1

I have a function parse_sdf(text).
When I call the function like this:

INSERT INTO test.table("Id", "Test") 
(SELECT props -> 'Id', props -> 'Test' FROM parse_sdf());

When I execute the INSERT with pgsql I want to pass as a parameter a text file which I download via curl. Like this:

INSERT INTO test.table("Id", "Test") 
(SELECT props -> 'Id', props -> 'Test' FROM parse_sdf('curl http://test/Files/text.txt'));

But it doesn't work. Is there a way to accomplish this?

UPDATE:

Postgres version: 10
Command will be executed with ExecuteSqlCommand command from Npgsql package for EF Core.

Palmi
  • 2,381
  • 5
  • 28
  • 65
  • [Execute system commands in postgresql](https://dba.stackexchange.com/questions/128229/execute-system-commands-in-postgresql#128254) – Lukasz Szozda Apr 24 '18 at 15:01
  • I know the COPY ... PROGRAM command. But this doesn't help me in my case. – Palmi Apr 24 '18 at 15:03
  • There is pl/sh language for PostgreSQL - https://github.com/petere/plsh - allows you to run linux shell scripts inside PostgreSQL. Did you try it? We use it for similar "corner cases"... – JosMac Apr 24 '18 at 16:13
  • I use npgsql for EF Core. So I need a pl/pgsql command. – Palmi Apr 24 '18 at 19:07
  • Why does `COPY FROM PROGRAM` not help you? You example URL indicates a local file? is that the case? Please clarify your question and always disclose your version of Postgres. In this case also your OS and relevant client / server setup. – Erwin Brandstetter Apr 25 '18 at 12:19
  • @ErwinBrandstetter Unless there is a way to combine a function and the curl command with the COPY FROM PROGRAM. File is not local all the time. – Palmi Apr 25 '18 at 14:38
  • Start by showing your function definition. – Erwin Brandstetter Apr 25 '18 at 14:44
  • It is a third party function. It accepts a text value which it splits and parses. – Palmi Apr 25 '18 at 14:59

0 Answers0