From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Laurent Marzullo <laurent(dot)marzullo(at)atosorigin(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: PQexecParams and CURSOR |
Date: | 2005-01-16 00:32:15 |
Message-ID: | 20050116003215.GA11076@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Jan 14, 2005 at 12:31:24PM +0100, Laurent Marzullo wrote:
> paramValues[0] = "2"; // This is the parameter for the query
>
> res = PQexecParams( conn ,
> "DECLARE MY_CURSOR FOR "
> "SELECT * FROM GRGL.RANGE_MODIFIER "
> "WHERE WEAPON_ID = $1",
> 1,
> NULL,
> paramValues,
> NULL,
> NULL,
> 0);
Are you checking the result status of this command? If so, what
does your error checking code look like? In 8.0.0rc5 this command
fails due to the missing keyword CURSOR before FOR.
> res = PQexec( conn , "FETCH 1 FROM MY_CURSOR" );
>
> => Error
> FETCH failed: ERROR: no value found for parameter 1
Again, what does your error checking code look like? If I correct
the syntax error in the DECLARE statement above then this query
succeeds.
> res = PQexecParams( conn ,
> "FETCH 1 FROM MY_CURSOR",
> 1,
> NULL,
> paramValues,
> NULL,
> NULL,
> 0);
>
> => Error:
> FETCH failed: ERROR: bind message supplies 1 parameters, but prepared
> statement "" requires 0
The error tells you what's wrong: you're supplying parameters that
the SQL statement isn't looking for. Change the nParams value from
1 to 0 and pass NULL instead of paramValues, or use PQexec() instead
of PQexecParams() since you're not passing any parameters.
If you still have trouble then please post a minimal but complete
program so we can see everything you're doing.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | Jim C. Nasby | 2005-01-16 01:15:02 | Re: Index optimization ? |
Previous Message | Edmund Dengler | 2005-01-16 00:00:53 | Re: Multi-column indexes |