Thread: Interesting ECPG error

Interesting ECPG error

From
"Owens, Steve"
Date:
I'm running 7.4.2 and using ECPG's dynamic SQL capabilities to run some pgplsql functions in a database, some of which
justinsert records into a table. The dynamic SQL statement looks something like this: 

"SELECT create_foo(?, ?, ?, ?);"

I'm supplying all 4 arguments, and all 4 arguments have legal values, but ECPG always returns a -220 (too few
arguments)in sqlca.sqlcode when running these statements. Other functions that I have are of the form: 

"SELECT * from get_foo(?, ?);"

In these cases, with all valid arguments ECPG is returning a 0 (normal return).

Now, I assume that the -220 is due to a "malformed" SELECT statement in the first case, though this seems to work ok in
psql.My question is: is there a way to rewrite the failing case above so that it returns a 0 instead of a -220? 

Thanks!
This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain
confidentialinformation.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the
intendedrecipient(s) please contact the sender by reply e-mail and destroy all copies of the original message. Finally,
therecipient should check that this email is authentic and examine it for the presence of viruses. Xerox does perform
viruschecks but cannot accept liability for any damage caused by any virus transmitted by this email. Thank you. 




Re: Interesting ECPG error

From
Michael Meskes
Date:
On Fri, Jun 18, 2004 at 05:11:01PM -0400, Owens, Steve wrote:
> 
> I'm running 7.4.2 and using ECPG's dynamic SQL capabilities to run some pgplsql functions in a database, some of
whichjust insert records into a table. The dynamic SQL statement looks something like this:
 
> ...

Could you please run your program with logging enabled? Therefore you
just have to add this at the beginning of your program:

FILE *dbgs;
if ((dbgs = fopen("log", "w")) != NULL) ECPGdebug(1, dbgs);

and an fclose(dbgs) at the end of course. This creates a file named
"log". Then please send me that file. I'd like to see what's going on. 

-220 btw is "No Connection" so I assume you mean -202 which is given if
a "?" is left after processing of all variables. 

Also could you please send me the .pgc file and your .c file, i.e.
ecpg's output? Preferably in a small test case.

Thanks.

Michael
-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!


Re: Interesting ECPG error

From
Michael Meskes
Date:
On Tue, Jun 22, 2004 at 01:41:58PM -0400, Owens, Steve wrote:
> Ok, I've attached the log file and a tgz file containing a simple test case that duplicates the problem. I took a
lookdown in ECPGexecute and found 3 places where the TOO_FEW_ARGUMENTS error is being returned. If I get a chance, I'll
seeif I can generate an unstripped version of the ECPG library and get more information.
 

I think I found it. The reason is that your function does return a
tuple, but your statement offers no variable where this tuple can be
stored. I haven't looked at your function so far, but the log file shows
that PQresultStatus is PGRES_TUPLES_OK. So ecpg tries to read that
variable, which is NULL btw, into a variable but does not find one. Thus
the error message.

Michael

-- 
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!