SQL/MX Release 3.4 Reference Manualh20628.BEGINWORKStatement.....98...

993
HPE NonStop SQL/MX Release 3.4 Reference Manual Part Number: 691117-009 Published: May 2017 Edition: L16.05 and later L-series RVUs and J06.21 and later J-series RVUs

Transcript of SQL/MX Release 3.4 Reference Manualh20628.BEGINWORKStatement.....98...

  • HPE NonStop SQL/MX Release 3.4Reference Manual

    Part Number: 691117-009Published: May 2017Edition: L16.05 and later L-series RVUs and J06.21 and later J-series RVUs

  • © Copyright 2017 Hewlett Packard Enterprise Development LP

    The information contained herein is subject to change without notice. The only warranties for Hewlett Packard Enterprise products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. Hewlett Packard Enterprise shall not be liable for technical or editorial errors or omissions contained herein.

    Confidential computer software. Valid license from Hewlett Packard Enterprise required for possession, use, or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license.

    Links to third-party websites take you outside the Hewlett Packard Enterprise website. Hewlett Packard Enterprise has no control over and is not responsible for information outside the Hewlett Packard Enterprise website.

    Acknowledgments

    Intel®, Itanium®, Pentium®, Intel Inside®, and the Intel Inside logo are trademarks of Intel Corporation in the United States and other countries.

    Microsoft® and Windows®are trademarks of the Microsoft group of companies.

    Java® and Oracle® are registered trademarks of Oracle and/or its affiliates.

    Motif, OSF/1, UNIX, X/Open, and the "X" device are registered trademarks and IT DialTone and The Open Group are trademarks of The OpenGroup in the U.S. and other countries.

    Warranty

    Open Software Foundation, OSF, the OSF logo, OSF/1, OSF/Motif, and Motif are trademarks of the Open Software Foundation, Inc.

    OSF MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THE OSF MATERIAL PROVIDED HEREIN, INCLUDING, BUT NOT LIMITEDTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

    OSF shall not be liable for errors contained herein or for incidental consequential damages in connection with the furnishing, performance, oruse of this material.

    © 1990, 1991, 1992, 1993 Open Software Foundation, Inc. This documentation and the software to which it relates are derived in part frommaterials supplied by the following:

    © 1987, 1988, 1989 Carnegie-Mellon University. © 1989, 1990, 1991 Digital Equipment Corporation. © 1985, 1988, 1989, 1990 Encore ComputerCorporation. © 1988 Free Software Foundation, Inc. © 1987, 1988, 1989, 1990, 1991 Hewlett-Packard Company. © 1985, 1987, 1988, 1989,1990, 1991, 1992 International Business Machines Corporation. © 1988, 1989 Massachusetts Institute of Technology. © 1988, 1989, 1990 MentatInc. © 1988 Microsoft Corporation. © 1987, 1988, 1989, 1990, 1991, 1992 SecureWare, Inc. © 1990, 1991 Siemens Nixdorf InformationssystemeAG. © 1986, 1989, 1996, 1997 Sun Microsystems, Inc. © 1989, 1990, 1991 Transarc Corporation.

    This software and documentation are based in part on the Fourth Berkeley Software Distribution under license from The Regents of the Universityof California. OSF acknowledges the following individuals and institutions for their role in its development: Kenneth C.R.C. Arnold, Gregory S.Couch, Conrad C. Huang, Ed James, Symmetric Computer Systems, Robert Elz. © 1980, 1981, 1982, 1983, 1985, 1986, 1987, 1988, 1989Regents of the University of California.

    Export of the information contained in this publication may require authorization from the U.S. Department of Commerce.

  • ContentsAbout this Document............................................................................................27

    Supported Release Version Updates (RVUs).....................................................................................27Intended Audience..............................................................................................................................27New and Changed Information...........................................................................................................27

    Changes to 691117-009 manual....................................................................................................27Changes to 691117-008 manual....................................................................................................27Changes to 691117-007 manual....................................................................................................30Changes to 691117-006 manual....................................................................................................31Changes to 691117-005 manual....................................................................................................31

    Related Documentation......................................................................................................................31Publishing History...............................................................................................................................33Change Bar Notation..........................................................................................................................33

    1 Introduction........................................................................................................34SQL/MX Language.............................................................................................................................34MXCI SQL/MX Conversational Interface............................................................................................34

    MXCI Session................................................................................................................................35Session Attributes..........................................................................................................................35Entering a Command.....................................................................................................................35SQL Comments ............................................................................................................................36Transactions in MXCI....................................................................................................................36Query Interruption and Termination in MXCI ................................................................................37

    Security ..............................................................................................................................................37The Super ID.................................................................................................................................37Guardian User ID...........................................................................................................................37Guardian Super ID.........................................................................................................................37Security Administrator...................................................................................................................38Security Administrator's Group......................................................................................................38With Grant Option..........................................................................................................................38Owner-Derived Grant....................................................................................................................38Derived Privilege...........................................................................................................................38Derived WGO................................................................................................................................38Security Administrator Grant.........................................................................................................38

    Data Consistency and Access Options...............................................................................................38SQL/MP Considerations................................................................................................................39READ UNCOMMITTED ................................................................................................................39READ COMMITTED .....................................................................................................................39SERIALIZABLE or REPEATABLE READ .....................................................................................40SKIP CONFLICT ..........................................................................................................................40STABLE ........................................................................................................................................40

    Database Integrity and Locking..........................................................................................................41Lock Duration ...............................................................................................................................41Lock Granularity ...........................................................................................................................41Lock Mode ....................................................................................................................................42Lock Holder ..................................................................................................................................42

    Transaction Management...................................................................................................................43Statement Atomicity.......................................................................................................................43User-Defined and System-Defined Transactions..........................................................................44Rules for DML Statements ...........................................................................................................45Effect of AUTOCOMMIT Option....................................................................................................45Concurrency .................................................................................................................................45Transaction Access Modes ..........................................................................................................50

    Contents 3

  • Transaction Isolation Levels..........................................................................................................50Partition Management.........................................................................................................................51Internationalization..............................................................................................................................52Using NonStop SQL/MX to Access SQL/MP Databases...................................................................52

    Naming Objects.............................................................................................................................52Delimiting Reserved Words in Guardian Names ..........................................................................54Selecting or Changing Data...........................................................................................................54Accessing Views ...........................................................................................................................56Access Options .............................................................................................................................57SQL/MP Stored Text .....................................................................................................................57SQL/MP File Organizations...........................................................................................................58Collations ......................................................................................................................................58

    ANSI Compliance and SQL/MX Extensions ......................................................................................58Default Settings for ANSI Compliance .........................................................................................58ANSI-Compliant Statements .........................................................................................................59Statements That Are SQL/MX Extensions ...................................................................................60ANSI-Compliant Functions ...........................................................................................................61

    SQL/MX Error Messages ...................................................................................................................622 SQL/MX Statements..........................................................................................63

    Categories..........................................................................................................................................63Data Definition Language (DDL) Statements ...............................................................................63Data Manipulation Language (DML) Statements .........................................................................65Transaction Control Statements ...................................................................................................65Prepared SQL Statements ...........................................................................................................65Embedded-Only SQL/MX Statements...........................................................................................65Resource Control and Optimization Statements ..........................................................................66Control Statements........................................................................................................................66Object Naming Statements............................................................................................................66Alias Statements............................................................................................................................67Stored Procedure Statements.......................................................................................................67Trigger Statements........................................................................................................................67Utilities...........................................................................................................................................67

    ALTER INDEX Statement ..................................................................................................................69Syntax Description of ALTER INDEX............................................................................................70Considerations for ALTER INDEX.................................................................................................70Examples of ALTER INDEX .........................................................................................................71

    ALTER SEQUENCE Statement .........................................................................................................71Syntax Description of ALTER SEQUENCE...................................................................................72Considerations for ALTER SEQUENCE........................................................................................73Examples of ALTER SEQUENCE ................................................................................................73

    ALTER SQLMP ALIAS Statement......................................................................................................74Syntax Description of ALTER SQLMP ALIAS...............................................................................74Considerations for ALTER SQLMP ALIAS....................................................................................74Examples of ALTER SQLMP ALIAS .............................................................................................75

    ALTER TABLE Statement ..................................................................................................................75Syntax Description of ALTER TABLE............................................................................................76Considerations for ALTER TABLE.................................................................................................85Examples of ALTER TABLE .........................................................................................................91

    ALTER TRIGGER Statement .............................................................................................................95Syntax Description of ALTER TRIGGER.......................................................................................96Considerations for ALTER TRIGGER............................................................................................96

    ALTER VIEW Statement.....................................................................................................................96Considerations for ALTER VIEW ..................................................................................................97Example of ALTER VIEW .............................................................................................................97

    4 Contents

  • BEGIN WORK Statement ..................................................................................................................98Considerations for BEGIN WORK.................................................................................................98MXCI Examples of BEGIN WORK ...............................................................................................99C Examples of BEGIN WORK ......................................................................................................99COBOL Examples of BEGIN WORK ............................................................................................99

    CALL Statement...............................................................................................................................100Considerations for CALL.............................................................................................................101Examples of CALL ......................................................................................................................102

    COMMIT WORK Statement .............................................................................................................102Considerations for COMMIT WORK...........................................................................................102MXCI Examples of COMMIT WORK ..........................................................................................104C Examples of COMMIT WORK ................................................................................................104COBOL Examples of COMMIT WORK ......................................................................................104

    CONTROL QUERY DEFAULT Statement........................................................................................105Inline CONTROL QUERY DEFAULT...........................................................................................106Considerations for CONTROL QUERY DEFAULT......................................................................106Examples of CONTROL QUERY DEFAULT ..............................................................................107

    CONTROL QUERY SHAPE Statement............................................................................................107Considerations for CONTROL QUERY SHAPE..........................................................................113Examples of CONTROL QUERY SHAPE ..................................................................................113

    CONTROL TABLE Statement...........................................................................................................116Considerations for CONTROL TABLE.........................................................................................119Examples of CONTROL TABLE .................................................................................................119

    CREATE CATALOG Statement .......................................................................................................120Syntax Description of CREATE CATALOG.................................................................................120Considerations for CREATE CATALOG......................................................................................120Examples of CREATE CATALOG ...............................................................................................121

    CREATE INDEX Statement .............................................................................................................121Syntax Description of CREATE INDEX.......................................................................................121Considerations for CREATE INDEX ...........................................................................................125Examples of CREATE INDEX.....................................................................................................127

    CREATE PROCEDURE Statement .................................................................................................128Considerations for CREATE PROCEDURE................................................................................133Examples of CREATE PROCEDURE ........................................................................................133

    CREATE SCHEMA Statement .........................................................................................................134Syntax Description of CREATE SCHEMA...................................................................................135Considerations for CREATE SCHEMA .......................................................................................136Examples of CREATE SCHEMA ................................................................................................137

    CREATE SEQUENCE Statement.....................................................................................................137Syntax Description of CREATE SEQUENCE..............................................................................138Considerations for CREATE SEQUENCE...................................................................................139Examples of CREATE SEQUENCE............................................................................................140

    CREATE SQLMP ALIAS Statement ................................................................................................140Considerations for CREATE SQLMP ALIAS...............................................................................141Examples of CREATE SQLMP ALIAS ........................................................................................142

    CREATE TABLE Statement .............................................................................................................142Syntax Description of CREATE TABLE.......................................................................................145Considerations for CREATE TABLE ...........................................................................................156Examples of CREATE TABLE ....................................................................................................165

    CREATE TRIGGER Statement ........................................................................................................171Syntax Description of CREATE TRIGGER..................................................................................171Considerations for CREATE TRIGGER.......................................................................................173Examples of CREATE TRIGGER................................................................................................177

    CREATE VIEW Statement ...............................................................................................................179Syntax Description of CREATE VIEW.........................................................................................180

    Contents 5

  • Considerations for CREATE VIEW .............................................................................................182Examples of CREATE VIEW ......................................................................................................183

    DELETE Statement..........................................................................................................................184Considerations for DELETE........................................................................................................191Multi Commit Delete....................................................................................................................191MXCI Examples of DELETE .......................................................................................................194C Examples of DELETE .............................................................................................................195COBOL Examples of DELETE ...................................................................................................196Publish/Subscribe Examples of DELETE ...................................................................................196

    DOWNGRADE Utility........................................................................................................................197Considerations for DOWNGRADE .............................................................................................198Example of DOWNGRADE ........................................................................................................200

    DROP CATALOG Statement ...........................................................................................................200Syntax Description of DROP CATALOG.....................................................................................201Considerations for DROP CATALOG..........................................................................................201Examples of DROP CATALOG....................................................................................................201

    DROP INDEX Statement .................................................................................................................201Syntax Description of DROP INDEX...........................................................................................201Considerations for DROP INDEX................................................................................................202Examples of DROP INDEX ........................................................................................................202

    DROP PROCEDURE Statement .....................................................................................................202Considerations for DROP PROCEDURE....................................................................................203Example of DROP PROCEDURE ..............................................................................................203

    DROP SCHEMA Statement .............................................................................................................203Syntax Description of DROP SCHEMA.......................................................................................203Considerations for DROP SCHEMA ..........................................................................................203Examples of DROP SCHEMA ....................................................................................................204

    DROP SEQUENCE Statement.........................................................................................................204Syntax Description of DROP SEQUENCE..................................................................................205Considerations for DROP SEQUENCE.......................................................................................205Examples of DROP SEQUENCE ...............................................................................................205

    DROP SQL Statement .....................................................................................................................205Considerations for DROP SQL ...................................................................................................205Examples of DROP SQL ............................................................................................................206

    DROP SQLMP ALIAS Statement ....................................................................................................206Considerations for DROP SQLMP ALIAS...................................................................................206Examples of DROP SQLMP ALIAS ...........................................................................................207

    DROP TABLE Statement .................................................................................................................207Syntax Description of DROP TABLE...........................................................................................207Considerations for DROP TABLE ...............................................................................................207Examples of DROP TABLE.........................................................................................................208

    DROP TRIGGER Statement ............................................................................................................208Syntax Description of DROP TRIGGER......................................................................................208Considerations for DROP TRIGGER..........................................................................................208Examples of DROP TRIGGER....................................................................................................208

    DROP VIEW Statement ...................................................................................................................208Syntax Description of DROP VIEW.............................................................................................209Considerations for DROP VIEW .................................................................................................209Examples of DROP VIEW ..........................................................................................................209

    DUP Utility........................................................................................................................................209Syntax Description of DUP..........................................................................................................210Considerations for DUP...............................................................................................................212Examples of DUP........................................................................................................................214

    EXECUTE Statement.......................................................................................................................214Considerations for EXECUTE.....................................................................................................217

    6 Contents

  • MXCI Examples of EXECUTE ....................................................................................................217C Examples of EXECUTE ..........................................................................................................218COBOL Examples of EXECUTE ................................................................................................219

    EXPLAIN Statement.........................................................................................................................219Considerations for EXPLAIN.......................................................................................................221Examples of EXPLAIN ................................................................................................................222

    FASTCOPY Utility.............................................................................................................................232FASTCOPY TABLE Command....................................................................................................232FASTCOPY INDEX Command....................................................................................................233Considerations for FASTCOPY...................................................................................................233Examples of FASTCOPY.............................................................................................................237

    GET ALL SECURITY_ADMINS Statement......................................................................................237Considerations for GET ALL SECURITY_ADMINS ...................................................................237Examples of GET ALL SECURITY_ADMINS .............................................................................238

    GIVE CATALOG Statement..............................................................................................................238Considerations for GIVE CATALOG ...........................................................................................238Example of GIVE CATALOG ......................................................................................................239

    GIVE Object Statement....................................................................................................................239Considerations for GIVE Object..................................................................................................239Examples of GIVE Object............................................................................................................240

    GIVE SCHEMA Operation................................................................................................................240Considerations for GIVE SCHEMA.............................................................................................241Examples of GIVE SCHEMA.......................................................................................................241

    GRANT Statement ...........................................................................................................................241Syntax Description of GRANT.....................................................................................................242Considerations for GRANT .........................................................................................................243Examples of GRANT ..................................................................................................................244

    GRANT CREATE CATALOG Statement...........................................................................................245Considerations for GRANT CREATE CATALOG ........................................................................245Examples for GRANT CREATE CATALOG.................................................................................245

    GRANT CREATE SCHEMA Statement............................................................................................245Considerations for GRANT CREATE SCHEMA .........................................................................246Example for GRANT CREATE SCHEMA ...................................................................................246

    GRANT SECURITY_ADMIN Statement...........................................................................................246Considerations for GRANT SECURITY_ADMIN ........................................................................246Examples of GRANT SECURITY_ADMIN .................................................................................247

    INITIALIZE SQL Statement .............................................................................................................247Considerations for INITIALIZE SQL ...........................................................................................247Examples of INITIALIZE SQL .....................................................................................................248

    INSERT Statement...........................................................................................................................248Considerations for INSERT ........................................................................................................256Considerations for self-referencing inserts..................................................................................258MXCI Examples of INSERT ........................................................................................................259C Examples of INSERT ..............................................................................................................262COBOL Examples of INSERT ....................................................................................................263

    LOCK TABLE Statement..................................................................................................................263Considerations for LOCK TABLE................................................................................................264Examples of LOCK TABLE..........................................................................................................264

    MODIFY Utility..................................................................................................................................265Reload tables or indexes using ANSI name................................................................................266Reuse an Existing Partition of a Range Partitioned Table...........................................................268Manage Partitions of Range Partitioned Tables and Indexes......................................................269Manage Partitions of Hash Partitioned Tables and Indexes........................................................274Manage System-Clustered Tables..............................................................................................279Managing a Sequence Generator...............................................................................................280

    Contents 7

  • Renaming Guardian Location of Partitions of Tables, Indexes or Sequence Generators...........280Considerations for MODIFY........................................................................................................282Examples of MODIFY..................................................................................................................287

    PREPARE Statement.......................................................................................................................289Considerations for PREPARE.....................................................................................................291MXCI Examples of PREPARE ....................................................................................................291C Examples of PREPARE ..........................................................................................................292COBOL Examples of PREPARE ................................................................................................293

    POPULATE INDEX Utility.................................................................................................................293Syntax Description of POPULATE INDEX...................................................................................294Considerations for POPULATE INDEX.......................................................................................295Examples of POPULATE INDEX.................................................................................................295

    PURGEDATA Utility..........................................................................................................................296Syntax Description of PURGEDATA............................................................................................296Considerations for PURGEDATA................................................................................................297Examples of PURGEDATA..........................................................................................................298

    RECOVER Utility .............................................................................................................................298Syntax Description of RECOVER................................................................................................299Considerations for RECOVER.....................................................................................................299Examples of RECOVER..............................................................................................................300

    RECOVER SCHEMA Operation.......................................................................................................300Considerations for RECOVER SCHEMA....................................................................................300Examples of RECOVER SCHEMA.............................................................................................301

    REGISTER CATALOG Statement....................................................................................................301Considerations for REGISTER CATALOG..................................................................................301Examples of REGISTER CATALOG ...........................................................................................302

    REVOKE Statement.........................................................................................................................302Syntax Description of REVOKE...................................................................................................303Considerations for REVOKE.......................................................................................................304Examples of REVOKE ................................................................................................................306

    REVOKE CREATE CATALOG Statement........................................................................................306Considerations for REVOKE CREATE CATALOG .....................................................................307Examples for REVOKE CREATE CATALOG .............................................................................307

    REVOKE CREATE SCHEMA Statement..........................................................................................307Considerations for REVOKE CREATE SCHEMA .......................................................................308Example for REVOKE CREATE SCHEMA..................................................................................308

    REVOKE SECURITY_ADMIN Statement ........................................................................................308Considerations for REVOKE SECURITY_ADMIN .....................................................................309Examples of REVOKE SECURITY_ADMIN ...............................................................................309

    ROLLBACK WORK Statement.........................................................................................................309Considerations for ROLLBACK WORK.......................................................................................309MXCI Examples of ROLLBACK WORK .....................................................................................310C Examples of ROLLBACK WORK ............................................................................................311COBOL Examples of ROLLBACK WORK ..................................................................................311

    SELECT Statement..........................................................................................................................311Considerations for SELECT........................................................................................................330Considerations for Select List......................................................................................................333Considerations for SEQUENCE BY............................................................................................333Considerations for GROUP BY...................................................................................................333Considerations for ORDER BY....................................................................................................334Considerations for UNION ..........................................................................................................334MXCI Examples of SELECT .......................................................................................................336C Examples of SELECT .............................................................................................................341COBOL Examples of SELECT ...................................................................................................341Publish/Subscribe Examples of SELECT ...................................................................................342

    8 Contents

  • Inline CQD Examples of SELECT ..............................................................................................343SELECT ROW COUNT Statement...................................................................................................343

    Considerations for SELECT ROW COUNT ................................................................................343Limitations of SELECT ROW COUNT ........................................................................................343Example of SELECT ROW COUNT ...........................................................................................344

    SET Statement ................................................................................................................................344Considerations for SET Statement .............................................................................................344

    SET CATALOG Statement ...............................................................................................................344Considerations for SET CATALOG..............................................................................................345MXCI Examples of SET CATALOG ............................................................................................345C Example of SET CATALOG ....................................................................................................345COBOL Example of SET CATALOG ..........................................................................................345

    SET MPLOC Statement....................................................................................................................346Considerations for SET MPLOC.................................................................................................346Examples of SET MPLOC ..........................................................................................................346

    SET NAMETYPE Statement.............................................................................................................346Considerations for SET NAMETYPE..........................................................................................347Examples of SET NAMETYPE ...................................................................................................347

    SET SCHEMA Statement.................................................................................................................347Considerations for SET SCHEMA...............................................................................................348MXCI Examples of SET SCHEMA .............................................................................................348C Example of SET SCHEMA ......................................................................................................348COBOL Example of SET SCHEMA ............................................................................................348

    SET TABLE TIMEOUT Statement....................................................................................................348Considerations for SET TABLE TIMEOUT..................................................................................350MXCI Examples of SET TABLE TIMEOUT ................................................................................351C Examples of SET TABLE TIMEOUT .......................................................................................351

    SET TRANSACTION Statement.......................................................................................................352Considerations for SET TRANSACTION....................................................................................354MXCI Examples of SET TRANSACTION ...................................................................................355C Examples of SET TRANSACTION .........................................................................................355COBOL Examples of SET TRANSACTION ...............................................................................355

    SIGNAL SQLSTATE Statement .......................................................................................................355Considerations for SIGNAL SQLSTATE .....................................................................................356

    TABLE Statement ............................................................................................................................356Considerations for TABLE...........................................................................................................356Examples of TABLE ....................................................................................................................356

    UNLOCK TABLE Statement.............................................................................................................356Considerations for UNLOCK TABLE...........................................................................................357Examples of UNLOCK TABLE ....................................................................................................357

    UNREGISTER CATALOG Statement...............................................................................................357Considerations for UNREGISTER CATALOG.............................................................................358Example of UNREGISTER CATALOG........................................................................................358

    UPDATE Statement..........................................................................................................................358Considerations for UPDATE .......................................................................................................366MXCI Examples of UPDATE ......................................................................................................371C Examples of UPDATE .............................................................................................................372COBOL Examples of UPDATE....................................................................................................373Publish/Subscribe Examples of UPDATE ...................................................................................373

    UPDATE STATISTICS Statement.....................................................................................................374Considerations for UPDATE STATISTICS...................................................................................378Examples of UPDATE STATISTICS............................................................................................382

    UPGRADE Utility..............................................................................................................................383Considerations for UPGRADE.....................................................................................................384Example of UPGRADE ...............................................................................................................386

    Contents 9

  • VALUES Statement .........................................................................................................................386Considerations for VALUES........................................................................................................387Examples of VALUES .................................................................................................................387

    3 Embedded-Only SQL/MX Statements.............................................................388ALLOCATE CURSOR Statement.....................................................................................................389

    Considerations for ALLOCATE CURSOR...................................................................................390C Examples of ALLOCATE CURSOR ........................................................................................390COBOL Examples of ALLOCATE CURSOR ..............................................................................391Publish/Subscribe Examples of ALLOCATE CURSOR ..............................................................391

    ALLOCATE DESCRIPTOR Statement ............................................................................................391Considerations for ALLOCATE DESCRIPTOR...........................................................................392C Examples of ALLOCATE DESCRIPTOR ................................................................................392COBOL Examples of ALLOCATE DESCRIPTOR ......................................................................393

    BEGIN DECLARE SECTION Declaration........................................................................................393C Examples of BEGIN DECLARE SECTION .............................................................................393C++ Examples of BEGIN DECLARE SECTION .........................................................................394COBOL Examples of BEGIN DECLARE SECTION ...................................................................394

    CLOSE Statement ...........................................................................................................................394Considerations for CLOSE..........................................................................................................395C Examples of CLOSE ...............................................................................................................395COBOL Examples of CLOSE......................................................................................................396

    Compound (BEGIN...END) Statement..............................................................................................396Considerations for Compound Statement...................................................................................397C Examples of Compound Statement.........................................................................................397

    DEALLOCATE DESCRIPTOR Statement .......................................................................................397C Examples of DEALLOCATE DESCRIPTOR ...........................................................................398COBOL Examples of DEALLOCATE DESCRIPTOR..................................................................398

    DEALLOCATE PREPARE Statement ..............................................................................................399Considerations for DEALLOCATE PREPARE.............................................................................399C Examples of DEALLOCATE PREPARE ..................................................................................400COBOL Examples of DEALLOCATE PREPARE ........................................................................401

    DECLARE CATALOG Declaration....................................................................................................401Considerations for DECLARE CATALOG....................................................................................401C Examples of DECLARE CATALOG ........................................................................................402COBOL Examples of DECLARE CATALOG ..............................................................................402

    DECLARE CURSOR Declaration.....................................................................................................402Considerations for DECLARE CURSOR.....................................................................................404C Examples of DECLARE CURSOR .........................................................................................405COBOL Examples of DECLARE CURSOR ...............................................................................405Publish/Subscribe Examples of DECLARE CURSOR................................................................406

    DECLARE MPLOC Declaration .......................................................................................................406Considerations for DECLARE MPLOC.......................................................................................407C Examples of DECLARE MPLOC ............................................................................................408COBOL Examples of DECLARE MPLOC ..................................................................................408

    DECLARE NAMETYPE Declaration ................................................................................................408Considerations for DECLARE NAMETYPE................................................................................408C Examples of DECLARE NAMETYPE......................................................................................408COBOL Examples of DECLARE NAMETYPE ...........................................................................408

    DECLARE SCHEMA Declaration ....................................................................................................408Considerations for DECLARE SCHEMA.....................................................................................409C Examples of DECLARE SCHEMA ..........................................................................................409COBOL Examples of DECLARE SCHEMA ................................................................................409

    DESCRIBE Statement .....................................................................................................................409C Examples of DESCRIBE .........................................................................................................411

    10 Contents

  • COBOL Examples of DESCRIBE ...............................................................................................411END DECLARE SECTION Declaration ...........................................................................................412

    C Examples of END DECLARE SECTION ................................................................................412C++ Examples of END DECLARE SECTION ............................................................................412COBOL Examples of END DECLARE SECTION ......................................................................412

    EXEC SQL Directive.........................................................................................................................412Considerations for EXEC SQL....................................................................................................413Examples of EXEC SQL .............................................................................................................413

    EXECUTE IMMEDIATE Statement ..................................................................................................413Considerations for EXECUTE IMMEDIATE.................................................................................413C Examples of EXECUTE IMMEDIATE .....................................................................................414COBOL Examples of EXECUTE IMMEDIATE ...........................................................................414

    FETCH Statement ...........................................................................................................................414Considerations for FETCH..........................................................................................................416C Examples of FETCH ...............................................................................................................417COBOL Examples of FETCH......................................................................................................418

    GET DESCRIPTOR Statement........................................................................................................418SQL Item Descriptor Area of GET DESCRIPTOR......................................................................420SQL Descriptor Area Data Type Declarations of GET DESCRIPTOR........................................422Considerations for GET DESCRIPTOR......................................................................................424C Examples of GET DESCRIPTOR ...........................................................................................425COBOL Examples of GET DESCRIPTOR .................................................................................425

    GET DIAGNOSTICS Statement ......................................................................................................426Statement Items of GET DIAGNOSTICS....................................................................................427Condition Items of GET DIAGNOSTICS.....................................................................................428Considerations for GET DIAGNOSTICS.....................................................................................429C Examples of GET DIAGNOSTICS ..........................................................................................430COBOL Examples of GET DIAGNOSTICS ................................................................................430

    IF Statement.....................................................................................................................................430Considerations for IF Statement..................................................................................................431C Example of IF Statement ........................................................................................................432COBOL Example of IF Statement ..............................................................................................432

    INVOKE Directive.............................................................................................................................432Considerations for INVOKE.........................................................................................................434C Examples of INVOKE ..............................................................................................................435COBOL Examples of INVOKE.....................................................................................................436

    MODULE Directive ..........................................................................................................................437Considerations for MODULE.......................................................................................................438C Examples of MODULE.............................................................................................................438COBOL Examples of MODULE...................................................................................................438

    OPEN Statement..............................................................................................................................438Considerations for OPEN............................................................................................................439C Examples of OPEN .................................................................................................................440COBOL Examples of OPEN .......................................................................................................440

    SET ( Assignment) Statement..........................................................................................................441C Examples of Assignment Statement .......................................................................................442

    SET DESCRIPTOR Statement ........................................................................................................442SQL Item Descriptor Area of SET DESCRIPTOR.......................................................................443Considerations for SET DESCRIPTOR.......................................................................................445C Examples of SET DESCRIPTOR.............................................................................................448COBOL Examples of SET DESCRIPTOR ..................................................................................448

    WHENEVER Declaration .................................................................................................................448Considerations for WHENEVER.................................................................................................449C Examples of WHENEVER ......................................................................................................450COBOL Examples of WHENEVER ............................................................................................450

    Contents 11

  • 4 MXCI Commands............................................................................................451ADD DEFINE Command..................................................................................................................453

    Considerations for ADD DEFINE................................................................................................454Examples of ADD DEFINE .........................................................................................................454

    ALTER DEFINE Command...............................................................................................................454Considerations for ALTER DEFINE.............................................................................................455Examples of ALTER DEFINE .....................................................................................................455

    CD Command...................................................................................................................................455Considerations for CD.................................................................................................................455Examples of CD ..........................................................................................................................455

    DELETE DEFINE Command............................................................................................................456Considerations for DELETE DEFINE..........................................................................................456Examples of DELETE DEFINE ...................................................................................................456

    DISPLAY USE OF Command...........................................................................................................456Considerations for DISPLAY USE OF.........................................................................................457Examples of DISPLAY USE OF .................................................................................................458

    DISPLAY USE OF SOURCE............................................................................................................459Examples of DISPLAY USE OF Source......................................................................................460

    DISPLAY USE OF ALL | INVALID MODULES..................................................................................460Considerations for DISPLAY USE OF ALL | INVALID MODULES..............................................462Examples of ALL | INVALID MODULES......................................................................................462

    DISPLAY_QC Command..................................................................................................................463Considerations for DISPLAY_QC................................................................................................463Examples of DISPLAY_QC ........................................................................................................464

    DISPLAY_QC_ENTRIES Command................................................................................................464Considerations for DISPLAY_QC_ENTRIES..............................................................................464Examples of DISPLAY_QC_ENTRIES........................................................................................465

    DISPLAY STATISTICS Command....................................................................................................466Considerations for DISPLAY STATISTICS..................................................................................466Examples of DISPLAY STATISTICS ...........................................................................................466

    ENV Command.................................................................................................................................467Examples of ENV........................................................................................................................467

    ERROR Command...........................................................................................................................468Examples of ERROR ..................................................................................................................468

    Exclamation Point (!) Command.......................................................................................................468Examples of ! ..............................................................................................................................469

    EXIT Command................................................................................................................................469Considerations for EXIT..............................................................................................................469Examples of EXIT .......................................................................................................................470

    FC Command...................................................................................................................................470Examples of FC ..........................................................................................................................471

    GTACL Command............................................................................................................................471Considerations for GTACL...........................................................................................................472Examples of GTACL ...................................................................................................................472

    GET NAMES OF RELATED NODES Command..............................................................................472Error Conditions for GET NAMES OF RELATED NODES..........................................................473Example of GET NAMES OF RELATED NODES ......................................................................473

    GET NAMES OF RELATED SCHEMAS Command.........................................................................473Error Conditions for GET NAMES OF RELATED SCHEMAS.....................................................473Example of GET NAMES OF RELATED SCHEMAS .................................................................473

    GET NAMES OF RELATED CATALOGS.........................................................................................474Error Conditions for GET NAMES OF RELATED CATALOGS....................................................474Example of GET NAMES OF RELATED CATALOGS ................................................................474

    GET VERSION OF SYSTEM...........................................................................................................474

    12 Contents

  • Error Conditions for GET VERSION OF SYSTEM......................................................................474Example of GET VERSION OF SYSTEM ..................................................................................475

    GET VERSION OF SCHEMA Command.........................................................................................475Error Conditions for GET VERSION OF SCHEMA.....................................................................475Examples of GET VERSION OF SCHEMA ................................................................................475

    GET VERSION OF SYSTEM SCHEMA Command.........................................................................475Error Conditions for GET VERSION OF SYSTEM SCHEMA.....................................................476Example of GET VERSION OF SYSTEM SCHEMA ..................................................................476

    GET VERSION OF Object Command..............................................................................................476Error Conditions for GET VERSION OF Object..........................................................................476Example of GET VERSION OF Object ......................................................................................477

    GET VERSION OF MODULE Command.........................................................................................477Error Conditions for GET VERSION OF MODULE.....................................................................477Example of GET VERSION OF MODULE .................................................................................477

    GET VERSION OF PROCEDURE Command..................................................................................477Error Conditions for GET VERSION OF PROCEDURE..............................................................478Example of GET VERSION OF PROCEDURE...........................................................................478

    GET VERSION OF STATEMENT Command...................................................................................478Error Conditions for GET VERSION OF STATEMENT...............................................................478Example of GET VERSION OF STATEMENT ............................................................................478

    HELP Command ..............................................................................................................................478Considerations for HELP.............................................................................................................480Examples of HELP......................................................................................................................480

    HISTORY Command........................................................................................................................481Examples of HISTORY ...............................................................................................................481

    INFO DEFINE Command.................................................................................................................481Examples of INFO DEFINE ........................................................................................................482

    INVOKE Command...........................................................................................................................482Examples of INVOKE .................................................................................................................483

    LOG Command.................................................................................................................................483Considerations for LOG...............................................................................................................484Examples of LOG .......................................................................................................................484

    LS Command ...................................................................................................................................485Considerations for LS..................................................................................................................486Examples of LS ..........................................................................................................................487

    MODE Command.............................................................................................................................487MXCI Command...............................................................................................................................487

    Examples of MXCI Command.....................................................................................................488OBEY Command..............................................................................................................................489

    Considerations for OBEY............................................................................................................490Examples of OBEY .....................................................................................................................490

    REPEAT Command..........................................................................................................................490Examples of REPEAT .................................................................................................................491

    RESET PARAM Command...............................................................................................................491Examples of RESET PARAM .....................................................................................................491

    SET LIST_COUNT Command..........................................................................................................492Considerations for SET LIST_COUNT........................................................................................492Examples of SET LIST_COUNT ................................................................................................493

    SET PARAM Command....................................................................................................................493Considerations for SET PARAM..................................................................................................494Examples of SET PARAM ..........................................................................................................494

    SET SESSION DEFAULT Statement...............................................................................................495Attributes for SET SESSION DEFAULT......................................................................................495Considerations for SET SESSION DEFAULT.............................................................................496Examples of SET SESSION DEFAULT.......................................................................................496

    Contents 13

  • SET SHOWSHAPE Command.........................................................................................................496Considerations for SET SHOWSHAPE.......................................................................................497Examples of SET SHOWSHAPE ...............................................................................................497

    SET STATISTICS Command ...........................................................................................................498Examples of SET STATISTICS ..................................................................................................498

    SET TERMINAL_CHARSET Command ..........................................................................................499Considerations for SET TERMINAL_CHARSET.........................................................................499

    SET WARNINGS Command.............................................................................................................499Examples of SET WARNINGS ...................................................................................................499

    SH Command...................................................................................................................................500Examples of SH ..........................................................................................................................500

    SHOW PARAM Command...............................................................................................................500Examples of SHOW PARAM ......................................................................................................501

    SHOW PREPARED Command........................................................................................................501Examples of SHOW PREPARED ...............................................................................................501

    SHOW SESSION Command............................................................................................................501Examples of SHOW SESSION ...................................................................................................502

    SHOWCONTROL Command...........................................................................................................502Examples of SHOWCONTROL ..................................................................................................504

    SHOWDDL Command......................................................................................................................507Considerations for SHOWDDL....................................................................................................508Examples of SHOWDDL ............................................................................................................512

    SHOWLABEL Command..................................................................................................................519Considerations for SHOWLABEL................................................................................................520Examples of SHOWLABEL ........................................................................................................522

    SHOWSET Command......................................................................................................................526Examples of SHOWSET Command............................................................................................527

    SHOWSHAPE Command.................................................................................................................527Considerations for SHOWSHAPE...............................................................................................527Examples of SHOWSHAPE .......................................................................................................527

    SHOWSTATS Command..................................................................................................................528Consideration for SHOWSTATS..................................................................................................529Examples of SHOWSTATS.........................................................................................................529

    5 SQL/MX Utilities..............................................................................................533Privileges Required to Execute Utilities............................................................................................533CLEANUP Operation........................................................................................................................534

    Considerations.............................................................................................................................535Restrictions..................................................................................................................................536Examples.....................................................................................................................................536

    FIXRCB Operation............................................................................................................................537Error Conditions...........................................................................................................................537Example of FIXRCB Operation....................................................................................................537

    FIXUP Operation .............................................................................................................................537Considerations for FIXUP Operation...........................................................................................540Examples of FIXUP Operation....................................................................................................540

    GOAWAY Operation.........................................................................................................................541Syntax Description of GOAWAY..................................................................................................541Considerations for GOAWAY.......................................................................................................543Examples of GOAWAY................................................................................................................543

    import Utility......................................................................................................................................545Considerations for import............................................................................................................552Programmatic Interfaces.............................................................................................................561Output File Consideration............................................................................................................563Examples of import......................................................................................................................564

    14 Contents

  • INFO Operation................................................................................................................................570Considerations for INFO..............................................................................................................570Examples of INFO.......................................................................................................................571

    mxexportddl Utility............................................................................................................................571Exporting Metadata and Statistics of SQL/MX Objects...............................................................572Considerations for mxexportddl.......................................................