Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

CURSOR

DATABASE

SCHEMA

STATEMENT

TABLE

TRANSACTION

FOR_UPDATE_OF

More Information

select expr

More Information

More Information

More Information

col definition

table constraint

sql and dtr clause

More Information

More Information

tx options

db txns

More Information

More Options

More Information

RDB/VMS SQL DECLARE — VMS SQLdev_2.0

 Specifies a cursor, database, table, statement, or transaction to VAX
 SQL.

Additional information available:

CURSORDATABASESCHEMASTATEMENTTABLETRANSACTION

CURSOR

 DECLARE cursor-name CURSOR FOR --+
 +--------------------------------+
 +-> select-expr --+
 | +---------------+
 | +-+---------------------+-+-------------------------------------+-+->
 |   +-> order-by-clause --+ +-> FOR UPDATE OF -+-> column-name -+-+ |
 |                                              +------ , <------+   |
 +-> statement-name -------------------------------------------------+

 order-by-clause =

 --> ORDER BY -++-> column-name -+-+---->----+-+-->
               |+-> integer -----+ +-> ASC --+ |
               |                   +-> DESC -+ |
               +------------ , <---------------+

Additional information available:

FOR_UPDATE_OF

More Informationselect expr

More Information

 The DECLARE CURSOR statement defines a cursor, a result table that
 exists through execution of more than one SQL statement.  Host
 language programs require cursors to individually process rows in a
 result table.

 The result table is created by an OPEN statement.  FETCH and CLOSE
 statements can operate on a cursor after it is opened.

FOR_UPDATE_OF

 Specifies the columns in a cursor that you or your program might
 later modify with an UPDATE statement.  The column names in the FOR
 UPDATE clause must belong to a table or view named in the FROM
 clause.

 You do not have to specify the FOR UPDATE clause of the DECLARE
 CURSOR statement to later modify rows using the UPDATE statement.
 However, if you do specify FOR UPDATE and later specify columns in an
 UPDATE statement that are not in the FOR UPDATE clause, VAX SQL
 issues a warning message and proceeds with the update modifications.
 If you do not specify a FOR UPDATE clause, you can update any column
 using the UPDATE statement.  VAX SQL will not issue any messages.

 You cannot refer to read-only cursors in UPDATE or DELETE statements.
 SQL considers as read-only cursors those that:

  o  Use the DISTINCT argument to eliminate duplicate rows from the
     result table

  o  Name more than one table or view in the FROM clause

  o  Include a function in the select list

  o  Contain a GROUP BY or HAVING clause

  o  Contain an ORDER BY clause

select expr

 select-expr =

 SELECT -+------>------+-> select-list --+
         +-> ALL ------+                 |
         +-> DISTINCT -+                 |
   +------------------------------<------+
   + FROM -++-> table-name -+-+----->----+-+-+--------->----------+-+
           |+-> view-name --+ +-> alias -+ | +-> WHERE predicate -+ |
           +---------- , <-----------------+                        |
   +------------------------------<---------------------------------+
   ++------------->------------------+-+---------->----------+-->
    +-> GROUP BY -+-> column-name -+-+ +-> HAVING predicate -+
                  +------- , <-----+

DATABASE

 The DECLARE DATABASE statement is supported only for upward
 compatibility.  For information on declaring databases see the Help
 topic on DECLARE SCHEMA.

SCHEMA

 DECLARE -+------>------+-+------->----+-> SCHEMA AUTHORIZATION -+
          +-> LOCAL ----+ +-> auth-id -+                         |
          +-> GLOBAL ---+                                        |
          +-> EXTERNAL -+                                        |
 +---------------------------------------------------------------+
 +-> FOR -+--------->---------+--+--> PATHNAME ---> path-name -+-+
          +--> COMPILETIME ---+  +--> FILENAME ---> file-spec -+ |
 +---------------------------- <---------------------------------+
 +--+--------------------> -------------------------+--+
    +--> RUNTIME --+-> FILENAME -+--> file-spec --+-+  |
                   |             +--> parameter --+ |  |
                   +-> PATHNAME -+--> path-name --+-+  |
                                 +--> parameter --+    |
 +--------------------------<--------------------------+
 +--+------------------------->-----------------------+-----> ;
    +--> DBKEY SCOPE IS ---+---> ATTACH ------+-------+
                           +---> TRANSACTION -+

Additional information available:

More Information

More Information

 The DECLARE SCHEMA statement specifies the name and the source of the
 schema definitions to be accessed in a program or by interactive SQL.

 If you do not declare any schema, SQL declares the schema specified
 in the logical name SQL$DATABASE as the default schema, using the FOR
 FILENAME clause.  See the Help topic on default_schema for more
 information.

STATEMENT

 DECLARE --+-> statement-name --+-> STATEMENT ;
           +-------  , <--------+

Additional information available:

More Information

More Information

 DECLARE STATEMENT is used only in preprocessed programs that include
 dynamic SQL.  DECLARE STATEMENT documents a statement name later used
 in a PREPARE, DECLARE CURSOR, or DESCRIBE statement.  Including the
 DECLARE STATEMENT is optional.

TABLE

 DECLARE --+-> table-name -+-> TABLE --+
           +-> view-name --+           |
   +-----------------------------------+
   +-> ( -++-> declare-col-definition -++-> ) --> ;
          |+-> table-constraint -------+|
          +---------- , <---------------+

Additional information available:

More Informationcol definitiontable constraint

More Information

 The DECLARE TABLE statement is used in preprocessed programs and as
 part of SQL module procedures.  It is an alternative to SQL's
 implicit declaration of a table based on the table definition in the
 database file or data dictionary.  For a table named in a DECLARE
 TABLE statement, SQL does not check the database or dictionary to
 compare the table definition with the explicit declaration.

 The DECLARE TABLE statement documents a table definition in the
 source code of the program.  It allows program references to tables
 that are created by other modules of a program or that are created
 dynamically.  Using DECLARE TABLE can also improve precompiler or
 module processor performance because SQL does not have to retrieve
 the table definition from the database.  You can also use DECLARE
 TABLE to specify a subset of a table definition when the program
 needs to use only some of the columns in the table.

 For details on specifying column definitions and table constraints,
 see the Help topic on CREATE TABLE.

col definition

 col-definition =
 --> column-name -+-> data-type ---+++---------->-------------++->
                  +-> domain-name -+|+-> col-constraint ------+|
                                    |+-> sql-and-dtr-clause --+|
                                    +-----------<--------------+
 col-constraint =
 -+------>------------------------+-+-------------------------------+->
  +-> NOT NULL -------------------+ +-> DIAGNOSTIC constraint-name -+
  +-> NOT NULL UNIQUE ------------+
  +-> CHECK (predicate) ----------+

 The column definition specifies a data type and optional
 column-constraints and SQL and DATATRIEVE formatting support clauses
 for the column specified by the column name.

Additional information available:

sql and dtr clause

sql and dtr clause

 sql-and-dtr-clause =

 -+-> QUERY HEADER IS -+> quoted-string --+-----------------+->
  |                    +------ / <--------+                 |
  +-> EDIT STRING IS quoted-string -------------------------+
  |                                                         |
  +-> QUERY NAME FOR -+-> DTR --------+-> IS quoted-string -+
  |                   +-> DATATRIEVE -+                     |
  +-> DEFAULT VALUE FOR -+-> DTR --------+-> IS literal ----+
  |                      +-> DATATRIEVE -+                  |
  +-> NO QUERY HEADER --------------------------------------+
  +-> NO EDIT STRING ---------------------------------------+
  +-> NO QUERY NAME ----+--> FOR -+-> DTR --------+---------+
  +-> NO DEFAULT VALUE -+         +-> DATATRIEVE -+

 Optional formatting clauses allow you to modify data displays or
 query characteristics for interactive SQL users and DATATRIEVE users.

 A query header specifies a string that interactive SQL or DATATRIEVE
 displays in place of the column name when it retrieves values from a
 column.  An edit string specifies a string that controls how
 interactive SQL or DATATRIEVE formats the display of values in a
 column.

 DEFAULT VALUE and QUERY NAME are active only from DATATRIEVE.

table constraint

 table-constraint =
 -+-> UNIQUE (-+-> column-name -+-> ) -+-+
  |            +----- , <-------+      | |
  +-> CHECK (predicate) ---------------+ |
    +------------------------------------+
    +-+-------------------------------+->
      +-> DIAGNOSTIC constraint-name -+

Additional information available:

More Information

More Information

 A table-constraint is a constraint definition that applies to the
 whole table.  There are two types of table constraints, UNIQUE and
 CHECK and an optional DIAGNOSTIC constraint name.

 The UNIQUE table constraint specifies that the combination of values
 for the columns named must be unique in a row.  Columns named in the
 list must be defined with the NOT NULL column constraint.

 The CHECK table constraint specifies a predicate that column values
 inserted into the table must satisfy.  Predicates in CHECK table
 constraints can refer to any column in the table.  Column select
 expressions within the predicate can refer to other tables in the
 schema.

 The optional DIAGNOSTIC constraint-name specifies a name for a column
 or table constraint that is used in several ways:

  o  The INTEG_FAIL error message specifies the name when an INSERT,
     UDPATE, or DELETE statement violates the constraint

  o  ALTER TABLE DROP CONSTRAINT statements specify the name to drop a
     table constraint

  o  SHOW TABLE statements display the names of column and table
     constraints

TRANSACTION

 DECLARE TRANSACTION --+---------------+-> ;
                       +-> tx-options -+
                       +-> db-txns ----+

Additional information available:

More Informationtx optionsdb txns

More Information

 Specifies the characteristics for a default transaction.  A
 transaction is a group of statements whose changes can be made
 permanent or undone as a unit.  By default, SQL starts transactions
 with the characteristics READ WRITE, WAIT, and CONSISTENCY LEVEL 3,
 reserving tables as required for statements that refer to the tables.

 In contrast to the SET TRANSACTION statement, the DECLARE TRANSACTION
 statement is not executable and therefore does not start a
 transaction.  The declarations in a DECLARE TRANSACTION statement
 take effect when SQL starts an implicit transaction, that is, with
 the first executable data manipulation or data definition statement
 following the DECLARE TRANSACTION, COMMIT, or ROLLBACK statement.

 The characteristics specified in a DECLARE TRANSACTION statement
 affect all transactions (except those started by the SET TRANSACTION
 statement) until you issue another DECLARE TRANSACTION statement.
 The characteristics specified in a SET TRANSACTION statement affect
 only that transaction.

 If you end the transaction with a COMMIT statement, all changes made
 to the database by statements in the transaction are made permanent.
 If you end the transaction with a ROLLBACK statement, none of the
 changes made to the database by the statements takes effect.  If you
 then start another transaction with a data manipulation or data
 definition statement, that transaction also has the characteristics
 originally specified in the DECLARE TRANSACTION statement.

 In interactive SQL, you can change transaction characteristics with
 another DECLARE or SET TRANSACTION statement, but only if a
 transaction is not currently active.  In programs, DECLARE
 TRANSACTION can apply only one set of transaction characteristics to
 a precompiled source file or compiled SQL module.

tx options

 tx-options =

  -+---> BATCH UPDATE ----------->------------------------+--->
   +-+------------------+-+------>-----+--+               |
     +-> READ ONLY    --+ +-> WAIT ----+  |               |
     +-> READ WRITE   --+ +-> NOWAIT --+  |               |
     +------------------------------------+               |
     +-+-------------------->---------+---+               |
       +-> CONSISTENCY LEVEL -+-> 2 --+   |               |
                              +-> 3 --+   |               |
     +------------------------------------+               |
     +-+----------------->-----------------------+-+      |
       +-> EVALUATING -+-> evaluating-clause --+-+ |      |
                       +-------- , <-----------+   |      |
     +---------------------------------------------+      |
     +-+----------------->-----------------------+----->--+
       +-> RESERVING --+-> reserving-clause ---+-+
                       +-------- , <-----------+

Additional information available:

More Information

More Information

 The transaction options include:

  o  BATCH UPDATE to reduce overhead in large load operations by not
     writing to any journal files.  No rollback is possible for batch
     update transactions.

  o  READ ONLY or READ WRITE specifies whether you want to use a
     snapshot of the database for only reading records or use a
     locking mechanism of SQL to get consistency in data retrieval and
     update for reading and writing records.

  o  WAIT or NOWAIT determines what your transaction does when it
     encounters a locked record.  WAIT waits for other transactions to
     complete and then proceds.  NOWAIT returns an error message when
     it encounters a locked record.

  o  See More_Options for additional transaction options.

Additional information available:

More Options

More Options
  o  CONSISTENCY LEVEL determines the extent to which the database
     protects the consistency of your data.  Relationships between
     data items may not be preserved by LEVEL 2 transactions since
     data items can be updated by another transaction before the LEVEL
     2 transaction finishes.  LEVEL 3 transactions mean the database
     system guarantees that data you read will not be changed by
     another user before you issue a COMMIT statement.

  o  EVALUATING determines the point at which the named constraint(s)
     are evaluated.  If you specify VERB TIME, they are evaluated when
     the data manipulation statement is issued.  If you specify COMMIT
     TIME, they are evaluated when the COMMIT statement executes.  For
     READ ONLY transactions, this clause is allowed but meaningless.

  o  RESERVING specifies the list of tables to be locked during the
     transaction.

db txns

 db-txns =
  -+--------------------------------------------------------------+->
   ++-> ON -+-> auth-id -+-> USING --> (-+-> tx-options --+-> ) -++
    |       +---- , <----+               +-> DEFAULTS ----+      |
    +-------------------------- AND <----------------------------+

Additional information available:

More Information

More Information

 Specifies the options for accessing other schemas when using the
 declare transaction statement.  These options include the
 authorization identifier for the schema and whether you want to state
 the transaction options individually or accept the default
 transaction options of READ WRITE WAIT plus the consistency option
 appropriate for the database system you are using.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026