ODBC driver chances function-call in a wrong way

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,



I have the following problem:





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



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

$function$

DECLARE

r RECORD;

BEGIN

SELECT INTO r
master_fileset,master_type,highest_number

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;

$function$

LANGUAGE plpgsql;



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

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



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?!



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



Thx, Ida






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

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

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<style>
<!--
/* Font Definitions */
[at] font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:Arial;
color:windowtext;}
[at] page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.Section1
{page:Section1;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DDE =
style=3D'font-size:10.0pt;
font-family:Arial'>Hello,<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span lang=3DDE =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>I have the following =
problem:<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>I have a PG function in my database which looks like =
this:<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
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 <o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  $function$<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  DECLARE<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;   r
RECORD;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  BEGIN<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  SELECT
INTO  r master_fileset,master_type,highest_number =
<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  FROM
gen_master<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  WHERE
master_fileset=3D a<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  AND  
master_type=3D b;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  =
master_fileset:=3Dr.master_fileset;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  master_type:=3Dr.master_type;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  =
highest_number:=3Dr.highest_number;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  END;
<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;  $function$ 
<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>         =
            &=
nbsp;   
LANGUAGE plpgsql;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
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<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'> {SELECT * FROM gen_master_sel0(?,?);} (with the
parameters 10 and ‘S2’) <o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
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 <o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>  SELECT * FROM gen_master_sel0( 10, E'S2');() =
..<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
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?!<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

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

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Thx, Ida<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p> </o:p></span></font></p>

</div>

</body>

</html>

------_=_NextPart_001_01C977F3.366E54D3--
Ida Schonfeld [ Fr, 16 Januar 2009 16:58 ] [ ID #1985128 ]

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

Ida Schonfeld wrote:
> Hello,
>
>
>
> I have the following problem:
>
>
>
>
>
> I have a PG function in my database which looks like this:
>
>
>
> 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
>
> $function$
>
> DECLARE
>
> r RECORD;
>
> BEGIN
>
> SELECT INTO r
> master_fileset,master_type,highest_number
>
> 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;
>
> $function$
>
> LANGUAGE plpgsql;
>
>
>
> 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 =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


--
Sent via pgsql-odbc mailing list (pgsql-odbc [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-odbc
Hiroshi Inoue [ Sa, 17 Januar 2009 06:07 ] [ ID #1985298 ]
Datenbanken » gmane.comp.db.postgresql.odbc » ODBC driver chances function-call in a wrong way

Vorheriges Thema: Psqlodbc install problem
Nächstes Thema: Re: ODBCNET