Analyzing Results

4D - Documentation   Français   English   German   4D ODBC, Command Theme List   4D ODBC, Command Alphabetical List   Back   Previous   Next

version 1.5


After executing an SQL command that generates results, it is possible to use 4D ODBC routines to analyze the nature of those results.

Using OC Number rows processed and OC Number of columns you can determine the number of rows processed by a command and the number of columns selected in the result set.

OC Describe column and OC Column attributes provide information on the nature of the columns retrieved in your result set.

Probably most useful is the result returned by the OC Load row function. OC Load row returns 1 if there are additional rows pending, and 0 if there are no more rows. Using this information, it is possible to design a procedure that will return all rows from your results set.

The following example uses the OC Load row command to load rows into 4D arrays. Note the while loop, which tests if more rows are pending.

   ARRAY STRING(30;ar1;0)
   ARRAY STRING(30;ar2;0)
   ARRAY INTEGER(ar3;0)
   $sql:="select * from authors where city = 'Oakland'"
   $res:=OC Set SQL in Cursor (cursor_id;$sql)
   $res:=OC Bind (cursor_id;1;"ar1")
   $res:=OC Bind (cursor_id;2;"ar2")
   $res:=OC Bind (cursor_id;3;"ar3")
   $res:=OC Execute cursor (cursor_id)
   $res:=OC Load row(cursor_id)
   While ($res=1)
     $res:=OC Load row(cursor_id)
   End while

4D - Documentation   Français   English   German   4D ODBC, Command Theme List   4D ODBC, Command Alphabetical List   Back   Previous   Next