Varchar parameter conversion

Varchar parameter conversion

am 23.07.2007 15:43:25 von Sergey.Zubkovsky

This is a multi-part message in MIME format.

------_=_NextPart_001_01C7CD2F.713E5EEF
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hello,

=20

My client program is developed on C++ & ODBC.

It's a Windows Unicode application.

=20

I'm trying to pass a "varchar" parameter value to a user-defined stored
procedure.

Each character of this actual parameter value (which ASC code is greater
than 127) is transformed into some two chars.

This value is stored and bound as a non-Unicode string (traditional
C-string) in the program.

So, some conversion happens for these characters.

It seems to me that it's the ODBC driver's intervention.

=20

Is that right?

And how can I avoid this unwanted conversion?

=20

Additional environment info:

=20

OS: Windows XP SP2

PostgreSQL version: "PostgreSQL 8.2.4 on i686-pc-mingw32, compiled by
GCC gcc.exe (GCC) 3.4.2 (mingw-special)"

ODBC driver version: PostgreSQL Unicode 8.02.04.00

=20

SHOW server_encoding;

"SQL_ASCII"

=20

SHOW client_encoding;

"SQL_ASCII"

=20

Thank you.

=20


------_=_NextPart_001_01C7CD2F.713E5EEF
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:Verdana'>Hello,



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



style=3D'font-size:
10.0pt;font-family:Verdana'>My client program is developed on C++ & =
ODBC.



style=3D'font-size:
10.0pt;font-family:Verdana'>It’s a Windows Unicode =
application.



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



style=3D'font-size:
10.0pt;font-family:Verdana'>I’m trying to pass a =
“varchar”
parameter value to a user-defined stored =
procedure.



color=3Dblack
face=3DVerdana> style=3D'font-size:9.0pt;font-family:Verdana;
color:black'>Each character of this actual parameter value (which ASC =
code is
greater than 127) is transformed into some two =
chars.



color=3Dblack
face=3DVerdana> style=3D'font-size:9.0pt;font-family:Verdana;
color:black'>This value is stored and bound as a non-Unicode string
(traditional C-string) in the program.



color=3Dblack
face=3DVerdana> style=3D'font-size:9.0pt;font-family:Verdana;
color:black'>So, some conversion happens for these =
characters.



color=3Dblack
face=3DVerdana> style=3D'font-size:9.0pt;font-family:Verdana;
color:black'>It seems to me that it’s the ODBC driver’s
intervention.



color=3Dblack
face=3DVerdana> style=3D'font-size:9.0pt;font-family:Verdana;
color:black'> 



color=3Dblack
face=3DVerdana> style=3D'font-size:9.0pt;font-family:Verdana;
color:black'>Is that right?



lang=3DEN-US
style=3D'font-size:9.0pt;font-family:Verdana;color:black'>An d how can I =
avoid
this unwanted conversion?
face=3DVerdana> lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:Verdana'>
<=
/p>

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



style=3D'font-size:
10.0pt;font-family:Verdana'>Additional environment =
info:



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



face=3D"Courier New"> lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Courier New"'>OS: =
Windows XP
SP2



face=3D"Courier New"> lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Courier =
New"'>PostgreSQL
version: “PostgreSQL 8.2.4 on i686-pc-mingw32, compiled by GCC =
gcc.exe
(GCC) 3.4.2 (mingw-special)”



face=3D"Courier New"> lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Courier New"'>ODBC =
driver
version: PostgreSQL Unicode 8.02.04.00



face=3D"Courier New"> lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Courier =
New"'> 



face=3D"Courier New"> lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Courier New"'>SHOW
server_encoding;



face=3D"Courier New"> lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Courier =
New"'>"SQL_ASCII"



face=3D"Courier New"> lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Courier =
New"'> 



face=3D"Courier New"> lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Courier New"'>SHOW
client_encoding;



face=3D"Courier New"> lang=3DEN-US style=3D'font-size:10.0pt;font-family:"Courier =
New"'>"SQL_ASCII"



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



style=3D'font-size:
10.0pt;font-family:Verdana'>Thank you.



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









------_=_NextPart_001_01C7CD2F.713E5EEF--

Re: Varchar parameter conversion

am 23.07.2007 16:40:59 von Andrei Kovalevski

Hello,

Try to use statements with parameters:
SQLBindParameters(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,=20
query_length, 0, param_ptr, query_length, buff_ptr);
SQLExecDirect(stmt, "{call SomeProc(?}}");

Zubkovsky, Sergey wrote:
>
> Hello,
>
> My client program is developed on C++ & ODBC.
>
> It=92s a Windows Unicode application.
>
> I=92m trying to pass a =93varchar=94 parameter value to a user-defined=20
> stored procedure.
>
> Each character of this actual parameter value (which ASC code is=20
> greater than 127) is transformed into some two chars.
>
> This value is stored and bound as a non-Unicode string (traditional=20
> C-string) in the program.
>
> So, some conversion happens for these characters.
>
> It seems to me that it=92s the ODBC driver=92s intervention.
>
> Is that right?
>
> And how can I avoid this unwanted conversion?
>
> Additional environment info:
>
> OS: Windows XP SP2
>
> PostgreSQL version: =93PostgreSQL 8.2.4 on i686-pc-mingw32, compiled by=
=20
> GCC gcc.exe (GCC) 3.4.2 (mingw-special)=94
>
> ODBC driver version: PostgreSQL Unicode 8.02.04.00
>
> SHOW server_encoding;
>
> "SQL_ASCII"
>
> SHOW client_encoding;
>
> "SQL_ASCII"
>
> Thank you.
>


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Re: Varchar parameter conversion

am 24.07.2007 13:37:27 von Sergey.Zubkovsky

Hello,

Thank you for your answer!
But this is the same what I do exactly.

I have realized the stored procedure call with a varchar parameter value
which originally contained characters with the ASC-codes from 1 to 255.
For visualization purpose all these chars were separated by char '-'.

A log file was produced by the ODBC driver is attached.

Look at the "GetPartitionName_sp" stored procedure call.
I suppose that the first parameter was converted to UTF-8.
But I didn't do this conversion!


-----Original Message-----
From: Andrei Kovalevski [mailto:andyk@commandprompt.com]=20
Sent: Monday, July 23, 2007 6:41 PM
To: Zubkovsky, Sergey
Cc: pgsql-odbc@postgresql.org
Subject: Re: [ODBC] Varchar parameter conversion

Hello,

Try to use statements with parameters:
SQLBindParameters(stmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,=20
query_length, 0, param_ptr, query_length, buff_ptr);
SQLExecDirect(stmt, "{call SomeProc(?}}");

Zubkovsky, Sergey wrote:
>
> Hello,
>
> My client program is developed on C++ & ODBC.
>
> It's a Windows Unicode application.
>
> I'm trying to pass a "varchar" parameter value to a user-defined=20
> stored procedure.
>
> Each character of this actual parameter value (which ASC code is=20
> greater than 127) is transformed into some two chars.
>
> This value is stored and bound as a non-Unicode string (traditional=20
> C-string) in the program.
>
> So, some conversion happens for these characters.
>
> It seems to me that it's the ODBC driver's intervention.
>
> Is that right?
>
> And how can I avoid this unwanted conversion?
>
> Additional environment info:
>
> OS: Windows XP SP2
>
> PostgreSQL version: "PostgreSQL 8.2.4 on i686-pc-mingw32, compiled by=20
> GCC gcc.exe (GCC) 3.4.2 (mingw-special)"
>
> ODBC driver version: PostgreSQL Unicode 8.02.04.00
>
> SHOW server_encoding;
>
> "SQL_ASCII"
>
> SHOW client_encoding;
>
> "SQL_ASCII"
>
> Thank you.
>


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org