Thread: Driver errors with Autocad (please help)
Hi everybody, I've run in a number of problem trying to use Autocad Map 2000i with postgres ODBC driver. Autocad claims to use OLEDB/ODBC driver to access data, but in fact I use it with my visual basic programs and I get no errors, everything is working fine. When I connect to PostgreSQL data source Autocad says that it's a read-only data source (this is not true, I can modify data from VB). I can stand this, I don't need to modify data. Anyway, when I try to perform some operations (creation of a thematic map based on data contained in PostgreSQL tables) I get a "cursor operation conflict" error. Notice that if I use OLEDB/ODBC driver over an Access DSN everything goes fine (and I see the source as read/write). Also, I've found that if I link pgsql tables to and access db and the I use Access OLEDB provider everything runs fine (but I cannot use that solution since in my db table get created and dropped during system's life, this is not a static db) I've tryied to give a look at logs and there are some errors. In sql.log I've found the following errors, that are issued when I connect to PostgreSQL tables from Autocad (if you like I can send you the full log file): acad f0-50 ENTER SQLGetInfoW HDBC 04DF3DF8 UWORD 151 <SQL_KEYSET_CURSOR_ATTRIBUTES2> PTR 0582AC68 SWORD 4 SWORD * 0x00000000 acad f0-50 EXIT SQLGetInfoW with return code -1 (SQL_ERROR) HDBC 04DF3DF8 UWORD 151 <SQL_KEYSET_CURSOR_ATTRIBUTES2> PTR 0582AC68 SWORD 4 SWORD * 0x00000000 acad f0-50 ENTER SQLGetInfoW HDBC 04DF3DF8 UWORD 168 <SQL_STATIC_CURSOR_ATTRIBUTES2> PTR 0582AC68 SWORD 4 SWORD * 0x00000000 acad f0-50 EXIT SQLGetInfoW with return code -1 (SQL_ERROR) HDBC 04DF3DF8 UWORD 168 <SQL_STATIC_CURSOR_ATTRIBUTES2> PTR 0582AC68 SWORD 4 SWORD * 0x00000000 In psqlodbc logs I also found the following error, that is issued when I try to execute thematic map creation: conn=102033048, query='SELECT CLASSE FROM tav974 WHERE SIAPK974=' ERROR from backend during send_query: 'ERROR: parser: parse error at or near ""' STATEMENT ERROR: func=SC_execute, desc='', errnum=-1, errmsg='Error while executing the query (non-fatal)' ------------------------------------------------------------ hdbc=102033048, stmt=103096400, result=102040592 manual_result=0, prepare=1, internal=0 bindings=0, bindings_allocated=0 parameters=0, parameters_allocated=0 statement_type=0, statement='SELECT CLASSE FROM tav974 WHERE SIAPK974=?' stmt_with_params='SELECT CLASSE FROM tav974 WHERE SIAPK974=' 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_CUR06252050' ----------------QResult Info ------------------------------- fields=102040976, manual_tuples=0, backend_tuples=0, tupleField=0, conn=0 fetch_count=0, fcount=0, num_fields=0, cursor='(NULL)' message='(NULL)', command='(NULL)', notice='(NULL)' status=6, inTuples=0 CONN ERROR: func=SC_execute, desc='', errnum=110, errmsg='ERROR: parser: parse error at or near ""' ------------------------------------------------------------ henv=102041232, conn=102033048, status=1, num_stmts=16 sock=102047696, stmts=102047616, lobj_type=-999 ---------------- Socket Info ------------------------------- socket=272, reverse=0, errornumber=0, errormsg='(NULL)' buffer_in=103088192, buffer_out=103092296 buffer_filled_in=44, buffer_filled_out=0, buffer_read_in=44 It seems that Autocad is trying to create a prepared statement with a parameter (statement='SELECT CLASSE FROM tav974 WHERE SIAPK974=?' where ? is the parameter) I also can see from sql.log: acad f0-50 ENTER SQLPrepareW HSTMT 04DF2050 WCHAR * 0x0384F138 [ 42] "SELECT CLASSE FROM tav974 WHERE SIAPK974=?" SDWORD 42 acad f0-50 EXIT SQLPrepareW with return code 0 (SQL_SUCCESS) HSTMT 04DF2050 WCHAR * 0x0384F138 [ 42] "SELECT CLASSE FROM tav974 WHERE SIAPK974=?" SDWORD 42 acad f0-50 ENTER SQLNumResultCols HSTMT 04DF2050 SWORD * 0x0582E8D0 acad f0-50 EXIT SQLNumResultCols with return code 0 (SQL_SUCCESS) HSTMT 04DF2050 SWORD * 0x0582E8D0 (0) acad f0-50 ENTER SQLFreeStmt HSTMT 04DF2050 UWORD 1 <SQL_DROP> acad f0-50 EXIT SQLFreeStmt with return code 0 (SQL_SUCCESS) HSTMT 04DF2050 UWORD 1 <SQL_DROP> (* SQL.LOG ENDS HERE *) So, how it is, here it seems that the prepared statement gets processed the right way... but then it gets called without parameters? Anyone can give me some advice? I can program in C and I have Visual C++, althought I don't have any experience with ODBC protocol, so even an advice on how to correct ODBC driver from source code would be appreciated. Regards Aime Andrea
I also tried psqlodbcplus (http://www.greatbridge.org/project/psqlodbcplus) which is supposed to support ODBC 3.0 level (or tries to support it...) but I get exactly the same errors. If I didn't misunderstood the documentation errors reported in psq.log are related to ODBC 3.0 compliance. Regards Andrea Aime
I begin to see some light now that I've spent some hours looking at the logs and at the source code. Autocad first prepares a statement with SQLPrepare, and the statement looks like: "SELECT CLASSE FROM tav974 WHERE SIAPK974=?" Then it calls SQLNumResultCols, which in turn calls SC_pre_execute and finally SQLExecute wich fails because there is still no parameter binding. If I set "Parse statements = 1" then SQLNumResultCols runs fine and returns 1, but the subsequent SQLDescribeCol fails because it calls SC_pre_execute... That happens in the following code (from results.c): if (stmt->parse_status != STMT_PARSE_FATAL && stmt->fi && stmt->fi[icol]) { if (icol >= stmt->nfld) { stmt->errornumber = STMT_INVALID_COLUMN_NUMBER_ERROR; stmt->errormsg = "Invalid column number in DescribeCol."; SC_log_error(func, "", stmt); return SQL_ERROR; } mylog("DescribeCol: getting info for icol=%d\n", icol); fieldtype = stmt->fi[icol]->type; col_name = stmt->fi[icol]->name; precision = stmt->fi[icol]->precision; mylog("PARSE: fieldtype=%d, col_name='%s', precision=%d\n", fieldtype, col_name, precision); if (fieldtype > 0) parse_ok = TRUE; } } /* * If couldn't parse it OR the field being described was not parsed * (i.e., because it was a function or expression, etc, then do it the * old fashioned way. */ if (!parse_ok) { SC_pre_execute(stmt); <======= HERE!!!!!!! Now, it seems that this happens because stmt->fi[icol] doesn't get properly initialized... ok, how can I solve it? Any suggestion would be much appreciated. Regards Andrea Aime
Andrea Aime wrote: > > I begin to see some light now that I've spent some hours looking > at the logs and at the source code. Autocad first prepares a > statement with SQLPrepare, and the statement looks like: > "SELECT CLASSE FROM tav974 WHERE SIAPK974=?" > Then it calls SQLNumResultCols, which in turn calls SC_pre_execute > and finally SQLExecute wich fails because there is still no > parameter binding. If I set "Parse statements = 1" then SQLNumResultCols > runs fine and returns 1, but the subsequent SQLDescribeCol fails > because it calls SC_pre_execute... That happens in the following code > (from results.c): > > if (stmt->parse_status != STMT_PARSE_FATAL && stmt->fi && > stmt->fi[icol]) > { > if (icol >= stmt->nfld) > { > stmt->errornumber = STMT_INVALID_COLUMN_NUMBER_ERROR; > stmt->errormsg = "Invalid column number in DescribeCol."; > SC_log_error(func, "", stmt); > return SQL_ERROR; > } > mylog("DescribeCol: getting info for icol=%d\n", icol); > > fieldtype = stmt->fi[icol]->type; > col_name = stmt->fi[icol]->name; > precision = stmt->fi[icol]->precision; > > mylog("PARSE: fieldtype=%d, col_name='%s', precision=%d\n", fieldtype, > col_name, precision); > if (fieldtype > 0) > parse_ok = TRUE; > } > } > > /* > * If couldn't parse it OR the field being described was not parsed > * (i.e., because it was a function or expression, etc, then do it the > * old fashioned way. > */ > if (!parse_ok) > { > SC_pre_execute(stmt); <======= HERE!!!!!!! > > Now, it seems that this happens because stmt->fi[icol] doesn't get > properly initialized... Isn't the second parameter of the SQLDescribeCol() zero ? regards, Hiroshi Inoue
Here is a snippet from sql.log: ... acad 78-48 EXIT SQLPrepareW with return code 0 (SQL_SUCCESS) HSTMT 04DF21B8 WCHAR * 0x0384F010 [ 42] "SELECT CLASSE FROM tav974 WHERE SIAPK974=?" SDWORD 42 acad 78-48 ENTER SQLNumResultCols HSTMT 04DF21B8 SWORD * 0x057BE924 acad 78-48 EXIT SQLNumResultCols with return code 0 (SQL_SUCCESS) HSTMT 04DF21B8 SWORD * 0x057BE924 (1) acad 78-48 ENTER SQLDescribeColW HSTMT 04DF21B8 UWORD 1 WCHAR * 0x00000000 SWORD 0 SWORD * 0x00000000 SWORD * 0x057BE93C SQLULEN * 0x057BE948 SWORD * 0x057BE958 SWORD * 0x057BE932 acad 78-48 EXIT SQLDescribeColW with return code -1 (SQL_ERROR) HSTMT 04DF21B8 UWORD 1 WCHAR * 0x00000000 SWORD 0 SWORD * 0x00000000 SWORD * 0x057BE93C SQLULEN * 0x057BE948 SWORD * 0x057BE958 SWORD * 0x057BE932 DIAG [S1002] Invalid column number in DescribeCol.; ERROR: parser: parse error at or near "" (13) acad 78-48 ENTER SQLGetDiagRecW SQLSMALLINT 3 SQLHANDLE 04DF21B8 SQLSMALLINT 1 SQLWCHAR * 0x057BE4C8 (NYI) SQLINTEGER * 0x057BE4E8 SQLWCHAR * 0x057BE0C8 (NYI) SQLSMALLINT 512 SQLSMALLINT * 0x057BE4D8 acad 78-48 EXIT SQLGetDiagRecW with return code 0 (SQL_SUCCESS) SQLSMALLINT 3 SQLHANDLE 04DF21B8 SQLSMALLINT 1 SQLWCHAR * 0x057BE4C8 (NYI) SQLINTEGER * 0x057BE4E8 (13) SQLWCHAR * 0x057BE0C8 (NYI) SQLSMALLINT 512 SQLSMALLINT * 0x057BE4D8 (80) acad 78-48 ENTER SQLGetDiagRecW SQLSMALLINT 3 SQLHANDLE 04DF21B8 SQLSMALLINT 2 SQLWCHAR * 0x057BE4C8 (NYI) SQLINTEGER * 0x057BE4E8 SQLWCHAR * 0x057BE0C8 (NYI) SQLSMALLINT 512 SQLSMALLINT * 0x057BE4D8 acad 78-48 EXIT SQLGetDiagRecW with return code 100 (SQL_NO_DATA_FOUND) SQLSMALLINT 3 SQLHANDLE 04DF21B8 SQLSMALLINT 2 SQLWCHAR * 0x057BE4C8 (NYI) SQLINTEGER * 0x057BE4E8 SQLWCHAR * 0x057BE0C8 (NYI) SQLSMALLINT 512 SQLSMALLINT * 0x057BE4D8 acad 78-48 ENTER SQLFreeStmt HSTMT 04DF21B8 UWORD 1 <SQL_DROP> ... The second parameter is 1, that is converted at the beginning of SQLDescribeCol into 0 in order to get a 0-based index... Hope this helps Hiroshi Inoue wrote: > > Andrea Aime wrote: > > > > I begin to see some light now that I've spent some hours looking > > at the logs and at the source code. Autocad first prepares a > > statement with SQLPrepare, and the statement looks like: > > "SELECT CLASSE FROM tav974 WHERE SIAPK974=?" > > Then it calls SQLNumResultCols, which in turn calls SC_pre_execute > > and finally SQLExecute wich fails because there is still no > > parameter binding. If I set "Parse statements = 1" then SQLNumResultCols > > runs fine and returns 1, but the subsequent SQLDescribeCol fails > > because it calls SC_pre_execute... That happens in the following code > > (from results.c): > > > > if (stmt->parse_status != STMT_PARSE_FATAL && stmt->fi && > > stmt->fi[icol]) > > { > > if (icol >= stmt->nfld) > > { > > stmt->errornumber = STMT_INVALID_COLUMN_NUMBER_ERROR; > > stmt->errormsg = "Invalid column number in DescribeCol."; > > SC_log_error(func, "", stmt); > > return SQL_ERROR; > > } > > mylog("DescribeCol: getting info for icol=%d\n", icol); > > > > fieldtype = stmt->fi[icol]->type; > > col_name = stmt->fi[icol]->name; > > precision = stmt->fi[icol]->precision; > > > > mylog("PARSE: fieldtype=%d, col_name='%s', precision=%d\n", fieldtype, > > col_name, precision); > > if (fieldtype > 0) > > parse_ok = TRUE; > > } > > } > > > > /* > > * If couldn't parse it OR the field being described was not parsed > > * (i.e., because it was a function or expression, etc, then do it the > > * old fashioned way. > > */ > > if (!parse_ok) > > { > > SC_pre_execute(stmt); <======= HERE!!!!!!! > > > > Now, it seems that this happens because stmt->fi[icol] doesn't get > > properly initialized... > > Isn't the second parameter of the SQLDescribeCol() zero ? > > regards, > Hiroshi Inoue > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
Hi Andrea, Andrea Aime wrote: > > Here is a snippet from sql.log: > Could you show me mylog output ? regards, Hiroshi Inoue