Statements

This chapter contains syntax diagrams, semantic descriptions, rules, and examples of the use of the SQL statements listed in the following table.

Table 36. SQL Schema Statements
SQL Statement Description Page
ALTER PROCEDURE (External) Alters the description of an external procedure ALTER PROCEDURE (External)
ALTER PROCEDURE (SQL) Alters the description of an SQL procedure ALTER PROCEDURE (SQL)
ALTER SEQUENCE Alters the description of a sequence ALTER SEQUENCE
ALTER TABLE Alters the description of a table ALTER TABLE
COMMENT Replaces or adds a comment to the description of an alias, column, function, index, package, parameter, procedure, table, type or view COMMENT
CREATE ALIAS Creates an alias CREATE ALIAS
CREATE DISTINCT TYPE Creates a distinct type CREATE DISTINCT TYPE
CREATE FUNCTION Creates a user-defined function CREATE FUNCTION
CREATE FUNCTION (External Scalar) Creates an external scalar function CREATE FUNCTION (External Scalar)
CREATE FUNCTION (External Table) Creates an external table function CREATE FUNCTION (External Table)
CREATE FUNCTION (Sourced) Creates a user-defined function based on another existing scalar or column function CREATE FUNCTION (Sourced)
CREATE FUNCTION (SQL Scalar) Creates an SQL scalar function CREATE FUNCTION (SQL Scalar)
CREATE FUNCTION (SQL Table) Creates an SQL table function CREATE FUNCTION (SQL Table)
CREATE INDEX Creates an index on a table CREATE INDEX
CREATE PROCEDURE Creates a procedure. CREATE PROCEDURE
CREATE PROCEDURE (External) Creates an external procedure. CREATE PROCEDURE (External)
CREATE PROCEDURE (SQL) Creates an SQL procedure. CREATE PROCEDURE (SQL)
CREATE SCHEMA Creates a schema and a set of objects in that schema CREATE SCHEMA
CREATE SEQUENCE Creates a sequence CREATE SEQUENCE
CREATE TABLE Creates a table CREATE TABLE
CREATE TRIGGER Creates a trigger CREATE TRIGGER
CREATE VIEW Creates a view of one or more tables or views CREATE VIEW
DROP Drops an alias, function, index, package, procedure, schema, table, trigger, type, or view DROP
GRANT (Distinct Type Privileges) Grants privileges on a distinct type GRANT (Distinct Type Privileges)
GRANT (Function or Procedure Privileges) Grants privileges on a function or procedure GRANT (Function or Procedure Privileges)
GRANT (Package Privileges) Grants privileges on a package GRANT (Package Privileges)
GRANT (Sequence Privileges) Grants privileges on a sequence GRANT (Sequence Privileges)
GRANT (Table Privileges) Grants privileges on a table or view GRANT (Table or View Privileges)
LABEL Replaces or adds a label on the description of an alias, column, package, table, or view LABEL
RENAME Renames a table, view, or index. RENAME
REVOKE (Distinct Type Privileges) Revokes the privilege to use a distinct type REVOKE (Distinct Type Privileges)
REVOKE (Function or Procedure Privileges) Revokes privileges on a function or procedure REVOKE (Function or Procedure Privileges)
REVOKE (Package Privileges) Revokes the privilege to execute statements in a package REVOKE (Package Privileges)
REVOKE (Sequence Privileges) Revokes privileges on a sequence REVOKE (Sequence Privileges)
REVOKE (Table Privileges) Revokes privileges on a table or view REVOKE (Table or View Privileges)
Table 37. SQL Data Change Statements
SQL Statement Description Page
DELETE Deletes one or more rows from a table DELETE
INSERT Inserts one or more rows into a table INSERT
UPDATE Updates the values of one or more columns in one or more rows of a table UPDATE
Table 38. SQL Data Statements
SQL Statement Description Page
All SQL Data Change statements Table 37
CLOSE Closes a cursor CLOSE
DECLARE CURSOR Defines an SQL cursor DECLARE CURSOR
FETCH Positions a cursor on a row of the result table; can also assign values from one or more rows of the result table to variables FETCH
FREE LOCATOR Removes the association between a LOB locator variable and its value FREE LOCATOR
HOLD LOCATOR Allows a LOB locator variable to retain its association with a value beyond a unit of work HOLD LOCATOR
LOCK TABLE Either prevents concurrent processes from changing a table or prevents concurrent processes from using a table LOCK TABLE
OPEN Opens a cursor OPEN
REFRESH TABLE Refreshes the data in a materialized query table REFRESH TABLE
SELECT Executes a query SELECT
SELECT INTO Assigns values to variables SELECT INTO
SET transition-variable Assigns values to a transition variable SET transition-variable
SET variable Assigns values to a variable SET variable
VALUES Provides a method to invoke a user-defined function from a trigger. VALUES
VALUES INTO Specifies a result table of no more than one row and assigns the values to variables. VALUES INTO
Table 39. SQL Transaction Statements
SQL Statement Description Page
COMMIT Ends a unit of work and commits the database changes made by that unit of work COMMIT
RELEASE SAVEPOINT Releases a savepoint within a unit of work RELEASE SAVEPOINT
ROLLBACK Ends a unit of work and backs out the database changes made by that unit of work or made since the specified savepoint ROLLBACK
SAVEPOINT Sets a savepoint within a unit of work SAVEPOINT
SET TRANSACTION Changes the isolation level for the current unit of work SET TRANSACTION
Table 40. SQL Connection Statements
SQL Statement Description Page
CONNECT (Type 1) Connects to an application server and establishes the rules for remote unit of work CONNECT (Type 1)
CONNECT (Type 2) Connects to an application server and establishes the rules for application-directed distributed unit of work CONNECT (Type 2)
DISCONNECT Immediately ends one or more connections DISCONNECT
RELEASE (Connection) Places one or more connections in the release-pending state RELEASE (Connection)
SET CONNECTION Establishes the application server of the process by identifying one of its existing connections SET CONNECTION
Table 41. SQL Dynamic Statements
SQL Statement Description Page
ALLOCATE DESCRIPTOR Allocates an SQL descriptor ALLOCATE DESCRIPTOR
DEALLOCATE DESCRIPTOR Deallocates an SQL descriptor DEALLOCATE DESCRIPTOR
DESCRIBE Describes the result columns of a prepared statement DESCRIBE
DESCRIBE INPUT Describes the input parameter markers of a prepared statement DESCRIBE INPUT
DESCRIBE TABLE Describes the columns of a table or view DESCRIBE TABLE
EXECUTE Executes a prepared SQL statement EXECUTE
EXECUTE IMMEDIATE Prepares and executes an SQL statement EXECUTE IMMEDIATE
GET DESCRIPTOR Gets information from an SQL descriptor GET DESCRIPTOR
PREPARE Prepares an SQL statement for execution PREPARE
SET DESCRIPTOR Sets items in an SQL descriptor SET DESCRIPTOR
Table 42. SQL Session Statements
SQL Statement Description Page
DECLARE GLOBAL TEMPORARY TABLE Defines a declared global temporary table DECLARE GLOBAL TEMPORARY TABLE
SET CURRENT DEBUG MODE Assigns a value to the CURRENT DEBUG MODE special register SET CURRENT DEBUG MODE
SET CURRENT DEGREE Assigns a value to the CURRENT DEGREE special register SET CURRENT DEGREE
SET ENCRYPTION PASSWORD Assigns a value to the default encryption password and default encryption password hint SET ENCRYPTION PASSWORD
SET PATH Assigns a value to the CURRENT PATH special register SET PATH
SET SCHEMA Assigns a value to the CURRENT SCHEMA special register SET SCHEMA
SET SESSION AUTHORIZATION Changes the user of the job and the USER special register SET SESSION AUTHORIZATION
Table 43. SQL Embedded Host Language Statements
SQL Statement Description Page
BEGIN DECLARE SECTION Marks the beginning of an SQL declare section BEGIN DECLARE SECTION
DECLARE PROCEDURE Defines an external procedure DECLARE PROCEDURE
DECLARE STATEMENT Declares the names used to identify prepared SQL statements DECLARE STATEMENT
DECLARE VARIABLE Declares a subtype or normalized other than the default for a host variable DECLARE VARIABLE
END DECLARE SECTION Marks the end of an SQL declare section END DECLARE SECTION
GET DIAGNOSTICS Obtains information about the previously executed SQL statement GET DIAGNOSTICS
INCLUDE Inserts declarations into a source program INCLUDE
SET OPTION Establishes the options for processing SQL statements SET OPTION
SET RESULT SET Identifies the result sets in a procedure SET RESULT SETS
SIGNAL Signals an error or warning condition SIGNAL
WHENEVER Defines actions to be taken on the basis of SQL return codes WHENEVER
Table 44. SQL Control Statements
SQL Statement Description Page
assignment-statement Assigns a value to an output parameter or to a local variable assignment-statement
CALL Calls a procedure CALL
CASE Selects an execution path based on multiple conditions CASE statement
compound-statement Groups other statements together in an SQL routine compound-statement
FOR Executes a statement for each row of a table FOR statement
GET DIAGNOSTICS Obtains information about the previously executed SQL statement GET DIAGNOSTICS statement
GOTO Branches to a user-defined label within an SQL routine or trigger GOTO statement
IF Provides conditional execution based on the truth value of a condition IF statement
ITERATE Causes the flow of control to return to the beginning of a labelled loop ITERATE statement
LEAVE Continues execution by leaving a block or loop LEAVE statement
LOOP Repeats the execution of a statement LOOP statement
REPEAT Repeats the execution of a statement REPEAT statement
RESIGNAL Resignals an error or warning condition RESIGNAL statement
RETURN Returns from a routine RETURN statement
SIGNAL Signals an error or warning condition SIGNAL statement
WHILE Repeats the execution of a statement while a specified condition is true WHILE statement

See also:



[ Top of Page | Previous Page | Next Page | Contents | Index ]