SQL$HELP72.HLB  —  SELECT  Singleton Select
    Specifies a result table. A result table is an intermediate table
    of values derived from columns and rows of one or more tables or
    views that meet conditions specified by a select expression.
    The tables or views that the columns and rows come from are
    identified in the FROM clause of the statement.

    The basic element of a SELECT statement is called a select
    expression. The Select_Expressions HELP topic describes select
    expressions in detail.

    To retrieve rows of a result table in host language programs,
    you must use the DECLARE CURSOR statement or a special form of
    SELECT statement called a singleton select. A singleton select
    statement specifies a one-row result table, and is allowed in
    either precompiled programs or as part of a procedure in an SQL
    module. A singleton select includes an additional clause, INTO,
    to assign the values in the row to host language variables in a
    program.

    For information on the general form of the SELECT statement, see
    the SELECT General_Form statement.

1  –  Environment

    You can use a singleton select statement:

    o  In interactive SQL

    o  Embedded in host language programs to be precompiled

    o  As part of a procedure in an SQL module

    o  In dynamic SQL as a statement to be dynamically executed

2  –  Format

  (B)0singleton-select =                                         
                                                             
  SELECT qwqqqqqqqqqqqqqwq> select-list qqk                  
          tq> ALL qqqqqqu                 x                  
          mq> DISTINCT qj                 x                  
    lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj                  
    mq> into-target qqqqqqqqqqqqqqqqqk                       
    lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj                       
    m> FROM qwqq> table-ref qqqqqwqk                         
             mqqqqqqqqqq , <qqqqqj x                         
    lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj                         
    m> WHERE predicate qwqqqqqqqqqqqqq>qqqqqqqqqqqqqqqqqwk   
                        mq> GROUP BY qw> <column-name> wjx   
                                      mqqqqqqq , <qqqqqj x   
    lqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqj   
    mwqqqqqqqqqqqqqqqqqqqqwqwqqqqqqqqqqqqqqqqqqqqqqqwqqqqk   
     m> HAVING predicate qj mq> limit-to-clause qqqqj    x   
    lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj   
    mqwqqqqqqqqqqqqqqqqqqqqqwqwqqqqqqqqqqqqqqqqqqqqqwqqqqqq>
      m> for-update-clause qj mq> optimize-clause qqj

  (B)0into-target =
  qqqq> INTO qqwqwq> <parameter> qqqqqqqqqqqwwq>
               x tq> <qualified-parameter> qux  
               x mq> <variable> qqqqqqqqqqqqjx  
               mqqqqqqqqqqqqq , <qqqqqqqqqqqqj  
                                                

  (B)0for-update-clause =                           
                                                
  qq> FOR UPDATE qwqqqqqqqqqqqqqqqqqqqqqqqqqwq> 
                  mqwq> OF <column-name> qwqj   
                    mqqqqqqqq , <qqqqqqqqqj     
                                                

  (B)0optimize-clause =                                                 
                                                                    
  qqwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwqqq> 
    mq> OPTIMIZE qqwqwq> FOR qwq> FAST FIRST qqqqqqqqwqqqqqqqqqqwqwqj     
                   x x        tq> TOTAL TIME qqqqqqqqu          x x       
                   x x        mq> SEQUENTIAL ACCESS qj          x x
                   x tq> USING <outline-name> qqqqqqqqqqqqqqqqqqu x 
                   x tq> WITH qwq> DEFAULT  qqwq> SELECTIVITY  qu x
                   x x         tq> SAMPLED  qqu                 x x
                   x x         mq> AGGRESSIVE j                 x x
                   x mq> AS <query-name> qqqqqqqqqqqqqqqqqqqqqqqj x 
                   mqqqqqqqqqqqqqqqq <qqqqqqqqqqqqqqqqqqqqqqqqqqqqj 
                                                                    

3  –  Arguments

3.1  –  INTO

    Syntax options:

       INTO parameter
       INTO qualified-parameter
       INTO variable

    Specifies a list of parameters, qualified parameters
    (structures), or variables to receive values from the columns
    of the one-row result table. The variables named must have been
    declared in the host program. If a variable named in the list
    is a host structure, SQL considers the reference the same as a
    reference to each of the elements of the host structure.

    If the number of variables specified, either explicitly or by
    reference to a host structure, does not match the number of
    values in the row of the result table, SQL generates an error
    when it precompiles the program or compiles the SQL module file.

    If columns in the result table from a singleton select include
    null values, the corresponding parameters must include indicator
    parameters.

3.2  –  select-list

    For a description of select lists, see the Select_Expressions
    HELP topic.
Close Help