Thread: Re: Using variables from c to be passed into PQexec

Re: Using variables from c to be passed into PQexec

From
Carl van Tast
Date:
On 14 Feb 2002 21:55:00 -0800, vikashb@mweb.co.za (Vikash Badal)
wrote:

>strcat(querystr,"\"DECLARE mycursor CURSOR FOR select * from currpass
>where sitename = \'tvl\'\");

Vikash,
double quotes tell the C compiler, where a string literal starts and
ends.  Otherwise DECLARE would be interpreted as a name of a variable
and the next word wolud be a syntax error.  Your querystr should not
*contain* the double quotes.  So

strcat(querystr,"DECLARE mycursor CURSOR FOR select * from currpass
where sitename = 'tvl'");

should do the trick.  BTW, are you sure you want strcat and not
strcpy?

Kind regards,
 Carl van Tast