Re: Using variables from c to be passed into PQexec

From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
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 20:04:24
Message-ID: 1014321864.13240.734.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2002-02-15 at 05:55, Vikash Badal wrote:
> If I do this:
> strcat(querystr,"\"DECLARE mycursor CURSOR FOR select * from currpass
^^
> where sitename = \'tvl\'\");
^^
Why the double quotes?

They turn your command into a single identifier (whose length is limited
to 31 characters):

> 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

I don't think you need to escape the single quotes either:
strcat(querystr,"DECLARE mycursor CURSOR FOR select * from currpass
where sitename = 'tvl'");

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C

"My sheep hear my voice, and I know them, and they
follow me; And I give unto them eternal life; and they
shall never perish, neither shall any man pluck them
out of my hand." John 10:27,28

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2002-02-21 20:05:22 Re: pg_restore valid archive
Previous Message Oliver Elphick 2002-02-21 19:56:01 Re: Strange problem with inserts.