PostgreSQL 14.0.0, PSQLODBC30A.DLL 13.02.0000

Windows x64 (Windows 10 or Windows 11).

 

Migrating data from SQL Server (or any other dbms that supports SQ_WCHAR/SQL_WVARCHAR) data types) to PostgreSQL.

 

Steps to reproduce:

 

1 create SQL Server table source data table:

 

create table test_char(

col1 nchar(8),

col2 nvarchar(30));

 

2 create PostgreSQL table target table:

 

create table test_char(

col1 char(8),

col2 varchar(30));

 

3 add test data in MS SQL Server table:

 

insert into test_char

values

(N'a', N'a');

 

insert into test_char

values

(N'bb', N'bb');

 

insert into test_char

values

(N'ccc', N'ccc');

 

insert into test_char

values

(N'ffffffff', N'ffffffff');

 

4 application binds the two columns as SQL_C_CHAR and SQL_C_WCHAR (excerpt from attached log).

 

cmpdata         6be8-29f4 EXIT  SQLBindParameter  with return code 0 (SQL_SUCCESS)

               HSTMT               0x000000000591E5D0

               UWORD                        1

               SWORD                        1 <SQL_PARAM_INPUT>

               SWORD                       -8 <SQL_C_WCHAR>

               SWORD                        1 <SQL_CHAR>

               SQLULEN                    8

               SWORD                        0

               PTR                0x0000000000411178

               SQLLEN                    18

               SQLLEN *            0x0000000000411170 (-1)

 

5 drivers successfully executes the inserts statements into PostgreSQL but does not convert from SQL_WCHAR and SQL_WVARCHAR, looks like it driver just grabs the first bytes of each inserted value.

 

6 Actual inserted data is just the first letter of each bound value.

 

‘b’ instead of ‘bb’, ‘c’ instead of ‘ccc’, ‘f’ instead of ‘ffffffff’.

 

 

Please see attached log with insert statements and screen shots.

 

Farid

 

 

CompareData  Compare and synchronize sql dbms data visually

Strobe  Strobe light for your phone