0007: * Create client interface environment 0008: status = SQLAllocEnv(henv) 0009: * Initialsie a connection environment within the client interface environ ment 0010: status = SQLAllocConnect(henv, hdbc) 0011: * Connect to the data source 0012: status = SQLConnect(hdbc, "sql2", "exploreworldwid\tlog","Tr4v3ll0g ") 0013: * Create an SQL Statement Environment 0014: status = SQLAllocStmt(hdbc, hstmt) 0015: * Pass an SQL statement (in SRDATA) to the data source readty for SQLExec ute 0016: *status = SQLPrepare(hstmt, SRDATA) ; CRT status 0017: * Set up parameters for input to spjiooutput 0018: CRT "Execute" 0019: status = SQLExecDirect(hstmt,SRDATA) 0020: * Bind columns to program variables 0021: status = SQLBindCol(hstmt,1,SQL.B.CHAR,XML1) 0022: OP = '' 0023: LOOP 0024: WHILE status <> SQL.NO.DATA.FOUND DO 0025: status = SQLFetch(hstmt) 0026: OP := XML1 0027: REPEAT 0028: 0029: *======================================================================== =========== 0030: * Release the SQL Statement Environment 0031: status = SQLFreeStmt(hstmt,SQL.DROP) 0032: * DisConnect from the data source 0033: status = SQLDisconnect(hdbc) 0034: * Releases a connection environment within the client interface environm ent 0035: status = SQLFreeConnect(hdbc) 0036: * Releases client interface environment 0037: status = SQLFreeEnv(henv)
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Sanjeebkumar Sarangi Sent: 08 March 2007 12:48 To: [email protected] Subject: [U2] How to use SQLExecDirect ? Hi, I created a sub routine and tried to execute a SQL query within it. In the Client programm i called the Subroutine within the SQLExecDirect function. Compilation, catalogging everything was fine. But the SQLExecDirect is returing a value '-1' which is an error and with the SQLError function I got the error as "invalid Cursor State". please, help me in this regard. Below is the block of code. >ED TEST2.BP MAIN 11 lines long. ----: PP 0002: $INCLUDE UNIVERSE.INCLUDE ODBC.H 0003: PRINT "ENTER THE ITEM CODE: ": ; INPUT ITEM 0004: ST = SQLExecDirect(@HSTMT,"CALL SUB(":ITEM:")") 0005: PRINT ST 0006: IF ST <> 0 THEN 0007: E = SQLError(SQL.NULL.HENV, SQL.NULL.HDBC, @HSTMT, STATE, CODE, MSG) 0008: PRINT "SQLSTATE = ":STATE:", ERROR CODE = ":CODE:", ERROR TEXT = " 0009: PRINT MSG 0012: END ----: pp 0001: SUBROUTINE SUB(ITM) 0002: $INCLUDE UNIVERSE.INCLUDE ODBC.H 0003: S="SELECT ITEM_CODE,DESCRIPTION FROM INVENTORY.T WHERE ITEM_CODE = ":ITM 0004: ST = SQLExecDirect(@HSTMT,S) 0005: RETURN >RUN TEST2.BP MAIN ENTER THE ITEM CODE: ?6 -1 SQLSTATE = 24000, ERROR CODE = 0, ERROR TEXT = [IBM][SQL Client]Invalid cursor state Sanjeeb =====-----=====-----===== Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you ------- u2-users mailing list [email protected] To unsubscribe please visit http://listserver.u2ug.org/ ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email ______________________________________________________________________ ------- u2-users mailing list [email protected] To unsubscribe please visit http://listserver.u2ug.org/
