call to PostgreSQL function executed twice ?

From: "Jan van der Weijde" <Jan(dot)van(dot)der(dot)Weijde(at)attachmate(dot)com>
To: <pgsql-odbc(at)postgresql(dot)org>
Subject: call to PostgreSQL function executed twice ?
Date: 2006-11-30 15:05:30
Message-ID: 4B9C73D1EB78FE4A81475AE8A553B3C60780BB@exch-lei1.attachmate.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Hello,

I have an ODBC C-program that executes a call to a PostgreSQL function
called testprocedure.
The call is first prepared, using SQLPrepare(). Next SQLNumResultCols()
and SQLDescribeCol() are used to get information about the result of the
call.
Finally SQLExecute() is called to execute the call to the procedure.
The result now is that two records are inserted into table test, with
other words the PostgreSQL function testprocedure is called twice!

I use the next procedure:

CREATE OR REPLACE FUNCTION testprocedure("varchar") RETURNS void AS $$
BEGIN
insert into test values($1);
end;
$$
language 'plpgsql';

And the prepared and executed call is "select testProcedure('vib') as
strout"

I use PostgreSQL 8.1.4 on Windows XP professional and ODBC Driver
'PostgreSQL ANSI', version 8.01.02.00 from the PostgreSQL Global
Deveopment Group

It turns out, that SQLNumResultCols() or SQLDescribeCol() also execute
the call. And that the call to SQLExecute() then executes it a second
time.
When I leave SQLNumResultCols() out, SQLDescribeCol() will execute the
statement and the other way around.

Is this a bug or do I do something wrong?
>From what I understand from the ODBC documentation, only SQLExecute()
should execute a prepared function call.

Thank you,
Jan

Jan Ch. van der Weijde
Senior Software Engineer

<http://www.attachmate.com/>

<http://www.attachmate.com/>

Schipholweg 103
2316 XC Leiden
The Netherlands
+31 71 368 1173 phone
+31 71 368 1181 fax
Jan(dot)van(dot)der(dot)Weijde(at)attachmate(dot)com
www.attachmate.com <outbind://348/www.attachmate.com>


Browse pgsql-odbc by date

  From Date Subject
Next Message noreply 2006-12-01 05:07:54 [ psqlodbc-Bugs-1000706 ] SQLTables SQL_ALL_TABLE_TYPES return code 100
Previous Message Richard Wesley 2006-11-29 19:10:23 List databases using ODBC through OLE DB