ODBC driver chances function-call in a wrong way

ODBC driver chances function-call in a wrong way

am 16.01.2009 16:58:02 von Ida Schonfeld

This is a multi-part message in MIME format.

------_=_NextPart_001_01C977F3.366E54D3
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hello,

=20

I have the following problem:

=20

=20

I have a PG function in my database which looks like this:

=20

CREATE OR REPLACE FUNCTION help_sel0(IN a int,IN b char(2),OUT
master_fileset INT, OUT master_type CHAR(2), OUT highest_number INT)
RETURNS RECORD AS=20

$function$

DECLARE

r RECORD;

BEGIN

SELECT INTO r
master_fileset,master_type,highest_number=20

FROM gen_master

WHERE master_fileset=3D a

AND master_type=3D b;

master_fileset:=3Dr.master_fileset;

master_type:=3Dr.master_type;

highest_number:=3Dr.highest_number;

END;=20

$function$ =20

LANGUAGE plpgsql;

=20

When I now want to send with my ODBC-programm the following prepared
statement to the server

{SELECT * FROM gen_master_sel0(?,?);} (with the parameters 10 and 'S2')


the driver recognizes that I'm calling a "stored procedure", but he
doesn't notice the given parameter and changes the command to this=20

SELECT * FROM gen_master_sel0( 10, E'S2');() .

=20

Is this a bug in the recent driver (8.3.0400) which I'm using or has
anybody any idea what I might have done wrong? I have to say this is the
first time I'm working with Postgres so maybe my function is not ok?!

=20

I'm very thankful for ideas and suggestions :-)

=20

Thx, Ida

=20

=20


------_=_NextPart_001_01C977F3.366E54D3
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns=3D"http://www.w3.org/TR/REC-html40">


charset=3Dus-ascii">









style=3D'font-size:10.0pt;
font-family:Arial'>Hello,



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>I have the following =
problem:



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>I have a PG function in my database which looks like =
this:



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>CREATE OR REPLACE FUNCTION help_sel0(IN a int,IN b
char(2),OUT master_fileset INT, OUT master_type CHAR(2), OUT =
highest_number
INT) RETURNS RECORD AS



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  $function$



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  DECLARE



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;   r
RECORD;



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  BEGIN



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  SELECT
INTO  r master_fileset,master_type,highest_number =



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  FROM
gen_master



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  WHERE
master_fileset=3D a



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  AND  
master_type=3D b;



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  =
master_fileset:=3Dr.master_fileset;



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  master_type:=3Dr.master_type;



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  =
highest_number:=3Dr.highest_number;



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  END;



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  $function$ 



style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;   
LANGUAGE plpgsql;



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>When I now want to send with my ODBC-programm the =
following
prepared statement to the server



style=3D'font-size:10.0pt;
font-family:Arial'> {SELECT * FROM gen_master_sel0(?,?);} (with the
parameters 10 and ‘S2’)



style=3D'font-size:10.0pt;
font-family:Arial'> the driver recognizes that I’m calling a =
“stored
procedure”, but he doesn’t  notice the given parameter =
and
changes the command to this



style=3D'font-size:10.0pt;
font-family:Arial'>  SELECT * FROM gen_master_sel0( 10, E'S2');() =
..



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>Is this a bug in the recent driver (8.3.0400) which =
I’m
using or has anybody any idea what I might have done wrong? I have to =
say this
is the first time I’m working with Postgres so maybe my function =
is not
ok?!



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>I’m very thankful for ideas and suggestions =
size=3D2 face=3DWingdings> style=3D'font-size:10.0pt;font-family:Wingdings'>J size=3D2 face=3DArial> style=3D'font-size:10.0pt;font-family:Arial'> >

style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'>Thx, Ida



style=3D'font-size:10.0pt;
font-family:Arial'> 



style=3D'font-size:10.0pt;
font-family:Arial'> 









------_=_NextPart_001_01C977F3.366E54D3--

Re: ODBC driver chances function-call in a wrong way

am 17.01.2009 06:07:34 von Hiroshi Inoue

Ida Schonfeld wrote:
> Hello,
>=20
> =20
>=20
> I have the following problem:
>=20
> =20
>=20
> =20
>=20
> I have a PG function in my database which looks like this:
>=20
> =20
>=20
> CREATE OR REPLACE FUNCTION help_sel0(IN a int,IN b char(2),OUT=20
> master_fileset INT, OUT master_type CHAR(2), OUT highest_number INT)=20
> RETURNS RECORD AS
>=20
> $function$
>=20
> DECLARE
>=20
> r RECORD;
>=20
> BEGIN
>=20
> SELECT INTO r=20
> master_fileset,master_type,highest_number
>=20
> FROM gen_master
>=20
> WHERE master_fileset=3D a
>=20
> AND master_type=3D b;
>=20
> master_fileset:=3Dr.master_fileset;
>=20
> master_type:=3Dr.master_type;
>=20
> highest_number:=3Dr.highest_number;
>=20
> END;
>=20
> $function$=20
>=20
> LANGUAGE plpgsql;
>=20
> =20
>=20
> When I now want to send with my ODBC-programm the following prepared=20
> statement to the server
>=20
> {SELECT * FROM gen_master_sel0(?,?);} (with the parameters 10 and =91S=
2=92)

The above call is wrong.
You should prepare the ODBC style procedure call
{call gen_master_sel0(?,?)}
or you can simply prepare the pg-specific procedure call
SELECT * FROM gen_master_sel0(?,?)
..

regards,
Hiroshi Inoue


--=20
Sent via pgsql-odbc mailing list (pgsql-odbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc