Re: [GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-27 Thread Poul Kristensen
Solution: C is able to compile with an embedded shell script. So a small C program with an argument being the user passed to the shell script it succeded succesfully. I am aware that it could be my question was not specifically relevant to Postgresql! :) It took a while to solve. :) Thanks Poul

Re: [GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-23 Thread Poul Kristensen
My goal is to grap a user from the OS and and substitute the grapped user - to be the owner of the database - in the sql commands e.g using shell-script substitution syntax: create user ${user} with login; create tablespace ${user} location '/path/${user)'; create database

Re: [GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-23 Thread Tom Lane
"David G. Johnston" writes: > On Wed, Nov 23, 2016 at 3:46 AM, Poul Kristensen wrote: >> In the postgresql.log I get "select datname from $1". > ​That is expected when you parameterize a query - the query string includes > parameter​s instead of

Re: [GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-23 Thread David G. Johnston
On Wed, Nov 23, 2016 at 3:46 AM, Poul Kristensen wrote: > In the postgresql.log I get "select datname from $1". > ​That is expected when you parameterize a query - the query string includes parameter​s instead of values. What you are seeing is the "Prepare" component of a

Re: [GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-23 Thread Poul Kristensen
The below mentioned pg_database does not appear in $1. In the postgresql.log I get "select datname from $1". Do you have a suggestion of how to solve this? I get double declarations when using both char *paramValues[1] char *paramValues[1] //char *value1 = "pg_database"; //char **paramValues =

Re: [GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-22 Thread John McKown
On Tue, Nov 22, 2016 at 8:22 AM, Poul Kristensen wrote: > I think I understand. > When I use this in my code I get > "undefined reference to `PQexecParms' > ​The correct name is PQexecParams (note the last "a"). Sorry I missed that when first looking.​ Also, just to be sure,

Re: [GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-22 Thread Tom Lane
Poul Kristensen writes: > When I use this in my code I get > "undefined reference to `PQexecParms' > when compiling. IIRC, it's PQexecParams not PQexecParms regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To

Re: [GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-22 Thread Poul Kristensen
I think I understand. When I use this in my code I get "undefined reference to `PQexecParms' when compiling. references in main is const char *conninfo; /* connection string to the database */ PGconn *conn; /* connection to the database */ PGresult *res; /* result of sql query */ int nFields;

Re: [GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-21 Thread John McKown
On Mon, Nov 21, 2016 at 11:22 AM, Poul Kristensen wrote: > Thank you for fast repons! > > The $1 substitution below. I assume that it refers to "joe's place". But > it is not very clear to me, how "joe's place" will appear instead of $1 > when running. Where is it possiible to

Re: [GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-21 Thread John McKown
On Mon, Nov 21, 2016 at 8:56 AM, Poul Kristensen wrote: > Hi! > > Hopefully this is this list. > > A shell variabel is defined like this > > var1= value > > used like ${var1}. > > How is the equal defened in the Postgresql C programming? > > Thanks. > > Poul > > BTW: I have

Re: [GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-21 Thread Adrian Klaver
On 11/21/2016 06:56 AM, Poul Kristensen wrote: Hi! Hopefully this is this list. A shell variabel is defined like this var1= value used like ${var1}. How is the equal defened in the Postgresql C programming? You probably need to be more specific about what aspect of using C in Postgres

[GENERAL] Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used

2016-11-21 Thread Poul Kristensen
Hi! Hopefully this is this list. A shell variabel is defined like this var1= value used like ${var1}. How is the equal defened in the Postgresql C programming? Thanks. Poul BTW: I have not received my ordered book yet!