Selecting one row

When you use the select statement without a cursor or array, it can return only one row of data. Embedded SQL requires a cursor or an array to return more than one row of data.

In Embedded SQL, a select statement must have an into clause. The clause specifies a list of host variables to be assigned values.

NoteThe current Embedded SQL precompiler version does not support into clauses that specify tables.

The syntax of the Embedded SQL select statement is:

exec sql [at connect_name]  
     select [all | distinct] select_list into
     :host_variable[[indicator]:indicator_variable]
     [, :host_variable 
     [[indicator]:indicator_variable]...]
 end-exec

For additional information on select statement clauses, see the Adaptive Server Enterprise Reference Manual.

The following select statement example accesses the authors table in the pubs2 database and assigns the value of au_id to the host variable ID:

exec sql select au_id into :ID from authors  
     where au_lname = "Stringer"
 end-exec