Skip to content

SQLFileFetch Command

SQLFileFetch

Obsolete

Refer to the SQLBindFile method in the cSQLStatement class.

SQLFileFetch hstmt [To FileNumber1|FileName1 [Filenumber2|FileName2]]

The SQLFileFetch command will fetch the next row of a statement's result set. The columns are placed in the file buffers passed as arguments. If no argument is passed, the command will attempt to use a default file buffer. If the connection was opened using the SQLFileConnect command, the file used for this connection will be the default file. If the connection is opened using SQLConnect, the default file can be set using the SQLBindFetchFile command, or the file can be explicitly passed in the SQLFileFetch command.

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 no file, use default
    If (SQLResult) ;
        Showln Customer.Name ", " Customer.Address
Until (Not(SQLResult))

The Embedded SQL engine will use the base column and table names to determine if columns of a file are used. If the table and column name match, the column will be filled with the value from the result set. Some back ends do not support returning base table names. In that case, only the column name will be matched. This scheme allows the programmer to use statements that only select a limited number of columns from a table. The Embedded SQL engine will ensure the correct mapping is performed.

Open Customer
SQLFileConnect Customer 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))