Pretty basic, I just need to do this to test that our odbc is working correctly.
Here is the code in the tcl proc:
proc tps_db_select { args } {
keylget args MODE mode ;# Fetch mode
set dispList {} ;# Nothing to return
switch -exact — $mode {
start {
# initialize the ODBC call level interface
package require odbc
odbc SQLAllocHandle SQL_HANDLE_ENV SQL_NULL_HANDLE henv
# application is ODBC 3
odbc SQLSetEnvAttr $henv SQL_ATTR_ODBC_VERSION SQL_OV_ODBC3 0
# allocate a connection handle
odbc SQLAllocHandle SQL_HANDLE_DBC $henv hdbc
# connect to the data source: data source name: MSSQLServer
# user name: med_adm password: aspirin
odbc SQLConnect $hdbc wshsql2 SQL_NTS thorst02 SQL_NTS %My_Password% SQL_NTS
# allocate a statement handle
odbc SQLAllocHandle SQL_HANDLE_STMT $hdbc hstmt
set query “SELECT count(*) OrderIndex1”
set rVal [odbc SQLExecDirect $hdbc $query SQL_NTS]
echo $rval
#odbc SQLFreeHandle SQL_HANDLE_STMT $hstmt
odbc SQLDisconnect $hdbc
odbc SQLFreeHandle SQL_HANDLE_DBC $hdbc
odbc SQLFreeHandle SQL_HANDLE_ENV $henv
return
}
run {
# ‘run’ mode always has a MSGID; fetch and process it
keylget args MSGID mh
lappend dispList “CONTINUE $mh”
return $dispList
}
}
}
Here is the code in the odbc.ini file:
[wshsql2]
Driver=/qdxitest/qdx5.5/integrator/lib/lib/CVmsss22.so
Description=DataDirect 5.2 SQL Server Wire Protocol
Address=
AlternateServers=
AnsiNPW=Yes
ConnectionRetryCount=0
ConnectionRetryDelay=3
Database=EI_YorkImaging
LoadBalancing=0
LogonID=thorst02
Password=%My_Password%
QuotedId=No
SnapshotSerializable=0
Everything is exactly as i have it except the my_password areas have my actual password.
It fails allocating the statement handle. Here is my error:
[0:TEST] Tcl error:
msgId = none
proc = ‘tps_db_select’
args = ”
result = ‘invalid hstmt handle “hdbc0”
handle hdbc0 not found’
errorInfo: ‘
invalid hstmt handle “hdbc0”
handle hdbc0 not found
while executing
“odbc SQLExecDirect $hdbc $query SQL_NTS”
(”start” arm line 27)
invoked from within
“switch -exact — $mode {
start {
# initialize the ODBC call level interface
package require odbc
odbc SQLAllocHandle SQL_HANDLE_ENV SQL_NULL_HANDLE he…”
(procedure “tps_db_select” line 6)
invoked from within
“tps_db_select {CONTEXT sms_ib_data} {ARGS {}} {MODE start} {VERSION 3.0}”‘
Does anyone have any ideas?