Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Command Index > S > SELECT


Scroll Prev Top Next More

If the result consists of one row, this clause loads the data into one or more variables, one for each column value in the result.








Stores an INTEGER value (-1 or 0) that indicates whether the preceding into_var received a null value or a non-null value; this is an optional indicator variable. If you omit indicator variables, R:BASE displays a message and assigns a negative integer to SQLCODE if it encounters a null value. The command continues to process rows.



Indicates the following variable is an indicator variable, which is used to indicate if a null value is retrieved.



Assigns the result associated with a column, expression, or function named in the command clause to the corresponding variable named in the INTO clause. The number of items or variables named in the command and INTO clauses, as well as their data types, must be the same.


About the SELECT INTO command


This optional clause loads the results of a SELECT command into variables, but does not display the results on screen.


An INTO clause loads the resulting value of each column, expression, or function included in the command clause into a variable. If previous clauses have returned more than one row, the values assigned to the variables are unpredictable. You should make sure you are returning only one row. Either test the results before using an INTO clause or check the value of the variable sqlcode after executing the command. If the clause is successful, sqlcode is 0.




The INTO clause must have a corresponding variable for every item in the command clause; values are assigned to variables in the order of items in the command clause. The data type of each command clause item and its corresponding into_var must be compatible. For example:


SELECT MAX(listprice), MIN(listprice) +

  INTO vmaxprice INDICATOR vind_max, +

       vminprice INDICATOR vind_min +

            FROM product


The MAX and MIN functions assign the value $3,100.00 to the variable vmaxprice and $1,900.00 to vminprice. These values are the maximum and minimum values for the listprice column in the product table. Since both functions returned values, the value of both indicator variables is 0. Also, since only SELECT functions are specified, a GROUP BY clause is not required.


If you select and load a value into an undefined numeric variable, that variable acquires the precision and scale of the column from which the value is selected.