|
Oracle9i Enterprise Edition User's Guide
Release 2 (9.2.0.1.0) for OS/390 Part No. A97312-01 |
|
The primary interface to the Oracle9i database server, SQL*Plus, provides a powerful environment for querying, defining, and controlling data.
This chapter describes accessing and running SQL*Plus commands and procedures in an OS/390 environment. The following topics are discussed:
The information in this chapter supplements the primary documentation for SQL*Plus found in the SQL*Plus User's Guide and Reference.
Oracle9i provides a native OS/390 UNIX System Services version of SQL*Plus. To run it, first ensure the environment is established as described in Chapter 4, Running an Oracle Utility Under USS, then enter the following at the command prompt:
sqlplus
For additional information, refer to Chapter 4, " Accessing Oracle9i Under USS" and the SQL*Plus User's Guide and Reference.
To access SQL*Plus as a command processor, use the following syntax:
SQLPLUS [-S] [userid[/password[@connect-string]]] [@start_file]
where:
| -S | calls SQL*Plus silently. The initial banner and the command prompts are not displayed. If used, then -S must be specified immediately following the SQLPLUS command. |
userid
|
is the Oracle user id. |
password
|
is the Oracle password associated with userid.
|
connect-string
|
is a tnsnames alias name or a complete Oracle Net address string. This parameter is optional if the Oracle database server is specified using methods described in Chapter 2. Otherwise, refer to Chapter 10 for further details. |
start_file
|
specifies a SQL command file to start after SQL*Plus initialization. This string must be separated from userid and password by at least one blank to indicate it is a start file and not a database pointer.
|
All parameters are optional to SQL*Plus.
According to the following syntax, the command connects Oracle user SCOTT to the Oracle instance specified in the ORA1 tnsnames alias. This automatically runs the SQL statements contained in member INITIAL in data set TEST.ORACLE.SQL:
SQLPLUS SCOTT/TIGER@ORA1 @/DSN/TEST.ORACLE.SQL(INITIAL)
Use of the [PA1] or [Attn] key interrupts the operation of SQL*Plus. When you enter a command producing results you did not expect or are not interested in viewing, using the attention interrupt is useful.
When running in TSO/E, SQL*Plus attempts to establish an attention processing exit using the TSO/E STAX service. For this to work, the ORASTAX module must be loadable from JOBLIB/STEPLIB, a linklist library, or LPA. If ORASTAX cannot be loaded, attention processing is suppressed; no messages are issued to indicate this condition.
When attention processing is established, it is used by both SQL*Plus and by the Oracle program interface code. The effect of an attention signal depends on whether SQL*Plus or an Oracle server is in control. If a request has been issued to a server, the attention signal is associated with the Oracle program interface and it will halt the in-progress server request. Otherwise, the signal is handled by SQL*Plus itself and will halt the current SQL*Plus activity. For example, if SQL*Plus is displaying large amounts of data from a SELECT statement, and attention will halt the output display and return to the "SQL>" prompt.
Because the computer operator can issue an attention interrupt at any time, the attention exit responds differently depending upon the processing state of SQL*Plus. Regardless of the processing state, the following message is displayed:
! Oracle ATTN.
If the [PA1] key is pressed during a running query or update, then the operation is canceled. The Oracle9i database server returns the following error message, acknowledging the cancel:
Error: ORA-1013: user requested cancel of current operation
If the [Attn] key is pressed during a running query, then the query might continue to retrieve and display a number of rows before the cancel is acknowledged. The query sometimes continues because the [Attn] key operates asynchronously. Any messages queued to the user before the attention interrupt are displayed.
If there is no update or query running, then SQL*Plus waits for other user input.
You can call SQL*Plus in the batch environment by running the ORASQL JCL procedure. This procedure is created during the Oracle9i database server installation process. Consult with your DBA or systems programming staff for the location of this procedure. A copy of the procedure is reproduced in the following example:
//ORASQL PROC INDEX=oran, // LIBV=orav, // SYSOUT='SYSOUT=*' //ORASQL EXEC PGM=SQLPLUS,REGION=4M //STEPLIB DD DSN=&INDEX..&LIBV..CMDLOAD,DISP=SHR //ORA$LIB DD DSN=&INDEX..&LIBV..MESG,DISP=SHR
When running this JCL procedure, include additional DD statements referring to other data sets required for proper operation of the utility.
The following JCL illustrates the use of the procedure described in the previous example:
//USER1JOB JOB ........ //STEP1 EXEC ORASQL,PARM='SCOTT/TIGER' //ORA@sid DD DUMMY //SYSIN DD DSN=SCOTT.ORACLE.SQL(SQLSTUFF),DISP=SHR
Note the additional DD statements:
ORA@sid, where sid is the SID associated with the Oracle9i database server to which you want to connect.
SYSOUT and SYSERR will be used if present.
Use this procedure as a model for creating your own JCL procedures conforming to your installation's policies.
To pass parameters to SQL*Plus in the batch environment, use the JCL PARM field.
You can also access the Oracle9i database server through the terminal monitor program (TMP) in batch mode. Refer to "Running Under TSO " in this case. File allocations required in TSO access are also required in batch mode.
During initialization, SQL*Plus searches for an allocation to the SQLLOGIN DD statement. If a file is allocated to this DD statement, then it is opened for input and the contents are run automatically, one command at a time, until an EOF is encountered. This DD statement points to a file that can contain any valid SQL or SQL*Plus statements you want run with each logon to SQL*Plus.
If the file allocated by the SQLLOGIN DD statement is not found during initialization, then the following messages are displayed:
ERROR OPENING /DD/SQLLOGIN: DDNAME STATEMENT MISSING OR MISSPELLED UNABLE TO OPEN FILE: "/DD/SQLLOGIN"
These messages signal an unsuccessful SQLLOGIN allocation and you are provided with the normal SQL prompt. This message display is not an error condition. It indicates automatic running of SQL or SQL*Plus statements at startup did not occur.
If you are not using automatic running of SQL or SQL*Plus statements at startup and do not want to receive these messages, then use the DUMMY parameter in the data set allocation.
A short SQLLOGIN profile example is shown in the following example:
_________________________________________________ Set echo off set feedback 4 set message on set echo on select * from daily_reminder; __________________________________________________
The SQL*Plus HOST command allows you to use a variety of commands and utilities from within SQL*Plus.
The SQL*Plus HOST command lets you run TSO/E commands from within SQL*Plus:
SQL> HOST SEND 'GOOD MORNING' USER(SMITH)
The HOST command is only valid in native TSO/E and cannot be used in batch mode.
The SQL*Plus HOST command lets you use CLISTs from within SQL*Plus. To run a CLIST use the following, where clist is the name of the CLIST to run:
SQL> HOST clist
SQL*Plus provides two means of gathering time usage information: the TIMING and SET TIMING commands. Refer to the SQL*Plus User's Guide and Reference for more information about TIMING and SET TIMING.
The TIMING command is used to record and display time usage statistics. The timing data returned has the following format:
Elapsed x:xx:xx.xx, user-CPU y.yy sec
where:
x:xx:xx.xx
|
is the amount of time since the current timing area started. |
y.yy
|
is the amount of CPU-time used since the current timing area started. |
The SET TIMING command is used to display time usage information. The information returned by the SET TIMING command is displayed after each SQL*Plus command is run. The timing data returned has the following format:
Elapsed x:xx:xx.xx, user-CPU y.yy sec
where:
x:xx:xx.xx
|
is the amount of time since the SQL*Plus command was issued. |
y.yy
|
is the amount of CPU-time used to run the SQL*Plus command. |
When you begin editing a member with ISPF, ISPF obtains an exclusive ENQ for QNAME SPFEDIT and a 52-byte RNAME consisting of the data set name and member. ENQ is held during the entire edit session. When you save the member, ISPF obtains a second exclusive ENQ for QNAME SPFEDIT and a 44-byte RNAME containing only the data set name. ISPF opens the PDS for output, writes the edited member, and closes the PDS. The two enqueues are released in the order they were obtained.
The DBA can use the PRODUCT_USER_PROFILE table, located in the SYSTEM account, to disable certain SQL*Plus commands for a user. You might be able to use the PRODUCT_USER_PROFILE table with your applications. For more information about the PRODUCT_USER_PROFILE table, consult with the DBA for your system and refer to the SQL*Plus User's Guide and Reference.
To exit SQL*Plus, you can enter one of the following:
SQL>EXIT [return code keyword | variable] SQL>QUIT [return code keyword | variable]
QUIT is a synonym for the EXIT command.
The EXIT command lets you specify an operating system return code. This enables you to run SQL*Plus command files in batch mode and detect any unexpected events. Under OS/390, the return code values are:
| Command | Condition | Return Code |
|---|---|---|
| SQL>EXIT | SUCCESS | 0 |
|
|
FAILURE | 1 |
| WARNING | 1 | |
<variable>
|
Value of <variable>
|
|
| SQL.SQLCODE | Return code from the last SQL operation to the database |
The syntax for the EXIT command is described in the SQL*Plus User's Guide and Reference.
There are special considerations for the following:
Special characters
String concatenation
Input line truncation
SQL*Plus ASCII function
The SQL symbol for negation is the exclamation point. For not equal, <> is recommended.
The SQL symbol for concatenation under OS/390 is the solid vertical bar.
A string concatenation function, CONCAT, provides an alternative to using the vertical bar character for concatenation. Installations that do not have computer keyboards with the vertical bar can use this function. For installations where the vertical bar is available on the computer keyboards and where portability to environments with other character sets is not important, the vertical bar character can be used.
The CONCAT function has the following syntax, where x and y are the strings to concatenate:
CONCAT('x','y')
The quotes in the syntax are required.
For example, the following statement selects rows where the employee name is CLARK:
SELECT * FROM EMP WHERE ENAME = CONCAT('CL','ARK');
SQL*Plus currently truncates, without warning, input lines exceeding 255 characters.
Under OS/390, the SQL ASCII function can cause confusion. Contrary to what the name implies, the ASCII function does not convert an EBCDIC value to its ASCII equivalent.
The ASCII function takes a character, in this case EBCDIC, and returns the number representation for that character in the given character set. For example, the ASCII value of A is 193 (ASCII('A')=193). The inverse function is CHR (meaning, CHR(193)='A').
The following functions are not supported:
The SPOOL OUT function documented in the SQL*Plus User's Guide and Reference is not supported in OS/390 in the TSO or batch environments. To spool to a data set that is automatically printed, you can use the following steps:
Allocate a DDname to SYSOUT:
//SPOOLED DD SYSOUT=*
Spool the output of the query to the pre-allocated DDname:
SQL> SPOOL /DD/SPOOLED
|
![]() Copyright © 2002 Oracle Corporation All rights reserved |
|