Re: Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used - Mailing list pgsql-general

From Poul Kristensen
Subject Re: Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used
Date
Msg-id CAAOuvVoEEJpM60UNyJR6DU=Ezf56a8R9yzMrzi_tDCwT88ofWQ@mail.gmail.com
Whole thread Raw
In response to Re: Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used  (John McKown <john.archie.mckown@gmail.com>)
Responses Re: Postgresql 9.5 and Shell scripts/variables vs. C programming/defining a value to be used  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general

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 = &value1; /* closer match to the documentation's syntax */
char *paramValues[1] = {"pg_database"}; /* same as above, different syntax */
//
//char *paramValues[1]; /* this looks to be missing */
//paramValues[0]={"pg_database"}; /* what you had */
           res = PQexecParams(conn,
           "select datname from $1",
           1, /* there is only 1 entry in paramValues array */
           NULL,
           paramValues, /* address of parameter value array */
           NULL, /* don't need param lengths since text */
           NULL, /* defaul to all text params */
           1); /* return all values as binary */

Thanks.

/Poul

2016-11-22 15:50 GMT+01:00 John McKown <john.archie.mckown@gmail.com>:
On Tue, Nov 22, 2016 at 8:22 AM, Poul Kristensen <bcc5226@gmail.com> 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, did you include the argument "-lpq" on the compile command to point to the PostgreSQL library for linking?

 
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;  /* print out the attribute names */
int i; / * print the columns */
     j;

Is the a reserved reference to use with

Reserved res = PQexecParms(conn.... )

Then I assume that I have to use another reference than res.

Thanks.

/Poul 


--
Heisenberg may have been here.


Maranatha! <><
John McKown



--
Med venlig hilsen / Best regards
Poul Kristensen
Linux-OS/Virtualizationexpert and Oracle DBA

pgsql-general by date:

Previous
From: "Charles Clavadetscher"
Date:
Subject: Re: max_connections limit violation not showing in pg_stat_activity
Next
From: Moreno Andreo
Date:
Subject: Re: [SPAM] Re: Best practices to manage custom statistics