AW: [INTERFACES] Postgres (NT), ODBC and DBTools
AW: [INTERFACES] Postgres (NT), ODBC and DBTools
От:
"Teulings, Tim" <Tim.Teulings@materna.de>
Дата:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hallo! > Have you tried switching on logging in the ODBC driver to see what > is being sent to the backend? Yes, here is an example output (hope it is not too long)... It contains the initialisation some queries and the a final UPDATE with causes a parse error (see STATEMENT ERROR...). After looking at it again, I'm not sure if it is a problem with the colon. The "?" in the statement looks supicious (itis near the 'where' stated in the error message). AFAIK ODBC does allow binding of variables (bind variable, bound expresion) and DBTools uses this. Is the "?" legal at this point (it references the value bound to a variable) or is it a error? Perhaps it is a problem with the ODBC driver settings? conn=25902376, SQLDriverConnect( in)='DSN=template1;UID=XXX;PWD=XXX;', fDriverCompletion=0 DSN info: DSN='template1',server='localhost',port='5432',dbase='template1',user= XXX',passwd='XXX' readonly='0',protocol='6.4',showoid='0',fakeoidindex='1',showsystable= 1' conn_settings='' translation_dll='',translation_option='' Global Options: Version='06.40.0006', fetch=100, socket=4096, unknown_sizes=0, max_varchar_size=254, max_longvarchar_size=8190 disable_optimizer=0, ksqo=1, unique_index=1, use_declarefetch=1 text_as_longvarchar=1, unknowns_as_longvarchar=0, bools_as_char=1 extra_systable_prefixes='dd_;', conn_settings='' conn=25902376, query=' ' conn=25902376, query='set DateStyle to 'ISO'' conn=25902376, query='set ksqo to 'ON'' conn=25902376, query='BEGIN' conn=25902376, query='declare SQL_CUR018C0040 cursor for select oid from pg_type where typname='lo'' conn=25902376, query='fetch 100 in SQL_CUR018C0040' [ fetched 0 rows ] conn=25902376, query='close SQL_CUR018C0040' conn=25902376, query='END' conn=25902376, SQLDriverConnect(out)='DSN=template1;DATABASE=template1;SERVER=localho t;PORT=5432;UID=XXX;PWD=XXX;READONLY=0;PROTOCOL=6.4;FAKEOIDINDEX=1;SHO OIDCOLUMN=0;ROWVERSIONING=0;SHOWSYSTEMTABLES=1;CONNSETTINGS=' conn=25902376, query='BEGIN' conn=25902376, query='declare SQL_CUR018F1650 cursor for select relname, usename, relhasrules from pg_class, pg_user where relkind = 'r' and relname like 'mds' and relname !~ '^xinv[0-9]+' and int4out(usesysid) = int4out(relowner)order by relname' conn=25902376, query='fetch 100 in SQL_CUR018F1650' [ fetched 1 rows ] conn=25902376, query='close SQL_CUR018F1650' conn=25902376, query='END' conn=25902376, query='BEGIN' conn=25902376, query='declare SQL_CUR018E1580 cursor for select u.usename, c.relname, a.attname, a.atttypid,t.typname, a.attnum, a.attlen, a.atttypmod, a.attnotnull from pg_user u, pg_class c, pg_attribute a, pg_type t where int4out(u.usesysid) = int4out(c.relowner) and c.oid= a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname like 'mds' order by attnum' conn=25902376, query='fetch 100 in SQL_CUR018E1580' [ fetched 3 rows ] conn=25902376, query='close SQL_CUR018E1580' conn=25902376, query='END' conn=25902376, query='BEGIN' conn=25902376, query='declare SQL_CUR018D13E0 cursor for SELECT t57.* FROM MDS t57 WHERE 0=0 AND t57.MsgKey LIKE 'CRC'' conn=25902376, query='fetch 100 in SQL_CUR018D13E0' [ fetched 0 rows ] conn=25902376, query='close SQL_CUR018D13E0' conn=25902376, query='END' conn=25902376, query='BEGIN' conn=25902376, query='declare SQL_CUR018D13E0 cursor for SELECT CXMgl.MglID, CXMgl.Name, CXMgl.Vorname, CXMgl.GebDat FROM CXMgl CXMgl ORDER BY CXMgl.Name ASC, CXMgl.Vorname ASC' conn=25902376, query='fetch 100 in SQL_CUR018D13E0' [ fetched 100 rows ] conn=25902376, query='fetch 100 in SQL_CUR018D13E0' [ fetched 100 rows ] conn=25902376, query='fetch 100 in SQL_CUR018D13E0' [ fetched 100 rows ] conn=25902376, query='declare SQL_CUR018E3008 cursor for SELECT CXMgl.RowVersion, CXMgl.Name, CXMgl.Vorname, CXMgl.GebDat, CXMgl.Strasse, CXMgl.Ort, CXMgl.OrtID, CXFirma1.Name, CXFirma1.Ort, CXMgl.FirmaID, CXMgl.Telefon, CXMgl.Fax, CXMgl.EMail, CXMgl.Sex, CXMgl.Bemerk FROM CXMgl CXMgl, CXFirma CXFirma1 WHERE CXMgl.FirmaID = CXFirma1.FirmaID AND CXMgl.MglID = 2776' conn=25902376, query='fetch 100 in SQL_CUR018E3008' [ fetched 1 rows ] conn=25902376, query='UPDATE CXMgl SET RowVersion = 2, Vorname = ? WHERE RowVersion = 1 AND MglID = 2776' ERROR from backend during send_query: 'ERROR: parser: parse error at or near "where"' conn=25902376, query='COMMIT' STATEMENT ERROR: func=SC_execute, desc='', errnum=1, errmsg='Error while executing the query' - ------------------------------------------------------------ hdbc=25902376, stmt=26161368, result=0 manual_result=0, prepare=1, internal=0 bindings=0, bindings_allocated=0 parameters=25897048, parameters_allocated=1 statement_type=2, statement='UPDATE CXMgl SET RowVersion = 2, Vorname = ? WHERE RowVersion = 1 AND MglID = 2776' stmt_with_params='UPDATE CXMgl SET RowVersion = 2, Vorname = ? WHERE RowVersion = 1 AND MglID = 2776' data_at_exec=-1, current_exec_param=-1, put_data=0 currTuple=-1, current_col=-1, lobj_fd=-1 maxRows=0, rowset_size=1, keyset_size=0, cursor_type=0, scroll_concurrency=1 cursor_name='SQL_CUR018F30D8' ----------------QResult Info - ------------------------------- CONN ERROR: func=SC_execute, desc='', errnum=110, errmsg='ERROR: parser: parse error at or near "where"' - ------------------------------------------------------------ henv=25902360, conn=25902376, status=1, num_stmts=16 sock=25896528, stmts=25896576, lobj_type=-999 ---------------- Socket Info - ------------------------------- socket=52, reverse=0, errornumber=0, errormsg='(null)' buffer_in=25908712, buffer_out=25912816 buffer_filled_in=3, buffer_filled_out=0, buffer_read_in=2 conn=25902376, SQLDisconnect - -- Gruß... Tim. -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 6.5.1 for non-commercial use iQA/AwUBOCA5x4aerLtCfP4IEQLJ5ACghmFg+XFTSi3z2AgP7sLtiyauK+oAoKhn 4/wO4dI++wGmvvCphrDHnxUo =doEE -----END PGP SIGNATURE-----
Re: AW: [INTERFACES] Postgres (NT), ODBC and DBTools
От:
"Ken J. Wright" <ken@ori-ind.com>
Дата:
>After looking at it again, I'm not sure if it is a problem with the >colon. The "?" in the statement looks supicious (itis near the >'where' >stated in the error message). AFAIK ODBC does allow binding of >variables >(bind variable, bound expresion) and DBTools uses this. Is the "?" >legal >at this point (it references the value bound to a variable) or is it >a >error? The '?' is fine but it's not getting replaced with the real value. The stmt_with_params string in the log is the actual string sent to the backend after parsing. I'm just guessing at the flag values, but it appears to me that there was not a "Prepare" statement in your code after assigning the sql string, and before assigning the parameter value. I'm not familiar with DBTools, so I don't know how it handles prepares. Normally it would go something like: (pseudo code) stmt.sql = 'select foo from bar where it = ?' stmt.prepare stmt.setparam(1,'avalue') stmt.execute Ken >ERROR from backend during send_query: 'ERROR: parser: parse error at >or near "where"' > hdbc=25902376, stmt=26161368, result=0 > manual_result=0, prepare=1, internal=0 > bindings=0, bindings_allocated=0 > parameters=25897048, parameters_allocated=1 > statement_type=2, statement='UPDATE CXMgl SET >RowVersion = 2, Vorname = ? WHERE RowVersion = 1 AND MglID = 2776' > stmt_with_params='UPDATE CXMgl SET RowVersion = 2, >Vorname = ? WHERE RowVersion = 1 AND MglID = 2776' > data_at_exec=-1, current_exec_param=-1, put_data=0 > currTuple=-1, current_col=-1, lobj_fd=-1 > maxRows=0, rowset_size=1, keyset_size=0, >cursor_type=0, scroll_concurrency=1 > cursor_name='SQL_CUR018F30D8' > ----------------QResult Info >- ------------------------------- >CONN ERROR: func=SC_execute, desc='', errnum=110, errmsg='ERROR: >parser: parse error at or near "where"'