ODBC parameter binding - Mailing list pgsql-interfaces
From | Tony Simopoulos |
---|---|
Subject | ODBC parameter binding |
Date | |
Msg-id | 06e201c07b2c$c8bc8770$0382a8c0@metavera.com Whole thread Raw |
List | pgsql-interfaces |
we are having problems getting the *nix ODBC driver (that came as part of the postgresql bundle) to bind values to the parameters given in the query. looking through the log file, and the code, it appears that the driver has no idea what the database type the column shouldbe. are there any special tables that the db requires in order to do this -- i poked around a little but didn't find any instructionson any data prep work, that is required to allow full ODBC functionality. my statement to be parsed is "select * from routes where name = ?" the driver correctly determines the input type (cType) to be SQL_CHAR, but has no idea what the database type (sqlType) shouldbe. as such, the code assumes that it is either a NUMERIC or BIT field, and finally resolves the statement as: "select * fromroutes where name = foo". this of course is wrong and fails because the single quotes are missing from around 'foo'. my only guess is that my database needs to prepped. any other ideas?? here is the log file output in question. <snip> **** SQLAllocStmt: hdbc = 136564736, stmt = 136794112 CC_add_statement: self=136564736, stmt=136794112 SQLGetInfo: entering...fInfoType=8 SQLGetInfo: p='<NULL>', len=4, value=191, cbMax=4 SQLSetStmtOption: entering... SetStmtOption(): SQL_CURSOR_TYPE = 2 SQLPrepare: entering... **** SQLPrepare: STMT_ALLOCATED, copy SQLNumParams: entering... SC_pre_execute: status = 1 preprocess: status = READY SQLExecute: entering... SQLExecute: clear errors... SQLExecute: copying statement params: trans_status=1, len=35, stmt='select * fro m routes where name = ?' stmt_with_params = 'select * from routes where name = ' Sending SELECT statement on stmt=136794112,cursor_name='SQL_CUR0x8275000 ' send_query(): conn=136564736, query='select * from routes where name = ' send_query: done sending query send_query: got id = 'Z' read 44, global_socket_buffersize=4096 send_query: got id = 'E' send_query: 'E' - ERROR: parser: parse error at or near "" done sending the query: STATEMENT ERROR: func=SC_execute, desc='', errnum=1, errmsg='Error while executi ng the query' CONN ERROR: func=SC_execute, desc='', errnum=110, errmsg='ERROR: parser: parse error at or near ""' preprocess: after status = FINISHED, so set PREMATURE SQLNumResultCols: result = 0, status = 2, numcols = -1 STATEMENT ERROR: func=SQLNumResultCols, desc='', errnum=3, errmsg='No query has been executed with that handle' CONN ERROR: func=SQLNumResultCols, desc='', errnum=110, errmsg='ERROR: parser: parse error at or near ""' SQLDescribeParam: entering... STATEMENT ERROR: func=SQLDescribeParam, desc='', errnum=11, errmsg='Invalid para meter number for SQLDescribeParam.' CONN ERROR: func=SQLDescribeParam, desc='', errnum=110, errmsg='ERROR: parser: parse error at or near ""' SQLBindParameter: entering... SQLBindParamater: ipar=0, paramType=1, fCType=1, fSqlType=0, cbColDef=-107794601 2, ibScale=-9800, rgbValue=135605836, *pcbValue = 4, data_at_exec = 0 SQLFreeStmt: entering...hstmt=136794112, fOption=0 recycle statement: self= 136794112 SC_free_params: ENTER, self=136794112 SC_free_params: EXIT SQLExecute: entering... SQLExecute: clear errors... SQLExecute: copying statement params: trans_status=1, len=35, stmt='select * fro m routes where name = ?' copy_statement_with_params: from(fcType)=1, to(fSqlType)=0 stmt_with_params = 'select * from routes where name = crap' Sending SELECT statement on stmt=136794112, cursor_name='SQL_CUR0x8275000 ' send_query(): conn=136564736, query='select * from routes where name = crap' send_query: done sending query read 1, global_socket_buffersize=4096 send_query: got id = 'Z' read 37, global_socket_buffersize=4096 send_query: got id = 'E' send_query: 'E' - ERROR: Attribute 'crap' not found done sending the query: STATEMENT ERROR: func=SC_execute, desc='', errnum=1, errmsg='Error while executi ng the query' CONN ERROR: func=SC_execute, desc='', errnum=110, errmsg='ERROR: Attribute 'cra p' not found' **** SQLError: henv=0, hdbc=0, hstmt=136794112 SC_get_error: status = 1, msg = #Error while executing the query; ERROR: Attribute 'crap' not found# szSqlState = 'S1000', szError='Error while executing the query; ERROR: Attribute 'crap' not found' SQLFreeStmt: entering...hstmt=136794112, fOption=3 SC_free_params: ENTER, self=136794112 SC_free_params: EXIT <snip>
pgsql-interfaces by date: