ISO Working Draft Persistent SQL Modules «Addendum 2 to SQL-92» February 1993 (ISO) Persistent Module Addendum Working Draft-February 18, 1993 Digital Equipment Corporation Maynard, Massachusetts Contents Page Foreword......................................................... v Introduction.....................................................vii 1 Scope ........................................................ 1 2 Normative references ......................................... 1 3 Definitions, notations, and conventions ...................... 1 3.1 Definitions ................................................ 1 3.2 Notations .................................................. 1 3.3 Conventions ................................................ 2 4 Concepts ..................................................... 3 4.1 Modules .................................................... 3 4.2 Routines ................................................... 4 4.3 Persistence ................................................ 5 4.4 Statements ................................................. 5 4.5 Exception handling ......................................... 5 5 Persistent SQL modules ....................................... 7 5.1 Introduction ............................................... 7 5.2 ................................................... 8 5.3 ..................................................11 5.4 Data type correspondences ..................................24 6 Persistent SQL module maintenance ............................31 6.1 Introduction ...............................................31 6.2 ........................................32 6.3 ....................................34 7 Persistent SQL module use ....................................35 7.1 Introduction ...............................................35 7.2 ...........................................36 7.3 .........................................37 Annex A Place Holder...........................................39 Index ii (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 TABLES Table Page 1 Data type correspondences for Ada ..........................24 2 Data type correspondences for C ............................25 3 Data type correspondences for COBOL ........................26 4 Data type correspondences for Fortran ......................27 5 Data type correspondences for MUMPS ........................28 6 Data type correspondences for Pascal .......................29 7 Data type correspondences for PL/I .........................30 Table of Contents iii YOK-010 and X3H2-93-082 Foreword Foreword v YOK-010 and X3H2-93-082 Introduction The organization of this International Standard is as follows: 1) Introduction vii YOK-010 and X3H2-93-082 Information Technology - Database Languages - SQL Addendum 2 - Persistent SQL Modules 1 Scope 2 Normative references The following standards contain provisions that, through reference in this text, constitute provisions of this National Standard. At the time of publication, the editions indicated were valid. All standards are subject to revision, and parties to agreements based on this National Standard are encouraged to investigate the possi- bility of applying the most recent editions of the standards listed below. Members of IEC and ISO maintain registers of currently valid International Standards. - ISO/IEC 9075:1992, Information Technology - Database Languages - SQL. 3 Definitions, notations, and conventions 3.1 Definitions 3.2 Notations Definitions, notations, and conventions 1 YOK-010 and X3H2-93-082 3.3 Conventions 3.3 Conventions 2 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 4 Concepts 4.1 Modules A is an object specified in the module language. A is either a persistent or an SQL-session . s are created and destroyed by the and , respectively. They may also be created and destroyed by implementation-defined mechanisms (which can include the granting and revoking of module privileges). A consists of a , a , a with either or both of a and a , an optional that identifies the character reper- toire used for expressing the names of schema objects used in the , zero or more s, zero or more cursors specified by s, and one or more s. All s contained in the are expressed in either or the character repertoire indicated by unless they are specified with "". A compilation unit is a segment of executable code, possibly con- sisting of one or more subprograms. A is associated with a compilation unit during its execution. A single may be associated with multiple compilation units and multiple s may be associated with a single compilation unit. The manner in which this association is specified, including the possible re- quirement for execution of some implementation-defined statement, is implementation-defined. Whether a compilation unit may invoke or transfer control to other compilation units, written in the same or a different programming language, is implementation-defined. A is described by a module descriptor. A module descriptor contains: o the name of the , o the descriptor of the character set used for representing the , o the schema name used for implicit qualification of unqualified names in the o the , o the of the , Concepts 3 YOK-010 and X3H2-93-082 4.1 Modules o the text of the 4.2 Routines A consists of a , a sequence of , and a . A is either an (which could be a ), or an that identifies a routine body that is provided externally as a program written in a standard programming language. A is either a component of a or an object in a . The of a specifies whether it will be invoked from within SQL, by s or s, or by a compilation unit of a specified standard programming language, by means of "call" statements or function invocations. An invocation of a specifies the of the and supplies a sequence of argument values corresponding in number and in to the s of the . Such invocation causes the or external routine body to be executed. A is either a function, which returns a value, or a pro- cedure, which does not return a value. Function invocations can be specified in s and s in both schemas and modules. Procedure invocations are specified in s or in compilation units. Different s can have the same . This is referred to an overloading the . Overloading is al- lowed only for s that are called from SQL. The parameter declaration lists of such routines must be sufficiently different to distinguish which of the routines is to be invoked for a given . A routine is described by a routine descriptor. A routine descrip- tor contains: - The ; - The name, data type, and position of each of the routine's pa- rameters; - If the routine is a function, then the data type returned by the function; and 4 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 4.2 Routines - If the routine is defined within an abstract data type defini- tion or a table definition, then an indicator of its encapsula- tion level. 4.3 Persistence 4.4 Statements 4.5 Exception handling Concepts 5 YOK-010 and X3H2-93-082 6 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 5 Persistent SQL modules 5.1 Introduction Persistent SQL modules 7 YOK-010 and X3H2-93-082 5.2 5.2 Function Define a module. Format ::= [ END MODULE ] ::= MODULE [ ] ::= [ ] [ ... ] ... ::= NAMES ARE ::= SCHEMA | AUTHORIZATION | SCHEMA AUTHORIZATION ::= ::= | | | | | | Syntax Rules 1) If a does not specify a , then an implementation-dependent is implicit. 2) The shall be different from the of any other in the same environment. Note: An SQL-environment may have multiple s that are unnamed. 8 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 5.2 3) If the of the containing specifies ADA, then a shall be specified, and that shall be a valid Ada library unit name. 4) If SCHEMA is not specified, then a equal to is implicit. 5) If a is not specified, then a that specifies an implementation-defined character set that contains at least every character that is in is implicit. 6) If the explicit or implicit does not specify a , then an implementation-defined is implicit. 7) The implicit or explicit is the implicit for all unqualified s in the . 8) A or shall precede in the text of the any that references the of the or . 9) An shall precede in the text of the module any that references the of the . 10)For every in a , there shall be exactly one in that that contains an that specifies the declared in the . Note: See the Syntax Rules of Subclause 13.1, "". Access Rules None. General Rules 1) In the SQL-environment, the containing has the name given by the explicit or implicit . 2) If the SQL-agent performs calls of s from more than one Ada task, then the results are implementation-dependent. 3) Case: a) If a is specified, then it is the current for privilege determination for the execution of each in the . Persistent SQL modules 9 YOK-010 and X3H2-93-082 5.2 b) Otherwise, the current for privi- lege determination for the execution of each in the is the SQL-session . 4) After the last time that an SQL-agent performs a call of a : a) A or a is effec- tively executed. If an unrecoverable error has occurred, or if the SQL-agent terminated unexpectedly, or if any con- straint is not satisfied, then a is performed. Otherwise, the choice of which of these SQL- statements to perform is implementation-dependent. The deter- mination of whether an SQL-agent has terminated unexpectedly is implementation-dependent. b) Let D be the of any system descriptor area that is currently allocated within an SQL-session associated with the SQL-agent. A that specifies DEALLOCATE DESCRIPTOR D is effectively executed. c) All SQL-sessions associated with the SQL-agent are termi- nated. Leveling Rules 1) The following restrictions apply for Full SQL: None. 2) The following restrictions apply for Intermediate SQL in addi- tion to any Full SQL restrictions: a) A shall not contain a . 3) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: a) A shall not be speci- fied. b) A shall be associated with an SQL-agent during its execution. An SQL-agent shall be associated with at most one . c) A shall not be a . d) A shall specify AUTHORIZATION and shall not specify SCHEMA. 10 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 5.3 5.3 Function Define a routine. Format ::= [CREATE] [] [ ] ::= PROCEDURE | [ ] FUNCTION ::= CONSTRUCTOR | ACTOR | DESTRUCTOR ::= | ::= [ [{ }... ] ] ::= [ ... ] ::= | ::= | ::= SQLSTATE | SQLCODE ::= [ ] ::= IN | OUT | INOUT Persistent SQL modules 11 YOK-010 and X3H2-93-082 5.3 ::= RETURNS [ ] ::= CAST FROM ::= ::= ::= | ::= ::= EXTERNAL [ NAME ] [ ] ::= VARIANT | NOT VARIANT ::= Syntax Rules 1) A shall contain a if and only if the specifies FUNCTION. 2) A shall specify CREATE if and only if the is contained in a . 3) A that specifies PROCEDURE is called a procedure. A that specifies FUNCTION is called a function. A (procedure or function) whose whose specifies SQL is called an SQL-invoked (proce- dure or function). A (procedure or function) whose does not specify SQL is called an externally-invoked (procedure or function). A (procedure or function) that specifies an is called an SQL (procedure or function). A (procedure or function) that specifies an is called an external (procedure or function). 4) Case: a) If a is contained in a , then it shall not specify a . A that is the same as the of the is implicit. 12 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 5.3 b) If a is not contained in a , then if a is not specified, then LANGUAGE SQL is implicit. 5) If the of a specifies a , then: a) The implicit or explicit shall spec- ify LANGUAGE SQL. b) The shall be an SQL routine. c) The shall be contained in an ADTB. Case: i) If ADTB is immediately contained in an ADT, then let DT be the immediately contained in ADT. ii) If ADTB is immediately contained in a TTD, then let DT be ":GEN_TYPE". d) If the is CONSTRUCTOR, then: i) The shall be DT. ii) At least one shall specify DT. iii) The shall contain exactly one , and the operand of that statement shall be a parameter whose data type is DT. e) If the is DESTRUCTOR, then: i) Exactly one shall specify DT. ii) The shall contain exactly one , and the operand of that statement shall be the parameter whose data type is DT. 6) If a is an SQL-invoked routine, then: a) The shall be a . b) Case: i) If the is contained in a , then let the subject be the of that . ii) If the is contained in a that is not contained in a , then let the subject be the implicit or explicit of the of that . Persistent SQL modules 13 YOK-010 and X3H2-93-082 5.3 c) If the contains a , then that shall be the same as the subject . d) If the does not contain a , then the subject is implicit. e) The shall not contain a . f) The routine family for a given con- sists of all s whose is equal to that . The routine family for a whose contains N is all members of the routine family of the of the whose s contain N . g) All s in the routine family for a that is a procedure shall be procedures. All s in the routine family of a that is a function shall be functions. If the i-th of a specifies an input (output) parameter, then the i-th of all s in the routine family of that shall specify input (output) parameters. h) For each specified in a or that is an abstract data type, let ADTD be the that defined the ab- stract data type. Either the shall be contained in ADTD or the shall be contained in the of ADTD. 7) If a is an externally-invoked routine, then: a) The shall be an . b) If the is contained in a , then the of the of the shall be dif- ferent from the of the of any other in the containing . c) If the is contained in a , then the of the of the routine shall be differ- ent from the of the of any other in that . d) The shall contain at least one , at most one that specifies SQLCODE, and at most one that specifies SQLSTATE. A parameter that corresponds with SQLCODE is re- ferred to as an SQLCODE parameter. A parameter than corre- sponds with SQLSTATE is referred to as an SQLSTATE parameter. The SQLCODE and SQLSTATE parameters are referred to as status parameters. 14 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 5.3 Note: SQLSTATE is the preferred status parameter. The SQLCODE status parameter is a deprecated future that is supported for compatibility with earlier versions of this International Standard. See Appendix D, "Deprecated features". e) No shall specify a that is an object identifier type containing an that implicitly or explicitly specifies WITH OID NOT VISIBLE. f) When the specifies ADA, C, COBOL, FORTRAN, MUMPS, PASCAL, or PLI, then let the operative data type correspondences table be Table 1, "Data type corre- spondences for Ada", Table 2, "Data type correspondences for C", Table 3, "Data type correspondences for COBOL", Table 4, "Data type correspondences for Fortran", Table 5, "Data type correspondences for MUMPS", Table 6, "Data type correspon- dences for Pascal", or Table 7, "Data type correspondences for PL/I", respectively. Refer to the two columns of the operative data type correspondences table as the "SQL data type" column and the "host data type column". g) If the is a function, then let the externally re- turned data type be the specified by the . h) Any in a or externally returned data type (if any) shall specify a data type listed in the SQL data type column for which the corresponding row in the host data type column is not "none". If the in a or externally returned data type (if any) specifies the data type listed in the i-th row of the SQL data type column, then the type of the i-th parameter or the externally returned data type shall be the type listed in the i-th row of the host data type column. i) If the specifies ADA, then: i) The s of the are identified by the as if they were declared immediately within an Ada library unit package specification that has a name identical to the of the containing . ii) The Ada base type of any parameter shall be an Ada data type declared in an Ada package named SQL_STANDARD of the following form: package SQL_STANDARD is package CHARACTER_SET renames csp; subtype CHARACTER_TYPE is CHARACTER_SET.cst; type CHAR is array (POSITIVE range <>) of CHARACTER_ TYPE; type BIT is array (NATURAL range <>) of BOOLEAN; type SMALLINT is range bs .. ts; Persistent SQL modules 15 YOK-010 and X3H2-93-082 5.3 type INT is range bi .. ti; type REAL is digits dr; type DOUBLE_PRECISION is digits dd; subtype INDICATOR_TYPE is t; type SQLCODE_TYPE is range bsc .. tsc; subtype SQL_ERROR is SQLCODE_TYPE range SQL_ TYPE'FIRST .. -1; subtype NOT_FOUND is SQLCODE_TYPE range 100 .. 100; type SQLSTATE_TYPE is new CHAR (1 .. 5); package SQLSTATE_CODES is AMBIGUOUS_CURSOR_NAME_NO_SUBCLASS: constant SQLSTATE_TYPE :="3C000"; CASE_NOT_FOUND_FOR_CASE_STATEMENT: constant SQLSTATE_TYPE :="20000"; CARDINALITY_VIOLATION_NO_SUBCLASS: constant SQLSTATE_TYPE :="21000"; CONNECTION_EXCEPTION_NO_SUBCLASS: constant SQLSTATE_TYPE :="08000"; CONNECTION_EXCEPTION_CONNECTION_DOES_NOT_ EXIST: constant SQLSTATE_TYPE :="08003"; CONNECTION_EXCEPTION_CONNECTION_FAILURE: constant SQLSTATE_TYPE :="08006"; CONNECTION_EXCEPTION_CONNECTION_NAME_IN_USE: constant SQLSTATE_TYPE :="08002"; CONNECTION_EXCEPTION_SQLCLIENT_UNABLE_TO_ ESTABLISH_SQLCONNECTION: constant SQLSTATE_TYPE :="08001"; CONNECTION_EXCEPTION_SQLSERVER_REJECTED_ ESTABLISHMENT_OF_SQLCONNECTION: constant SQLSTATE_TYPE :="08004"; CONNECTION_EXCEPTION_UNKNOWN_STATEMENT_ COMPLETION: constant SQLSTATE_TYPE :="08005"; CURSOR_OPERATION_CONFLICT_NO_SUBCLASS: constant SQLSTATE_TYPE :="09000"; DATA_EXCEPTION_NO_SUBCLASS: constant SQLSTATE_TYPE :="22000"; DATA_EXCEPTION_CHARACTER_NOT_IN_REPERTOIRE: constant SQLSTATE_TYPE :="22021"; DATA_EXCEPTION_DATETIME_FIELD_OVERFLOW: constant SQLSTATE_TYPE :="22008"; DATA_EXCEPTION_DIVISION_BY_ZERO: constant SQLSTATE_TYPE :="22012"; DATA_EXCEPTION_ERROR_IN_ASSIGNMENT: constant SQLSTATE_TYPE :="22005"; DATA_EXCEPTION_INDICATOR_OVERFLOW: constant SQLSTATE_TYPE :="22022"; DATA_EXCEPTION_INTERVAL_FIELD_OVERFLOW: constant SQLSTATE_TYPE :="22015"; DATA_EXCEPTION_INVALID_CHARACTER_VALUE_FOR_ CAST: constant SQLSTATE_TYPE :="22018"; 16 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 5.3 DATA_EXCEPTION_INVALID_DATETIME_FORMAT: constant SQLSTATE_TYPE :="22007"; DATA_EXCEPTION_INVALID_ESCAPE_CHARACTER: constant SQLSTATE_TYPE :="22019"; DATA_EXCEPTION_INVALID_ESCAPE_SEQUENCE: constant SQLSTATE_TYPE :="22025"; DATA_EXCEPTION_INVALID_FETCH_SEQUENCE: constant SQLSTATE_TYPE :="22006"; DATA_EXCEPTION_INVALID_PARAMETER_VALUE: constant SQLSTATE_TYPE :="22023"; DATA_EXCEPTION_INVALID_TIME_ZONE_DISPLACEMENT_ VALUE: constant SQLSTATE_TYPE :="22009"; DATA_EXCEPTION_NULL_VALUE_NO_INDICATOR_ PARAMETER: constant SQLSTATE_TYPE :="22002"; DATA_EXCEPTION_NUMERIC_VALUE_OUT_OF_RANGE: constant SQLSTATE_TYPE :="22003"; DATA_EXCEPTION_STRING_DATA_LENGTH_MISMATCH: constant SQLSTATE_TYPE :="22026"; DATA_EXCEPTION_STRING_DATA_RIGHT_TRUNCATION: constant SQLSTATE_TYPE :="22001"; DATA_EXCEPTION_SUBSTRING_ERROR: constant SQLSTATE_TYPE :="22011"; DATA_EXCEPTION_TRIM_ERROR: constant SQLSTATE_TYPE :="22027"; DATA_EXCEPTION_UNTERMINATED_C_STRING: constant SQLSTATE_TYPE :="22024"; DEPENDENT_PRIVILEGE_DESCRIPTORS_STILL_EXIST_NO_ SUBCLASS: constant SQLSTATE_TYPE :="2B000"; DYNAMIC_SQL_ERROR_NO_SUBCLASS: constant SQLSTATE_TYPE :="07000"; DYNAMIC_SQL_ERROR_CURSOR_SPECIFICATION_CANNOT_ BE_EXECUTED: constant SQLSTATE_TYPE :="07003"; DYNAMIC_SQL_ERROR_INVALID_DESCRIPTOR_COUNT: constant SQLSTATE_TYPE :="07008"; DYNAMIC_SQL_ERROR_INVALID_DESCRIPTOR_INDEX: constant SQLSTATE_TYPE :="07009"; DYNAMIC_SQL_ERROR_PREPARED_STATEMENT_NOT_A_ CURSOR_SPECIFICATION: constant SQLSTATE_TYPE :="07005"; DYNAMIC_SQL_ERROR_RESTRICTED_DATA_TYPE_ ATTRIBUTE_VIOLATION: constant SQLSTATE_TYPE :="07006"; DYNAMIC_SQL_ERROR_USING_CLAUSE_DOES_NOT_MATCH_ DYNAMIC_PARAMETER_SPEC: constant SQLSTATE_TYPE :="07001"; DYNAMIC_SQL_ERROR_USING_CLAUSE_DOES_NOT_MATCH_ TARGET_SPEC: constant SQLSTATE_TYPE :="07002"; Persistent SQL modules 17 YOK-010 and X3H2-93-082 5.3 DYNAMIC_SQL_ERROR_USING_CLAUSE_REQUIRED_FOR_ DYNAMIC_PARAMETERS: constant SQLSTATE_TYPE :="07004"; DYNAMIC_SQL_ERROR_USING_CLAUSE_REQUIRED_FOR_ RESULT_FIELDS: constant SQLSTATE_TYPE :="07007"; FEATURE_NOT_SUPPORTED_NO_SUBCLASS: constant SQLSTATE_TYPE :="0A000"; FEATURE_NOT_SUPPORTED_MULTIPLE_ENVIRONMENT_ TRANSACTIONS: constant SQLSTATE_TYPE :="0A001"; INTEGRITY_CONSTRAINT_VIOLATION_NO_SUBCLASS: constant SQLSTATE_TYPE :="23000"; INVALID_AUTHORIZATION_SPECIFICATION_NO_ SUBCLASS: constant SQLSTATE_TYPE :="28000"; INVALID_CATALOG_NAME_NO_SUBCLASS: constant SQLSTATE_TYPE :="3D000"; INVALID_CHARACTER_SET_NAME_NO_SUBCLASS: constant SQLSTATE_TYPE :="2C000"; INVALID_CONDITION_NUMBER_NO_SUBCLASS: constant SQLSTATE_TYPE :="35000"; INVALID_CONNECTION_NAME_NO_SUBCLASS: constant SQLSTATE_TYPE :="2E000"; INVALID_CURSOR_NAME_NO_SUBCLASS: constant SQLSTATE_TYPE :="34000"; INVALID_CURSOR_STATE_NO_SUBCLASS: constant SQLSTATE_TYPE :="24000"; INVALID_SCHEMA_NAME_NO_SUBCLASS: constant SQLSTATE_TYPE :="3F000"; INVALID_SQL_DESCRIPTOR_NAME_NO_SUBCLASS: constant SQLSTATE_TYPE :="33000"; INVALID_SQL_STATEMENT_NAME_NO_SUBCLASS: constant SQLSTATE_TYPE :="26000"; INVALID_TRANSACTION_STATE_NO_SUBCLASS: constant SQLSTATE_TYPE :="25000"; INVALID_TRANSACTION_TERMINATION_NO_SUBCLASS: constant SQLSTATE_TYPE :="2D000"; NO_DATA_NO_SUBCLASS: constant SQLSTATE_TYPE :="02000"; REMOTE_DATABASE_ACCESS_NO_SUBCLASS: constant SQLSTATE_TYPE :="HZ000"; SUCCESSFUL_COMPLETION_NO_SUBCLASS: constant SQLSTATE_TYPE :="00000"; SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION_NO_ SUBCLASS: constant SQLSTATE_TYPE :="42000"; SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION_IN_ DIRECT_STATEMENT_NO_SUBCLASS: constant SQLSTATE_TYPE :="2A000"; SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION_IN_ DYNAMIC_STATEMENT_NO_SUBCLASS: constant SQLSTATE_TYPE :="37000"; 18 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 5.3 TRANSACTION_ROLLBACK_NO_SUBCLASS: constant SQLSTATE_TYPE :="40000"; TRANSACTION_ROLLBACK_INTEGRITY_CONSTRAINT_ VIOLATION: constant SQLSTATE_TYPE :="40002"; TRANSACTION_ROLLBACK_SERIALIZATION_FAILURE: constant SQLSTATE_TYPE :="40001"; TRIGGERED_DATA_CHANGE_VIOLATION_NO_SUBCLASS: constant SQLSTATE_TYPE :="27000"; WARNING_NO_SUBCLASS: constant SQLSTATE_TYPE :="01000"; WARNING_CONSTRAINT_CURSOR_OPERATION_CONFLICT: constant SQLSTATE_TYPE :="01001"; WARNING_DISCONNECT_ERROR: constant SQLSTATE_TYPE :="01002"; WARNING_IMPLICIT_ZERO_BIT_PADDING: constant SQLSTATE_TYPE :="01008"; WARNING_INSUFFICIENT_ITEM_DESCRIPTOR_AREAS: constant SQLSTATE_TYPE :="01005"; WARNING_NULL_VALUE_ELIMINATED_IN_SET_FUNCTION: constant SQLSTATE_TYPE :="01003"; WARNING_PRIVILEGE_NOT_GRANTED: constant SQLSTATE_TYPE :="01007"; WARNING_PRIVILEGE_NOT_REVOKED: constant SQLSTATE_TYPE :="01006"; WARNING_SEARCH_CONDITION_TOO_LONG_FOR_ INFORMATION_SCHEMA: constant SQLSTATE_TYPE :="01009"; WARNING_STRING_DATA_RIGHT_TRUNCATION_WARNING: constant SQLSTATE_TYPE :="01004"; WARNING_QUERY_EXPRESSION_TOO_LONG_FOR_ INFORMATION_SCHEMA: constant SQLSTATE_TYPE :="0100A"; WITH_CHECK_OPTION_VIOLATION_NO_SUBCLASS: constant SQLSTATE_TYPE :="44000"; end SQLSTATE_CODES; end SQL_STANDARD; where csp is an implementation-defined package and cst is an implementation-defined character type such that within the scope of an Ada use clause for SQL_STANDARD.CHARACTER_ SET, string literals can be of type SQL_STANDARD.CHAR. bs, ts, bi, ti, dr, dd, bsc, and tsc are implementation-defined integer values. t is INT or SMALLINT, corresponding with an implementation-defined of indicator parameters. SQL_STANDARD shall contain no other declarations. 8) If a is an SQL routine, then: a) Each in the shall be an . Persistent SQL modules 19 YOK-010 and X3H2-93-082 5.3 b) The of each in a shall be different from the of any other in that . c) Whether a is for an input parameter, an output parameter, or both is determined as follows: Case: i) A is an output parameter. ii) For every that is not a , Case: 1) If the of a parameter is contained in a or a that is contained in , but it is not contained in a or a that is contained in , then the parameter is an input parameter. 2) If the of a parameter is contained in a or a that is contained in , but it is not contained in a or a that is contained in , then the parameter is an output parameter. 3) If the of a parameter is contained in a or a that is contained in and it is contained in a or a that is contained in , then the parameter is both an input parameter and an output parameter. 4) Otherwise, the parameter is neither an input parameter nor an output parameter. d) Any contained in the of a shall be specified in an of the . e) If the contains an that is identical to a in the , then the shall contain a . f) The shall not specify a . g) An shall contain a if and only if the is a function. 20 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 5.3 9) If a is an external routine, then: a) Each in the shall be an . b) The implicit or explicit shall spec- ify SQL. c) If an is not specified, then the of the is implicit. d) If a is not specified, then VARIANT is implicit. e) The shall not specify SQL. f) If a is specified, then let R be some value of the specified in the and let RT be the . The following shall be valid according to the Syntax Rules of Subclause 6.10, "": CAST ( R AS RT ) g) If is not specified, then IN is implicit. h) If is IN or INOUT, then the parameter is an input parameter. If the is OUT or INOUT, then the parameter is an output parameter. i) Let N be the number of s. Let PN be the number of s that are predefined types. Let UN be the number of actual base types of the operand data types that are abstract data types. If the is an abstract data type, then let RN be the number of actual base types of that data type; otherwise, let RN be 1. Let the effective external parameter type list be a list of PN+UN+RN+N+2 data types, as follows: i) Effective parameter type list entries 1 to PN + UN are N groups of entries. For i ranging from 1 to N, Case: 1) If the i-th is a predefined type, then the i-th group of effective parameter type list entries consists of the i-th . 2) If the i-th is some abstract data type ADTi, then the i-th group of effective parameter type list entries consists of the of the and the actual base types of the of ADTi. ii) Effective parameter type list entries (PN + UN) + 1 to (PN + UN)+RN are as follows: Persistent SQL modules 21 YOK-010 and X3H2-93-082 5.3 Case: 1) If the is a predefined type, then effective external parameter list entry (PN + UN) + 1 is the OUT and the . 2) If the is some abstract data type ADTr, then effective external parameter list entries (PN+UN)+1 to (PN+UN)+RN consist of the OUT and the actual base types of the of ADTr. iii) Effective external parameter list entries (PN+UN+RN)+1 to (PN+UN+RN)+N+1 are N+1 occurrences of an implementor- defined that is an exact numeric type with scale 0. The for the i-th such effective external parameter is the same as that of the i-RN-PN-UN-th effective external parameter. iv) Effective parameter type list entry (PN + UN + RN + N + 1) + is a that is character string of length 3 and character set SQL_TEXT with OUT. j) Depending on whether the specifies ADA, C, COBOL, FORTRAN, MUMPS, PASCAL, or PLI, let the op- erative data type correspondences table be Table 1, "Data type correspondences for Ada", Table 2, "Data type corre- spondences for C", Table 3, "Data type correspondences for COBOL", Table 4, "Data type correspondences for Fortran", Table 5, "Data type correspondences for MUMPS", Table 6, "Data type correspondences for Pascal", or Table 7, "Data type correspondences for PL/I", respectively. Refer to the two columns of the operative data type correspondences ta- ble as the "SQL data type" column and the "host data type column". k) If the is a function, then if the con- tains a , let the externally returned data type be the contained in that ; other- wise, let the externally returned data type be the contained in the . l) Any in a or externally returned data type (if any) shall specify a data type listed in the SQL data type column for which the corresponding row in the host data type column is not "none". If the in a or externally returned data type (if any) specifies the data type listed in the i-th row of the SQL data type column, then the type of the i-th parameter or the externally returned data type shall be the type listed in the i-th row of the host data type column. 22 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 5.3 Access Rules 1) If an external routine is contained in a , then the of the current SQL-session shall be equal to the that owns the schema identified by the implicit or explicit of the . General Rules 1) If the is an external routine, then a privilege de- scriptor is created that defines the EXTERNAL PRIVILEGES privi- lege on the to the of the schema or in which the appears. This privi- lege is grantable. The grantor for the privilege descriptor is set to the special grantor value "_SYSTEM". 2) Case: a) If a is an SQL-invoked routine, then the rules for invocation of the are specified in (routine_ invocation\FULL). b) If a is an externally-invoked routine, then the rules for invocation of the are specified in (external_invocation\FULL). Leveling Rules 1) The following restrictions apply for Full SQL: a) A shall be a routine, shall be contained in a , and shall not contain a . 2) The following restrictions apply for Intermediate SQL in addi- tion to any Full SQL restrictions: None. 3) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Persistent SQL modules 23 YOK-010 and X3H2-93-082 5.4 Data type correspondences 5.4 Data type correspondences Function Specify the data type correspondences for SQL data types and host language types. Note: These tables are referenced in S>0, then a PICTURE with an 'S' followed by P-S '9's fol- lowed by a 'V' followed by S '9's. cIf S=0, then a PICTURE with an 'S' followed by P '9's option- ally followed by a 'V'. | [3]The length Y of the character data type corresponding with | | an SQL object ADT is the implementor-defined length of an object | | identifier. | |__________________________________________________________________| | | 26 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 5.4 Data type correspondences ___________Table_4-Data_type_correspondences_for_Fortran___________ _SQL_Data_Type__________Fortran_Data_Type__________________________ | SQLSTATE | CHARACTER, with length 5 | | | | | SQLCODE | INTEGER | | | | | CHARACTER(L) | CHARACTER, with length L | | | | | CHARACTER VARYING(L) | None | | | | | BIT(L) | CHARACTER, with length X[1] | | | | | BIT VARYING(L) | None | | | | | BOOLEAN | LOGICAL | | | | | SMALLINT | None | | | | | INTEGER | INTEGER | | | | | DECIMAL(P,S) | None | | | | | NUMERIC(P,S) | None | | | | | REAL | REAL | | | | | DOUBLE PRECISION | DOUBLE PRECISION | | | | | FLOAT(P) | None | | | | |_object_ADT___________|_CHARACTER,_with_length_Y[2]_______________| | | | | [1]The length X of th| character data type corresponding with | SQL data type BIT(L) is the smallest integer not less than the quotient of the division L/B, where B is the implementation- defined number of bits contained in character of the host lan- guage. | | | [2]The length Y of the character data type corresponding with | | an SQL object ADT is the implementor-defined length of an object | | identifier. | |__________________________________________________________________| | | | | | | Persistent SQL modules 27 YOK-010 and X3H2-93-082 5.4 Data type correspondences ____________Table_5-Data_type_correspondences_for_MUMPS____________ _SQL_Data_Type__________MUMPS_Data_Type____________________________ | SQLSTATE | character, with maximum length at least 5 | | | | | SQLCODE | None | | | | | CHARACTER(L) | None | | | | | CHARACTER VARYING | character with maximum length L | (L) | BIT(L) | None | | | | | BIT VARYING(L) | None | | | | | BOOLEAN | None | | | | | SMALLINT | None | | | | | INTEGER | character | | | | | DECIMAL(P,S) | character | | | | | NUMERIC(P,S) | character | | | | | REAL | character | | | | | DOUBLE PRECISION | None | | | | | FLOAT(P) | None | | | | |_object_ADT___________|_CHARACTER,_with_length_X[1]_______________| | | | | [1]The length X of th| character data type corresponding with | an SQL object ADT is the implementor-defined length of an object identifier. |__________________________________________________________________| | | | | | | 28 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 5.4 Data type correspondences ____________Table_6-Data_type_correspondences_for_Pascal___________ _SQL_Data_Type__________Pascal_Data_Type___________________________ | SQLSTATE | PACKED ARRAY[1..5] OF CHAR | | | | | SQLCODE | INTEGER | | | | | CHARACTER(1) | CHAR | | | | | CHARACTER(L), L>1 | PACKED ARRAY[1..L] OF CHAR | | | | | CHARACTER VARYING(L) | None | | | | | BIT(L), 1 L B[1] | CHAR | | | | | BIT(L), B[1] < L | PACKED ARRAY[LB[1]] OF CHAR | | | | | BIT VARYING(L) | None | | | | | BOOLEAN | BOOLEAN | | | | | SMALLINT | None | | | | | INTEGER | INTEGER | | | | | DECIMAL(P,S) | None | | | | | NUMERIC(P,S) | None | | | | | REAL | REAL | | | | | DOUBLE PRECISION | None | | | | | FLOAT(P) | None | | | | |_object_ADT___________|_CHAR,_with_length_X[2]____________________| | | | | [1]The length LB of t|e character data type corresponding with | SQL data type BIT(L) is the smallest integer not less than the quotient of the division L/B, where B is the implementation- defined number of bits contained in a character of the host language. | | | [2]The length X of the character data type corresponding with | | an SQL object ADT is the implementor-defined length of an object | | identifier. | |__________________________________________________________________| | | | | | | Persistent SQL modules 29 YOK-010 and X3H2-93-082 5.4 Data type correspondences _____________Table_7-Data_type_correspondences_for_PL/I____________ _SQL_Data_Type__________PL/I_Data_Type_____________________________ | SQLSTATE | CHARACTER(5) | | | | | SQLCODE | FIXED BINARY(PP), where PP is an | implementation-defined precision at least 15. | CHARACTER(L) | CHARACTER(L) | | | | | CHARACTER VARYING(L) | CHARACTER VARYING(L) | | | | | BIT(L) | BIT(L) | | | | | BIT VARYING(L) | BIT VARYING (L) | | | | | BOOLEAN | BIT(1) | | | | | SMALLINT | FIXED BINARY(SPI), where SPI is implementa|ion- defined | INTEGER | FIXED BINARY(PI), where PI is implementati|n- | | defined | | | | | DECIMAL(P,S) | FIXED REAL DECIMAL(P,S) | | | | | NUMERIC(P,S) | None | | | | | REAL | None | | | | | DOUBLE PRECISION | None | | | | | FLOAT(P) | FLOAT(P) | | | | |_object_ADT___________|_CHARACTER,_with_length_X[1]_______________| | | | | [1]The length X of th| character data type corresponding with | an SQL object ADT is the implementor-defined length of an object identifier. |__________________________________________________________________| | | | | | | 30 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 6 Persistent SQL module maintenance 6.1 Introduction Persistent SQL module maintenance 31 YOK-010 and X3H2-93-082 6.2 6.2 Function Define a module. Format ::= CREATE MODULE END MODULE Syntax Rules 1) Case: a) If a is contained in a , and if the contains a , then that shall be the same as the spec- ified or implicit of the containing . b) If a is contained in a other than in a , and if the contains a , then that shall be the same as the specified or implicit of the containing . 2) The of shall be different from the of any other of a module definition> in the same schema. Access Rules 1) If a is contained in a , then the of the current SQL-session shall be equal to the that owns the schema identified by the implicit or explicit of the . General Rules 1) A defines a module. 2) A privilege descriptor is created that defines the EXECUTE priv- ilege on this module to the of the or in which the appears. This privilege is grantable. The grantor of the privilege de- scriptor is set to the special grantor value "_SYSTEM". 32 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 6.2 Leveling Rules 1) The following restrictions apply for Full SQL: a) Conforming Full SQL language shall contain no . 2) The following restrictions apply for Intermediate SQL in addi- tion to any Full SQL restrictions: None. 3) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. Persistent SQL module maintenance 33 YOK-010 and X3H2-93-082 6.3 6.3 Function Destroy a module. Format ::= DROP MODULE Syntax Rules 1) Let M be the module identified by and let MN be the . Access Rules 1) The of the current SQL-session shall be equal to the that owns the schema identified by the of the module identified by MN. General Rules 1) Let A be the current . The following is effectively executed with a current of "_SYSTEM" and without further Access Rule checking: REVOKE EXECUTE ON MODULE M FROM A 2) The descriptor of M is destroyed. Leveling Rules 1) The following restrictions apply for Full SQL: a) Conforming Full SQL language shall contain no . 2) The following restrictions apply for Intermediate SQL in addi- tion to any Full SQL restrictions: None. 3) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 34 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 7 Persistent SQL module use 7.1 Introduction Persistent SQL module use 35 YOK-010 and X3H2-93-082 7.2 7.2 Function Invoke a procedure. Format ::= CALL Syntax Rules 1) A shall contain a whose candidate s are procedures. Note: The candidate s of a are defined in (routine_invocation\FULL). Access Rules 1) The applicable privileges shall include the EXECUTE privilege on the identified by . General Rules 1) The is executed. Leveling Rules 1) The following restrictions apply for Full SQL: a) Conforming Full SQL language shall contain no . 2) The following restrictions apply for Intermediate SQL in addi- tion to any Full SQL restrictions: None. 3) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 36 (ISO Working Draft) Persistent SQL Modules YOK-010 and X3H2-93-082 7.3 7.3 Function Return a value from an SQL function. Format ::= RETURN ::= | ::= TUPLE ::= [ { }... ] Syntax Rules 1) A shall be contained in a that is an SQL function. Let F be that . 2) Case: a) If the of F specifies a , then the data type of the shall be the same as the specified with RETURNS in F. b) If the of F specifies a , then: i) F shall be contained in an ADT. Let TD be the sequence of stored columns in ADT. ii) The specified in the of F shall identify the of ADT. iii) The number of s simply contained in the shall be the same as the number of s contained in TD. iv) Let TUi be the i-th in the and let TDi be the data type of the i-th column of TD. CAST (TUi AS TDi) shall conform to the Syntax Rules of Subclause 6.10, "". Persistent SQL module use 37 YOK-010 and X3H2-93-082 7.3 Access Rules None. General Rules 1) Case: a) If the is a , then the re- turn value is set to the value of that . b) If the is a , then: i) For every in the , the General Rules for CAST (TUi AS TDi) are performed. ii) The return value is set to a value whose type is that of TN and whose i-th component value is CAST (TUi AS TDi). Leveling Rules 1) The following restrictions apply for Full SQL: a) Conforming Full SQL language shall contain no . 2) The following restrictions apply for Intermediate SQL in addi- tion to any Full SQL restrictions: None. 3) The following restrictions apply for Entry SQL in addition to any Intermediate SQL restrictions: None. 38 (ISO Working Draft) Persistent SQL Modules Annex A (Informative) Place Holder Place Holder 39