Re: Using variables from c to be passed into PQexec

From: "Tim Barnard" <tbarnard(at)povn(dot)com>
To: "Vikash Badal" <vikashb(at)mweb(dot)co(dot)za>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using variables from c to be passed into PQexec
Date: 2002-02-21 19:35:46
Message-ID: 017c01c1bb0e$fffea7e0$a519af3f@hartcomm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Don't pass in the double-quotes in your call. In other words:

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

should work.

Tim

----- Original Message -----
From: "Vikash Badal" <vikashb(at)mweb(dot)co(dot)za>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Thursday, February 14, 2002 9:55 PM
Subject: [GENERAL] Using variables from c to be passed into PQexec

> Greetings,
>
> I am a novice programmer and I am now totally lost,
> I've been through the web trying to find a solution,
> If I've posted on the wrong place please advise.
>
>
> If I have this line in the code, I get there desired result.
> res = PQexec(conn, "DECLARE mycursor CURSOR FOR select * from currpass
> where sitename = 'tvl'");
> I get :
> ------------------------------------------------------------------
> sitename password date time
>
> tvl Zb0sj1sds 2002-02-13 12:21:00
> ------------------------------------------------------------------
>
> If I do this:
> strcat(querystr,"\"DECLARE mycursor CURSOR FOR select * from currpass
> where sitename = \'tvl\'\");
> fprintf(stdout,"%s\n", querystr);
> res = PQexec(conn, querystr);
>
> I get
> --------------------------------------------------------------------------
-
> Output of fprintf:
> "DECLARE mycursor CURSOR FOR select * from currpass where sitename =
> 'tvl'"
>
> Error Message:
> NOTICE: identifier "DECLARE mycursor CURSOR FOR select * from
> currpass where si
> tename = 'tvl'" will be truncated to "DECLARE mycursor CURSOR FOR sel"
> DECLARE CURSOR command failed
>
> --------------------------------------------------------------------------
---
>
> What am I missing ?
>
> Please assist
>
> Vikash
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Griffiths 2002-02-21 19:37:44 Re: search engines
Previous Message Ian Harding 2002-02-21 19:34:11 Re: Postgresql/linux speed + reliability