SQLBindFetchFile Command
Obsolete
Refer to the SQLBindFile method in the cSQLStatement class.
Syntax
SQLBindFetchFile hstmt|hdbc FileNumber|FileName
The SQLBindFetchFile command allows the programmer to set up a default file for a connection or statement. If the default is set up, no arguments need to be passed to the SQLFileFetch command. This is normally only used when a file connection has been opened using the SQLConnect command (as opposed to the SQLFileConnect command).
Example
SQLSetConnect "DB2_DRV"_ID "DSN=CompanyServer;UID=John;PWD=Secret"
SQLConnect To hdbc
SQLOpen hdbc To hstmt
SQLBindFetchFile hstmt Customer // set default file for fetches
SQLExecDirect hstmt "SELECT * FROM CUSTOMER WHERE AccntMngr = 'Mary'"
Repeat
SQLFileFetch hstmt
If (SQLResult) ;
Showln Customer.Name ", " Customer.Address
Until (Not(SQLResult))
When a file connection is opened using SQLFileConnect, the default file is automatically set to the file number passed with this command. Normally, this will be the file you will want to use as the bind file. Therefore, if SQLFileConnect is used, you will rarely need to execute the SQLBindFetchFile command.
Example
Open Customer
SQLFileConnect Customer To hdbc // this will bind Customer as fetch file
SQLOpen hdbc To hstmt
SQLExecDirect hstmt "SELECT * FROM CUSTOMER WHERE AccntMngr = 'Mary'"
Repeat
SQLFileFetch hstmt
If (SQLResult) ;
Showln Customer.Name ", " Customer.Address
Until (Not(SQLResult))
If you use the SQLConnect command to create a connection, no default file is set. In such a case, using the SQLBindFetchFile command would allow you to set a default file. If you do not set a default file, you must pass a file name with the SQLFileFetch command.
Example
SQLSetConnect "DB2_DRV"_ID "DSN=CompanyServer;UID=John;PWD=Secret"
SQLConnect To hdbc
SQLOpen hdbc To hstmt
SQLExecDirect hstmt "SELECT * FROM CUSTOMER WHERE AccntMngr = 'Mary'"
Repeat
SQLFileFetch hstmt to Customer
If (SQLResult) ;
Showln Customer.Name ", " Customer.Address
Until (Not(SQLResult))