Displays a message in interactive SQL.
1 – Environment
You can use the PRINT statement in interactive SQL.
2 – Format
PRINT -+-+-> <literal> --+--+--------------------------------------+-+-->
| +-> <variable> -+ +-> AS <name> -+----------------------++ |
| +-> edit-using-clause -+ |
+------------------------ , <---------------------------------+
edit-using-clause =
--> EDIT USING -+-> edit-string ---+->
+-> <domain-name> -+
3 – Arguments
3.1 – AS name
Changes the name displayed in the print statement header. By
default literal values have a blank header name and variables
use their name as a header. If the header must include spaces or
lowercase characters then use SET QUOTING RULES or SET DIALECT to
enable delimited identifiers
3.2 – EDIT_USING
Syntax options:
EDIT USING edit-string|EDIT USING domain-name
Assigns an edit string for use when formatting the variable or
literal value. If a domain name is specified then the EDIT STRING
from the domain is used.
This clause is only permitted for interactive SQL.
3.3 – literal
Specifies the values you want displayed to the user during
execution of the command procedure. Enclose the character
literals in single quotation marks.
3.4 – variable
Prints the contents of the specified variable.
4 – Examples
Example 1: Displaying a literal from a command procedure
The following PRINT statement in a command procedure displays
'Creating trigger definitions for the database' during the
execution of the command procedure:
SQL> -- Trigger definition statements are next.
SQL> PRINT 'Creating trigger definitions for the database';
SQL> CREATE TRIGGER EMPLOYEE_ID_CASCADE_DELETE
.
.
.
Example 2: Displaying a variable
The following PRINT statement displays the definition of a
variable:
SQL> DECLARE :X CHAR(10);
SQL> BEGIN
cont> SET :X = 'Active';
cont> END;
SQL> PRINT :X;
X
Active