DECLARE DATAROWS

Declares an ADO.NET DataRows cursor (similar to an SQL cursor) based on criteria established against a particular DataTable.

Syntax:

>>--EXEC ADO---.--------------------.--DECLARE datarows_name DATAROWS->
               +-USING dataset_name-+

 >--.------------------------------------.—-FROM datatable_name------->
    |              +--- , ---+           |
    |              V         |           |
    +--FOR SELECT--column_name-----------+


 >--.-----------------------------------.—---------------------------->
    +-FOR-.-ADDED-------------.-DATAROWS+
          +-CURRENT-----------+
          +-DELETED-----------+
          +-MODIFIED CURRENT--+
          +-MODIFIED ORIGINAL-+
          +-ORIGINAL----------+
          +-UNCHANGED---------+  


 >-.----------------------------------------------------.--—END-EXEC-->< 
   |                                                    |  
   +-WHERE search_conditions--.----------------------.--+
   |                          +-ORDER BY sort_clause-+  | 
   |                                                    |
   +-WHERE CHILDREN OF cursor_name (relation_name)------+ 
   +-WHERE PARENTS  OF cursor_name (relation_name}------+    
   +-ORDER BY sort_clause-------------------------------+
			

Parameters:

dataset_name The DataSet reference to be used. If you do not specify dataset_name, the current DataSet is used.
datarows_name The name of a DataRows cursor.
column_name The names of the columns in the DataTable to specify in the DataRows cursor.
FOR row_state DATAROWS Identifies the DataRows to use in a DataTable based on the row_state value.
datatable_name The name of the DataTable on which the DataRows cursor is defined.
search_conditions Any valid expression that can follow the standard SQL WHERE clause.
sort_clause Any valid expression that can follow the standard SQL ORDER BY clause.
cursor_name The name of a DataRows cursor to be associated with this DataRows cursor (as either a parent or a child.)
relation_name The name of the constraint which specifies the parent-child relationship between this DataRows cursor and the cursor_name cursor referenced above. relation_name is defined in the DECLARE DATASET statement.

Comments:

The standard cursor manipulation statements (OPEN, FETCH, DELETE (POSITIONED), UPDATE (POSITIONED) and CLOSE) are also applicable to an ADO.NET DataRows cursor.

In addition to the standard WHERE clause, the DECLARE DATAROWS statement allows you to navigate parent-child relationships of related DataRows cursors with the WHERE CHILDREN and WHERE PARENTS clauses.

Example:

     EXEC ADO
        DECLARE drOrder DATAROWS  
        FOR SELECT OrderID, OrderDate FROM Orders
        WHERE CHILDREN OF drCust(custord)
     END-EXEC