OSQL SELECT Command

PURPOSE:  This statement identifies a group of qualifying rows from one or more tables and displays them to the screen.  If the WITH WINDOW clause is specified, then an SMF window will be displayed.  If the DEFINE PM clause is included, then the process module created to execute the command will be saved in the current DBL under the object name specified.

Syntax

OSQL SELECT [DISTINCT] select_list  FROM \\table_name\\
      [WHERE str_exp]
      [ORDER BY str_exp]
      [WITH WINDOW]
      [INCLUDE include_list]
      [DEFINE PM process_module_name [ONLY]]

DISTINCT

specifies that duplicate rows will not be retrieved from the server.

select_list

specifies the column names to be retrieved.  The list is composed of one or more column names (separated by commas) or an asterisk ('*') that represents all columns in the order that they were specified when the table was created.  The asterisk may be qualified by a table name (Oracle extension).  For example, BOOKS_ORA.* would select all columns from the table that was related with the designator "BOOKS_ORA".

FROM table_name

is the name of table or table rows from which rows will be extracted.  This command makes a shared lock on a specified table more restrictive by holding it until the completion of the transaction that is defined by the SQL COMMIT WORK and SQL ROLLBACK WORK statements.  Normally the lock is released as soon as the required table or data page is no longer needed, whether or not the transaction has been completed.  This option only applies to the table for which it was specified and only for the duration of the transaction.

WHERE str_exp

You can set the string to contain any valid WHERE clause including column names, expressions, arithmetic operators, comparison operators, the keywords NOT, LIKE, IS NULL, AND, OR, BETWEEN, IN, EXISTS, ANY, ALL, sub-queries, or any combination of these items.  This string can be built dy­namically from within the process module.  There is no limit on the number of search conditions that can be included.  This search condition cannot contain aggregates.  See the 'WHERE clause' in the Oracle SQL Language Reference Manual for details.  Note all literals must be enclosed within single quote marks (i.e. '  ').

ORDER BY str_exp

You can set the string to contain any valid ORDER BY clause in­cluding a column name, an expression, or a number representing the position of the item in the select_list.

You can ORDER BY columns that do not appear in the select_list.  If you sort by a select_list number, the columns to which the ORDER BY refers must be included in the select list and the select_list cannot be "*".

The sort list may be terminated with "ASC" or "DESC".  "ASC" sorts results in ascending order, which is the default.  "DESC" sorts the results in descending order.  See the 'ORDER BY clause' in the Oracle Commands Reference Manual for details.

WITH WINDOW

specifies that a window containing the columns from the table will be displayed on the screen.  The window uses the SMF window development language of ACCENT R.

INCLUDE include_list

includes code from a Code Segment (CS) into a particular section/location within the OSQL generated process module.

DEFINE PM process_module_name

specifies that the process module containing the code generated to execute the OSQL command be saved and named as an object in the current DBL.  This process module is made up of ACCENT R SPL and SMF statements and is useful for prototyping applications.  Defining the Process Module causes your OSQL command to be compiled for faster execution.

ONLY

specifies that the Process Module will be created without being executed by OSQL.  This clause is used primarily by the OSQL BUILD command but may also be used for on-line prototyping.  If you include the ONLY clause then you must invoke the Process Module interactively.

Examples

*OSQL SELECT * FROM BOOKS_ORA, ROYALTIES_ORA WHERE &
BOOKS_ORA.TITLE_CODE = ROYALTIES_ORA.TITLE_CODE ORDER BY &
BOOKS_ORA.TITLE_CODE

*OSQL SELECT * FROM BOOKS_ORA WITH WINDOW DEFINE PM PROTO_1

OSQL Select Command

Figure 17 OSQL SELECT Command

SEE ALSO:  SQL SELECT statement

OSQL Menu Command    OSQL Update Command