pg.ddx.io pgsql-odbc@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Insert with bound columns 3+ messages / 2 participants [nested] [flat]
* Insert with bound columns @ 2003-02-06 18:33 Andreas Pflug <Andreas.Pflug@web.de> 0 siblings, 1 reply; 3+ messages in thread From: Andreas Pflug @ 2003-02-06 18:33 UTC (permalink / raw) To: pgsql-odbc Did anybody succeed in inserting empty string columns using bound columns? INSERT INTO testtab (keyCol, strCol) VALUES (1, '') or (1, NULL) succeeds, but INSERT INTO testtab (keyCol, strCol) VALUES (?,?) does not. I debugged the driver and found that SQLNumParams will return 2 for the bound column version,which is obviously correct. Unfortunately, MSDASQL seems to expect 1 (I checked by changing it with debugger), but that will make the ODBC driver unhappy. I changed the database access class to replace all empty strings with a one-space string. This made MSDASQL happy, but will not be reasonable for production. I'm using native OLEDB, thus MSDASQL is my provider using ODBC 7.2.5 from source. Feedback from ADO users is welcome, they're using OLEDB implicitely. I checked MSDN and Technet for this,and traced the output of PGadmin II which is not using bound columns so it's not helpful to me. Any hints? Andreas ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Insert with bound columns @ 2003-02-06 21:56 Andreas Pflug <Andreas.Pflug@web.de> parent: Andreas Pflug <Andreas.Pflug@web.de> 0 siblings, 1 reply; 3+ messages in thread From: Andreas Pflug @ 2003-02-06 21:56 UTC (permalink / raw) To: pgsql-odbc After experimenting heavily, I found out some more. MSDASQL doesn't like a NULL-pointer as string in the buffer to be written. Instead, a SysAllocString(L"") is needed. This is acceptable, if an zero length string should be inserted. If the status field of the buffer ist not set to DBSTATUS_S_OK indicating valid data to be written, but to DBSTATUS_S_ISNULL for a NULL to be inserted, MSDASQL will fail with "Parameter type cannot be determined for at leas one variant parameter". Actually, it's no variant given, but a DBTYPE_BSTR, and this information is put correctly into the DBBINDING structure. Still, I believe ADO users should be unable to insert a NULL string into a VARCHAR column (if not omitted in the query). The same (OLEDB side) code works with SQLSRV32, and MSDASQL blows as soon as it gets to know the number of parameters, so it seems that for SQLSRV32 MSDASQL can determine the parameter type from the SQL server driver, but not with PostgreSQL. Does this switch on a light for anybody, saying "ah now I know what SQLxxyy is for"? If pointed towards some topic, I could try to implement it. Regards, Andreas ^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Insert with bound columns @ 2003-02-07 04:17 Hiroshi Inoue <Inoue@tpf.co.jp> parent: Andreas Pflug <Andreas.Pflug@web.de> 0 siblings, 0 replies; 3+ messages in thread From: Hiroshi Inoue @ 2003-02-07 04:17 UTC (permalink / raw) To: Andreas Pflug <Andreas.Pflug@web.de>; +Cc: pgsql-odbc Andreas Pflug wrote: > > After experimenting heavily, I found out some more. > MSDASQL doesn't like a NULL-pointer as string in the buffer to be > written. Instead, a SysAllocString(L"") is needed. This is acceptable, > if an zero length string should be inserted. If the status field of the > buffer ist not set to DBSTATUS_S_OK indicating valid data to be written, > but to DBSTATUS_S_ISNULL for a NULL to be inserted, MSDASQL will fail > with "Parameter type cannot be determined for at leas one variant > parameter". Actually, it's no variant given, but a DBTYPE_BSTR, and this > information is put correctly into the DBBINDING structure. Still, I > believe ADO users should be unable to insert a NULL string into a > VARCHAR column (if not omitted in the query). I can insert a '' or NULL using ADO.Parameter in VB. > The same (OLEDB side) code works with SQLSRV32, and MSDASQL blows as > soon as it gets to know the number of parameters, so it seems that for > SQLSRV32 MSDASQL can determine the parameter type from the SQL server > driver, but not with PostgreSQL. The psqlodbc driver couldn't determine the parameter type unless the upper application specifies it explicitly. > Does this switch on a light for > anybody, saying "ah now I know what SQLxxyy is for"? If pointed towards > some topic, I could try to implement it. Maybe SQLDescribeParam should be supported though I'm not sure. regards, Hiroshi Inoue http://www.geocities.jp/inocchichichi/psqlodbc/ ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-02-07 04:17 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2003-02-06 18:33 Insert with bound columns Andreas Pflug <Andreas.Pflug@web.de> 2003-02-06 21:56 ` Andreas Pflug <Andreas.Pflug@web.de> 2003-02-07 04:17 ` Hiroshi Inoue <Inoue@tpf.co.jp>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox