4D v13

ODBC_SQLFetch

Home

 
4D v13
ODBC_SQLFetch

ODBC_SQLFetch 


 

ODBC_SQLFetch ( stmtID ) -> Function result 
Parameter Type   Description
stmtID  Longint in Statement ID
Function result  Longint in Returns the result of the MS ODBC API function SQLFetch

The ODBC_SQLFetch command fetches the next rowset of data from the result set and returns data for all bound columns.

stmtID is a valid statement ID returned by ODBC_SQLAllocStmt.

For more information, please see the SQLFetch function in the MS ODBC API Reference at http://msdn.microsoft.com/en-us/library/ms712424(VS.85).aspx.

SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_NO_DATA, SQL_STILL_EXECUTING, SQL_ERROR, or SQL_INVALID_HANDLE.

Example  

The following method selects all the records from the Employee table, ccreates a bind with our data source's Employee table and its four fields specified by the ODBC_SQLPrepare and ODBC_SQLBindCol commands, and then creates one record for each row of data in the 4D table [Employees]:

 $result:=ODBC_SQLPrepare($statementID;"SELECT * FROM Employee")
 $result:=ODBC_SQLExecute($statementID)
 
 $result:=ODBC_SQLBindCol($statementID;1;->[Employees]Emp_ID)
 $result:=ODBC_SQLBindCol($statementID;2;->[Employees]Emp_Fullname)
 $result:=ODBC_SQLBindCol($statementID;3;->[Employees]Emp_HireDate)
 $result:=ODBC_SQLBindCol($statementID;4;->[Employees]Emp_CurrentEmployee)
 
 While($result#SQL_NO_DATA)
    CREATE RECORD([Employees])
    $result:=ODBC_SQLFetch($statementID)
    If($result#SQL_NO_DATA)
       SAVE RECORD([Employees])
    End if
 End while
 UNLOAD RECORD([Employees])
 
 $result:=ODBC_SQLFreeStmt($statementID;SQL_UNBIND)

 
PROPERTIES 

Product: 4D
Theme: ODBC_Results
Number: 16960

 
INDEX

Alphabetical list of commands

 
HISTORY 

Created: 4D ODBC Pro 2004

 
SEE ALSO 

ODBC_SQLBindCol
ODBC_SQLFetchScroll
ODBC_SQLFreeStmt