Re: Using variables from c to be passed into PQexec - Mailing list pgsql-general

From Carl van Tast
Subject Re: Using variables from c to be passed into PQexec
Date
Msg-id 5oip6u070tgt09ts3t9kvipva46j6i1n1a@4ax.com
Whole thread Raw
List pgsql-general
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

pgsql-general by date:

Previous
From: Samik Raychaudhuri
Date:
Subject: Re: Installing DBD::Pg module without Pg Database server
Next
From: Josh Rovero
Date:
Subject: Re: Postal code radius searches