SELECT INTO

Retrieves one or more DataRows from a DataTable into host variables or host arrays, enabling you to select information from a DataTable without declaring a DataRows cursor.

Syntax:

>>---EXEC ADO--.--------------------.—--SELECT---------------->
               +-USING dataset_name-+ 


                          +--  ,  --+         +---- , ----+
                          V         |         V           | 
 >--.-----------------.---column_name---INTO--:col_value_hv--->
    +-CURRENT VALUES--+
    +-DEFAULT VALUES--+
    +-ORIGINAL VALUES-+
    +-PROPOSED VALUES-+


>--FROM datatable_name---------------------------------------->
                        

>--.----------------------------------------------------.--—--> 
   |                                                    |  
   +-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-------------------------------+


>--END-EXEC---><

Parameters:

dataset_name The DataSet reference to be used. If you do not specify dataset_name, the current DataSet is used.
VALUES group Determines which type of DataRows to use in the selection criteria.
column_name The columns in the DataTable whose data values are retrieved.
col_value_hv Host variable where the columns data values are stored.
datatable_name The DataTable used in the selection criteria.
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 the 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.

Comment:

This statement is similar to the embedded EXEC SQL SELECT INTO statement.

Example:

     MOVE 99 TO staff-id
     EXEC ADO
        SELECT last_name
        INTO :lname
        FROM staff
        WHERE staff_id=:staff-id
     END-EXEC

     EXEC ADO
        SELECT staff_id
        INTO :staff-id
        FROM staff
        WHERE first_name = 'Phil'
     END-EXEC