Programmer's Guide Pro*COBOL - Oracle

Transcription

Pro*COBOL Programmer's Guide21cF31841-01November 2020

Pro*COBOL Programmer's Guide, 21cF31841-01Copyright 1996, 2020, Oracle and/or its affiliates.Primary Author: Celin CherianContributing Authors: Syed Mujeed Ahmed, Jack Melnick, Neelam Singh, Subhranshu Banerjee, BeethovenCheng, Michael Chiocca, Nancy Ikeda, Alex Keh, Thomas Kurian, Shiao-Yen Lin, Diana Lorentz, Ajay Popat,Chris Racicot, Pamela Rothman, Simon Slack, Gael StevensContributors: Valarie MooreThis software and related documentation are provided under a license agreement containing restrictions onuse and disclosure and are protected by intellectual property laws. Except as expressly permitted in yourlicense agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license,transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverseengineering, disassembly, or decompilation of this software, unless required by law for interoperability, isprohibited.The information contained herein is subject to change without notice and is not warranted to be error-free. Ifyou find any errors, please report them to us in writing.If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it onbehalf of the U.S. Government, then the following notice is applicable:U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software,any programs embedded, installed or activated on delivered hardware, and modifications of such programs)and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Governmentend users are "commercial computer software" or "commercial computer software documentation" pursuantto the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such,the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works,and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programsembedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oraclecomputer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in thelicense contained in the applicable contract. The terms governing the U.S. Government’s use of Oracle cloudservices are defined by the applicable contract for such services. No other rights are granted to the U.S.Government.This software or hardware is developed for general use in a variety of information management applications.It is not developed or intended for use in any inherently dangerous applications, including applications thatmay create a risk of personal injury. If you use this software or hardware in dangerous applications, then youshall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure itssafe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of thissoftware or hardware in dangerous applications.Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks oftheir respective owners.Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks areused under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc,and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registeredtrademark of The Open Group.This software or hardware and documentation may provide access to or information about content, products,and services from third parties. Oracle Corporation and its affiliates are not responsible for and expresslydisclaim all warranties of any kind with respect to third-party content, products, and services unless otherwiseset forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will notbe responsible for any loss, costs, or damages incurred due to your access to or use of third-party content,products, or services, except as set forth in an applicable agreement between you and Oracle.

ContentsPrefaceIntended AudiencexxviDocumentation AccessibilityxxviRelated DocumentsxxviiConventionsxxviiPart I1Introduction and ConceptsIntroduction1.1What is Pro*COBOL?1-11.2The Pro*COBOL Precompiler1-11.2.11-21.3Advantages of the Pro*COBOL Precompiler1-31.4The SQL Language1-31.5The PL/SQL Language1-31.6Pro*COBOL Features and Benefits1-41.7Directory Structure1-51.82Language Alternatives1.7.1Header Files1-61.7.2Library File1-61.7.3Known Problems, Restrictions, and Workarounds1-6Compatibility, Upgrading, and Migration1-7Precompiler Concepts2.1Key Concepts of Embedded SQL Programming2-12.1.1Steps in Developing an Embedded SQL Application2-12.1.2Embedded SQL Statements2-22.1.2.1Executable versus Declarative Statements2-32.1.3Embedded SQL Syntax2-42.1.4Static Versus Dynamic SQL Statements2-52.1.5Embedded PL/SQL Blocks2-5iii

2.1.6Host Variables and Indicator Variables2-52.1.7Oracle Datatypes2-62.1.8Tables2-72.1.9Errors and Warnings2-72.1.9.1SQLCODE/SQLSTATE Status Variables2-72.1.9.2SQLCA Status Variable2-72.1.9.3WHENEVER Statement2-82.1.9.4ORACA2-82.1.9.5Precompiler Options and Error Handling2-92.1.102.22.3SQL99 Syntax SupportProgramming ensitivity2-92.2.3COBOL Versions Supported2-92.2.4Coding nuation Lines2-112.2.8Copy Statements2-112.2.9Decimal-Point is Comma2-112.2.10Delimiters2-122.2.11Division Headers that are Optional2-122.2.12Embedded SQL Syntax2-122.2.13Figurative Constants2-132.2.14File Length2-132.2.15FILLER is Allowed2-132.2.16Host Variable Names2-132.2.17Hyphenated Names2-142.2.18Level Numbers2-142.2.19MAXLITERAL Default2-142.2.20Multibyte Datatypes2-142.2.21NULLs in SQL2-142.2.22Paragraph and Section Names2-142.2.23REDEFINES Clause2-152.2.24Relational Operators2-152.2.25Sentence Terminator2-16The Declare Section2.3.1Contents of a Declare Section2.3.1.1An Example2-162-162-172.3.2Precompiler Option DECLARE SECTION2-172.3.3Using the INCLUDE Statement2-17iv

2.42.3.3.1Filename Extensions2-182.3.3.2Search Paths2-18Nested Programs2.4.12.52.62-192.4.1.1Declaring the SQLCA2-202.4.1.2Nested Program Example2-20Conditional Precompilations2-202.5.1An Example2-212.5.2Defining Symbols2-21Separate encing Cursors2-222.6.1.2Specifying MAXOPENCURSORS2-222.6.1.3Using a Single SQLCA2-222.6.1.4Using a Single DATE FORMAT2-232.6.2Restrictions2-232.7Compiling and Linking2-232.8Sample DEPT and EMP Tables2-232.8.12.93Support for Nested Programs2-18Sample DEPT and EMP DataSample EMP Program: SAMPLE1.PCO2-242-24Database Concepts3.1Connecting to Oracle3-13.2Default Databases and Connections3-33.2.1Concurrent Logons3-33.2.2Using Username/Password3-43.2.2.13.2.3Named Database ConnectionsAutomatic Logons3.2.3.1The AUTO CONNECT Precompiler Option3-43-73-83.2.4Changing Passwords at Runtime3-83.2.5Connect Without Alter Authorization3-83.2.5.1Standard CONNECT3-83.2.5.2SYSDBA or SYSOPER Privileges3-93.2.6Using Links3-93.3Key Terms3-93.4How Transactions Guard a Database3-103.5Beginning and Ending Transactions3-113.6Using the COMMIT Statement3-113.6.1WITH HOLD Clause in DECLARE CURSOR Statements3-123.6.2CLOSE ON COMMIT Precompiler Option3-12v

3.7Using the ROLLBACK Statement3.7.1Statement-Level Rollbacks3-133.8Using the SAVEPOINT Statement3-143.9Using the RELEASE Option3-153.10Using the SET TRANSACTION Statement3-163.11Overriding Default Locking3-173.11.1Using the FOR UPDATE OF Clause3.11.1.13.12RestrictionsFetching Across Commits3.12.143-12Using the LOCK TABLE Statement3-173-173-183-183.13Handling Distributed Transactions3-193.14Guidelines for Transaction Processing3-193.14.1Designing Applications3-203.14.2Obtaining Locks3-203.14.3Using PL/SQL3-203.14.4X/Open Applications3-20Datatypes and Host Variables4.1The Oracle Database Datatypes4-14.1.1Internal Datatypes4-14.1.2External 4.1.2.10LONG RAW4-64.1.2.11LONG VARCHAR4-64.1.2.12LONG 18UNSIGNED4-74.1.2.19VARCHAR4-7vi

4-84.1.2.23SQL Pseudocolumns and Functions4-84.2Datetime and Interval Datatype Descriptors4-104.3Host Variables4-124.3.1Example strictions4-174.64-17Group Items as Host Variables4-184.3.2.2Restrictions4-19Indicator VariablesUsing Indicator Variables4-194-194.4.1.1On Input4-194.4.1.2On Output4-204.4.2Declaring Indicator Variables4-204.4.3Referencing Indicator Variables4-204.4.3.1Use in Where Clauses4-214.4.3.2Avoid Error Messages4-214.4.3.3ANSI Requirements4-214.4.3.4Indicator Variables for Multibyte NCHAR Variables4-224.4.3.5Indicator Variables with Host Group Items4-22VARCHAR Variables4-224.5.1Declaring VARCHAR Variables4-224.5.2Implicit VARCHAR Group Items4-234.5.3Referencing VARCHAR Variables4-24Handling Character Data4-254.6.1Default for PIC X4-254.6.2Effects of the PICX Option4-254.6.3Fixed-Length Character Variables4-254.6.3.1On Input4-254.6.3.2On Output4-264.6.44.7Referencing Host ng Host VariablesVarying-Length Variables4-264.6.4.1On Input4-274.6.4.2On Output4-27Universal ROWIDs4.7.1Subprogram SQLROWIDGET4-274-294.8Globalization Support4-304.9Unicode Support for Pro*COBOL4-31vii

4.9.1NLS LOCAL YES Restrictions4-324.9.2Character Strings in Embedded SQL4-324.9.3Embedded DDL4-334.9.4Blank Padding4-334.9.5Indicator Variables4-334.9.6Various Combinations of PIC X/PIC N Variables and NCHAR/CHARColumns4-344.9.6.1PIC X and NCHAR Column4-344.9.6.2PIC N and CHAR column4-344.9.75Working With New Options4-344.10Datatype Conversion4-354.11Explicit Control Over DATE String Format4-374.12Datatype Equivalencing4-384.12.1Usefulness of Equivalencing4-384.12.2Host Variable Equivalencing4-384.12.2.1CONVBUFSZ Clause in VAR Statement4-404.12.2.2An Example4-404.12.3Using the CHARF Datatype Specifier4-424.12.4Guidelines4-424.12.5RAW and LONG RAW Values4-434.13Platform Endianness Support4-434.14Sample Program 4: Datatype Equivalencing4-44Embedded SQL5.1Using Host Variables5.1.15.25.3Output Versus Input Host VariablesUsing Indicator Variables5-15-15-25.2.1Input Variables5-25.2.2Output Variables5-35.2.3Inserting NULLs5-35.2.4Handling Returned NULLs5-45.2.5Fetching NULLs5-45.2.6Testing for NULLs5-45.2.7Fetching Truncated Values5-5The Basic SQL Statements5.3.1Selecting Rows5.3.1.1Available Clauses5-55-65-75.3.2Inserting Rows5-75.3.3DML Returning Clause5-75.3.4Using Subqueries5-85.3.5Updating Rows5-8viii

5.45.55.3.6Deleting Rows5-85.3.7Using the WHERE Clause5-9Cursors5.4.1Declaring a Cursor5-105.4.2Opening a Cursor5-115.4.3Fetching from a Cursor5-115.4.4Closing a Cursor5-125.4.5Using the CURRENT OF Clause5-125.4.6Restrictions5-135.4.7A Typical Sequence of Statements5-135.4.8Positioned Update5-145.4.9The PREFETCH Precompiler Option5-14Scrollable Cursors5.5.1Using Scrollable Cursors5-155-155.5.1.1DECLARE SCROLL OSE5-165.5.2The CLOSE ON COMMIT Precompiler Option5-165.5.3The PREFETCH Precompiler Option5-165.6Flexible B Area Length5-175.7Fix Execution Plans5-185.7.1SQL File5.7.1.15.7.25.865-9ExamplesLOG FileSample Program 2: Cursor Operations5-205-215-225-23Embedded PL/SQL6.1Embedding PL/SQL6.1.1Host Variables6-16.1.2VARCHAR Variables6-16.1.3Indicator Variables6-26.1.3.1Handling NULLs6-26.1.3.2Handling Truncated Values6-26.1.46.26-1SQLCHECK6-2Advantages of PL/SQL6-26.2.1Better Performance6-26.2.2Integration with Oracle6-36.2.3Cursor FOR Loops6-36.2.4Subprograms6-3ix

6.2.4.1Parameter Modes6-46.2.5Packages6-46.2.6PL/SQL Tables6-46.2.7User-Defined Records6-56.3Embedding PL/SQL Blocks6-66.4Host Variables and PL/SQL6-66.4.1PL/SQL Examples6-66.4.2A More Complex PL/SQL Example6-76.4.3VARCHAR Pseudotype6-96.5Indicator Variables and PL/SQL6-96.5.1Handling NULLs6-106.5.2Handling Truncated Values6-106.6Host Tables and PL/SQL6.6.1ARRAYLEN Statement6.6.1.1Optional Keyword EXECUTE to ARRAYLEN Statement6-116-126-136.7Cursor Usage in Embedded PL/SQL6-156.8Stored PL/SQL and Java Subprograms6-166.8.1Creating Stored Subprograms6-166.8.2Calling a Stored PL/SQL or Java Subprogram6-176.8.2.1Anonymous PL/SQL Block6-176.8.2.2CALL Statement6-176.8.2.3CALL Example6-186.8.3Using Dynamic PL/SQL6-196.8.4Subprograms Restriction6-196.9Sample Program 9: Calling a Stored Procedure6.9.16.10Remote AccessCursor Variables6-196-236-236.10.1Declaring a Cursor Variable6-246.10.2Allocating a Cursor Variable6-246.10.3Opening a Cursor Variable6-246.10.3.1Opening Indirectly through a Stored PL/SQL Procedure6-256.10.3.2Opening Directly from Your Pro*COBOL Application6-266.10.4Fetching from a Cursor Variable6-266.10.5Closing a Cursor Variable6-276.10.6Freeing a Cursor Variable6-276.10.7Restrictions on Cursor Variables6-276.10.8Sample Program 11: Cursor E11.PCO6-28x

7Host Tables7.1Host Tables7-17.2Advantages of Host Tables7-17.3Tables in Data Manipulation Statements7-27.3.1Declaring Host Tables7.3.1.1Restrictions7-27.3.2Referencing Host Tables7-37.3.3Using Indicator Tables7-47.3.4Host Group Item Containing Tables7-47.3.5Oracle Restrictions7-57.3.6ANSI Restriction and Requirements7-57.4Selecting into Tables7-57.4.1Batch Fetches7-67.4.2Using SQLERRD(3)7-67.4.3Number of Rows Fetched7-67.4.4Restrictions on Using Host Tables7-77.4.5Fetching NULLs7-77.4.6Fetching Truncated Values7-87.4.7Sample Program 3: Fetching in Batches7-87.5Inserting with Tables7.5.17.6Restrictions on Host TablesUpdating with Tables7.6.17.7Restrictions in UPDATEDeleting with Tables7.7.1Restrictions in DELETE7-107-107-117-117-127-127.8Using Indicator Tables7-127.9The FOR Clause7-137.9.187-2Restrictions7-147.9.1.1In a SELECT Statement7-147.9.1.2With the CURRENT OF Clause7-147.10The WHERE Clause7-147.11Mimicking the CURRENT OF Clause7-157.12Tables of Group Items as Host Variables7-167.13Sample Program 14: Tables of Group Items7-177.14Additional Array Insert/Select Syntax7-197.15Using Implicit Buffered Insert7-25Error Handling and Diagnostics8.1Why Error Handling is Needed8-18.2Error Handling Alternatives8-1xi

8.2.1SQLCA8-28.2.2ORACA8-28.2.3ANSI SQLSTATE Variable8-28.2.4Declaring SQLSTATE8-38.2.4.18.3SQLSTATE ValuesUsing the SQL Communications Area8-38-68.3.1Contents of the SQLCA8-68.3.2Declaring the SQLCA8-78.3.3Key Components of Error Reporting8-78.3.3.1Status Codes8-78.3.3.2Warning Flags8-78.3.3.3Rows-Processed Count8-78.3.3.4Parse Error Offset8-78.3.3.5Error Message Text8-88.3.4SQLCA .4.6SQLWARN8-108.3.4.7SQLEXT8-118.3.5PL/SQL Considerations8-118.3.6Getting the Full Text of Error Messages8-118.3.7DSNTIAR8-128.3.8WHENEVER G8-138.3.8.3SQLERROR8-138.3.8.4NOT FOUND or .3.8.7DO CALL8-148.3.8.8DO PERFORM8-148.3.8.9GOTO or GO TO8-148.3.8.108.3.9STOPCoding the WHENEVER Statement8-148-158.3.9.1DO PERFORM8-158.3.9.2DO CALL8-168.3.9.3Scope8-178.3.9.4Careless Usage: Examples8-17xii

8.3.108.4Using the Oracle Communications Area8-19Contents of the ORACA8-208.4.2Declaring the ORACA8-208.4.3Enabling the ORACA8-208.4.4Choosing Runtime Options8-218.4.5ORACA .4.5.11Cursor Cache 8-238.4.5.17ORANEX8-24ORACA Example Program8-24How Errors Map to SQLSTATE Codes8-258.5.198-188.4.18.4.68.5Getting the Text of SQL StatementsStatus Variable Combinations8-30Oracle Dynamic SQL9.1Dynamic SQL9-19.2Advantages and Disadvantages of Dynamic SQL9-29.3When to Use Dynamic SQL9-29.4Requirements for Dynamic SQL Statements9-29.5How Dynamic SQL Statements Are Processed9-39.6Methods for Using Dynamic SQL9-39.6.1Method 19-39.6.2Method 29-49.6.3Method 39-49.6.4Method 49-49.6.5Guidelines9-5xiii

9.6.5.19.7Using Method 19-59-69.7.1The EXECUTE IMMEDIATE Statement9-69.7.2An Example9-79.8Sample Program 6: Dynamic SQL Method 19.9Using Method 29.9.1The USING Clause9-89-109-119.10Sample Program 7: Dynamic SQL Method 29-119.11Using Method -159.11.4FETCH9-159.11.5CLOSE9-169.12Sample Program 8: Dynamic SQL Method 39-169.13Using Oracle Method 49-189.13.1Need for the SQLDA9-199.13.2The DESCRIBE Statement9-199.13.3SQLDA Contents9-209.13.4Implementing Method 49-209.14Using the DECLARE STATEMENT Statement9-219.15Using Host Tables9-229.16Using PL/SQL9-229.16.1With Method 19-229.16.2With Method 29-229.16.3With Method 39-239.16.4With Method 49-239.16.5Caution9-239.17Part II10Avoiding Common ErrorsDynamic SQL Statement Caching9-23ApplicationsANSI Dynamic SQL10.1Basics of ANSI Dynamic SQL10.1.1Precompiler Options10-110-210.2Overview of ANSI SQL Statements10-210.3Sample Code10-510.4Oracle Extensions10-610.4.1Reference Semantics10-610.4.2Using Tables for Bulk Operations10-7xiv

10.5ANSI Dynamic SQL Precompiler Options10.6Full Syntax of the Dynamic SQL Statements10.6.1ALLOCATE Examples10-1110.6.2DEALLOCATE DESCRIPTOR10-1110.6.3GET DESCRIPTOR10-1210.6.4SET DESCRIPTOR10-1410.6.4.1Example10-1610.6.5Use of PREPARE10-1610.6.6DESCRIBE INPUT10-1710.6.7DESCRIBE OUTPUT10-1710.6.8EXECUTE10-1810.6.9Use of EXECUTE IMMEDIATE10-1910.6.10Use of DYNAMIC DECLARE CURSOR10-1910.6.11OPEN Cursor10-2010.6.12FETCH10-2110.6.13CLOSE a Dynamic Cursor10-2110.6.14Differences From Oracle Dynamic Method 410-2210.6.15Restrictions10-2210.71110-9Sample Programs: SAMPLE12.PCO10-23Oracle Dynamic SQL: Method 411.1Meeting the Special Requirements of Method 411-111.1.1Advantages of Method 411-211.1.2Information the Database Needs11-211.1.3Where the Information is Stored11-211.1.4How Information is Obtained11-311.2Understanding the SQL Descriptor Area (SQLDA)11-311.2.1Purpose of the SQLDA11-311.2.2Multiple SQLDAs11-411.2.3Declaring a SQLDA11-411.3The SQLDA Variables11.4Prerequisite Knowledge11-611-1111.4.1Using SQLADR11-1111.4.2Converting Data11-1211.4.3Coercing Datatypes11-1511.4.4Handling NULL/Not NULL Datatypes11-1811.5The Basic Steps11-1811.6A Closer Look at Each Step11-19xv

1211.6.1Declare a Host String11-2011.6.2Declare the SQLDAs11-2011.6.3Set the Maximum Number to DESCRIBE11-2111.6.4Initialize the Descriptors11-2111.6.5Store the Query Text in the Host String11-2311.6.6PREPARE the Query from the Host String11-2311.6.7DECLARE a Cursor11-2411.6.8DESCRIBE the Bind Variables11-2411.6.9Reset Number of Place-Holders11-2511.6.10Get Values for Bind Variables11-2611.6.11OPEN the Cursor11-2711.6.12DESCRIBE the Select List11-2811.6.13Reset Number of Select-List Items11-2911.6.14Reset Length/Datatype of Each Select-List Item11-2911.6.15FETCH Rows from the Active Set11-3111.6.16Get and Process Select-List Values11-3211.6.17CLOSE the Cursor11-3211.7Using Host Tables with Method 411-3311.8Sample Program 10: Dynamic SQL Method 411-36Multithreaded Applications12.1Introduction to Threads12-112.2Runtime Contexts in Pro*COBOL12-212.3Runtime Context Usage Models12-312.3.1Multiple Threads Sharing a Single Runtime Context12-312.3.2Multiple Threads Sharing Multiple Runtime Contexts12-412.4User Interface Features for Multithreaded Applications12-512.4.1THREADS Option12-512.4.2Embedded SQL Statements and Directives for Runtime Contexts12-612.4.2.1Host Tables of SQL-CONTEXT Are Not Allowed12-612.4.2.2EXEC SQL ENABLE THREADS12-612.4.2.3EXEC SQL CONTEXT ALLOCATE12-612.4.2.4EXEC SQL CONTEXT USE12-712.4.2.5EXEC SQL CONTEXT FREE12-712.4.3Communication with Pro*C/C Programs12-712.4.4Multithreading Programming Considerations12-712.4.4.112.4.5Restrictions on MultithreadingMultiple Context Examples12-812-812.4.5.1Example 112-812.4.5.2Example 212-8xvi

12.51312.4.5.3Example 312-912.4.5.4Example 412-1012.4.5.5Example 512-11Multithreaded Example12-12Large Objects (LOBs)13.1Using LOBs13-113.1.1Internal LOBs13-113.1.2External LOBs13-113.1.3Security for BFILEs13-213.1.4LOBs Compared with LONG and LONG RAW13-213.1.5LOB Locators13-213.1.6Temporary LOBs13-313.1.7LOB Buffering Subsystem13-313.2How to Use LOBs13-313.2.1LOB Locators in Your Application13-513.2.2Initializing a LOB13-513.313.2.2.1Internal LOBs13-513.2.2.2External LOBs13-513.2.2.3Temporary LOBs13-613.2.2.4Freeing LOBs13-6Rules for LOB Statements13-613.3.1For All LOB Statements13-613.3.2For the LOB Buffering Subsystem13-713.3.3For Host Variables13-713.4LOB .3CLOSE13-913.4.4COPY13-1013.4.5CREATE TEMPORARY13-1113.4.6DISABLE BUFFERING13-1113.4.7ENABLE BUFFERING13-1213.4.8ERASE13-1213.4.9FILE CLOSE ALL13-1313.4.10FILE SET13-1313.4.11FLUSH BUFFER13-1413.4.12FREE TEMPORARY13-1413.4.13LOAD FROM FILE13-1413.4.14OPEN13-15xvii

3.4.18DESCRIBE13-1913.4.19READ and WRITE Using the Polling Method13-2213.514LOB Sample Program: LOBDEMO1.PCO13-23Precompiler Options14.1The procob Command14.1.1Case-Sensitivity14-114-214.2Actions During Precompilation14-214.3About the Options14-214.3.1Precedence of Option Values14-314.3.2Macro and Micro Options14-414.3.3Determining Current Values14-414.4Entering Precompiler Options14-514.4.1On the Command .2.2Scope of EXEC ORACLE14-614.4.3Configuration Files14-614.4.4Column Properties Support14-714.5Scope of Precompiler Options14-814.6Quick Reference14-914.7Using Pro*COBOL Precompiler Options14-1114.7.1ASACC14-1114.7.2ASSUME SQLCODE14-1214.7.3AUTO CONNECT14-1214.7.4CHARSET PICX14-1314.7.5CHARSET PICN14-1314.7.6CLOSE ON COMMIT14-1414.7.7COMMON PARSER14-1414.7.8CONFIG14-1514.7.9DATE FORMAT14-1514.7.10DB2 ARRAY14-1614.7.11DBMS14-1614.7.12DECLARE 4.7.15END OF FETCH14-18xviii

14.7.16ERRORS14-1914.7.17File LD CURSOR14-2114.7.21HOST14-2214.7.22IMPLICIT 514.7.28LRECLEN14-2514.7.29LTYPE14-2614.7.30MAX ROW NLS 14-3214.7.41PAGELEN14-3214.7.42PICN ENDIAN14-3314.7.43PICX14-3314.7.44PLAN BASELINE14-3414.7.45PLAN PREFIX14-3414.7.46PLAN RUN14-3514.7.47PLAN FIXED14-3514.7.48PLAN TCH14-3614.7.51RELEASE CURSOR14-3714.7.52RUNOUTLINE14-3814.7.53SELECT ERROR14-3914.7.54SQLCHECK14-3914.7.55STMT CACHE14-4214.7.56TYPE CODE14-43xix

ACUNSAFE .60XREF14-44Operating System DependenciesA.1B14.7.57System-Specific References in this ManualA-1A.1.1COBOL VersionsA-1A.1.2Host .3INCLUDE StatementsA-2A.1.4MAXLITERAL DefaultA-2A.1.5PIC N or Pic G Clause for Multi-byte Globalization Support CharactersA-2A.1.6RETURN-CODE Special Register May Be Unpredictable.A-2A.1.7Byte-Order of Binary DataA-2Reserved Words, Keywords, and NamespacesB.1Reserved Words and KeywordsB-1B.2Reserved NamespacesB-4Performance TuningC.1Causes of Poor PerformanceC-1C.2Improving PerformanceC-2C.3Using Host TablesC-2C.4Using PL/SQL and JavaC-3C.5Optimizing SQL StatementsC-3C.5.1Optimizer HintsC.5.1.1C-4Giving HintsC-4C.6SQL Statement CachingC-4C.7Using IndexesC-5C.8Taking Advantage of Row-Level LockingC-5C.9Eliminating Unnecessary ParsingC-5C.9.1Handling Explicit CursorsC.9.1.1C.9.2Cursor ControlUsing the Cursor Management OptionsC-6C-6C-7C.9.2.1Private SQL Areas and Cursor CacheC-7C.9.2.2Resource UseC-8C.9.2.3Infrequent ExecutionC-8xx

DC.9.2.4Frequent ExecutionC-9C.9.2.5Effect on the Shared SQL AreaC-9C.9.2.6Embedded PL/SQL ConsiderationsC-9C.9.2.7Parameter InteractionsC-10C.10Avoiding Unnecessary ReparsingC-10C.11About Using Oracle Connection Manager in Traffic Director ModeC-10Syntactic and Semantic CheckingD.1Syntactic and Semantic Checking BasicsD-1D.2Controlling the Type and Extent of CheckingD-1D.3Specifying SQLCHECK SEMANTICSD-2D.3.1EEnabling a Semantic CheckD-2D.3.1.1Connecting to OracleD-2D.3.1.2Using DECLARE TABLED-3Embedded SQL Statements and Precompiler DirectivesE.1Summary of Precompiler Directives and Embedded SQL StatementsE-3E.2About the Statement DescriptionsE-5E.3How to Read Syntax DiagramsE-5E.3.1Statement TerminatorE-6E.3.2Required Keywords and ParametersE-6E.3.3Optional Keywords and ParametersE-7E.3.4Syntax LoopsE-7E.3.5Multi-part DiagramsE-7E.3.6Oracle NamesE-8E.4ALLOCATE (Executable Embedded SQL Extension)E-8E.5ALLOCATE DESCRIPTOR (Executable Embedded SQL)E-9E.6CALL (Executable Embedded SQL)E-10E.7CLOSE (Executable Embedded SQL)E-11E.8COMMIT (Executable Embedded SQL)E-12E.9CONNECT (Executable Embedded SQL Extension)E-14E.10CONTEXT ALLOCATE (Executable Embedded SQL Extension)E-15E.11CONTEXT FREE (Executable Embedded SQL Extension)E-16E.12CONTEXT USE (Oracle Embedded SQL Directive)E-17E.13DEALLOCATE DESCRIPTOR (Embedded SQL Statement)E-18E.14DECLARE CURSOR (Embedded SQL Directive)E-19E.15DECLARE DATABASE (Oracle Embedded SQL Directive)E-21E.16DECLARE STATEMENT (Embedded SQL Directive)E-22E.17DECLARE TABLE (Oracle Embedded SQL Directive)E-23xxi

E.18DELETE (Executable Embedded SQL)E-24E.19DESCRIBE (Executable Embedded SQL)E-27E.20DESCRIBE DESCRIPTOR (Executable Embedded SQL)E-29E.21ENABLE THREADS (Executable Embedded SQL Extension)E-30E.22EXECUTE . END-EXEC (Executable Embedded SQL Extension)E-31E.23EXECUTE (Executable Embedded SQL)E-32E.24EXECUTE DESCRIPTOR (Executable Embedded SQLE-33E.25EXECUTE IMMEDIATE (Executable Embedded SQL)E-35E.26FETCH (Executable Embedded SQL)E-36E.27FETCH DESCRIPTOR (Executable Embedded SQL)E-39E.28FREE (Executable Embedded SQL Extension)E-40E.29GET DESCRIPTOR (Executable Embedded SQL)E-41E.30INSERT (Executable Embedded SQL)E-43E.31LOB APPEND (Executable Embedded SQL Extension)E-46E.32LOB ASSIGN (Executable Embedded SQL Extension)E-46E.33LOB CLOSE (Executable Embedded SQL Extension)E-47E.34LOB COPY (Executable Embedded SQL Extension)E-47E.35LOB CREATE TEMPORARY (Executable Embedded SQL Extension)E-48E.36LOB DESCRIBE (Executable Embedded SQL Extension)E-49E.37LOB DISABLE BUFFERING (Executable Embedded SQL Extension)E-50E.38LOB ENABLE BUFFERING (Executable Embedded SQL Extension)E-50E.39LOB ERASE (Executable Embedded SQL Extension)E-51E.40LOB FILE CLOSE ALL (Executable Embedded SQL Extension)E-51E.41LOB FILE SET (Executable Embedded SQL Extension)E-52E.42LOB FLUSH BUFFER (Executable Embedded SQL Extension)E-52E.43LOB FREE TEMPORARY (Executable Embedded SQL Extension)E-53E.44LOB LOAD (Executable Embedded SQL Extension)E-53E.45LOB OPEN (Executable Embedded SQL Extension)E-54E.46LOB READ (Executable Embedded SQL Extension)E-54E.47LOB TRIM (Executable Embedded SQL Extension)E-55E.48LOB WRITE (Executable Embedded SQL Extension)E-55E.49OPEN (Executable Embedded SQL)E-56E.50OPEN DESCRIPTOR (Executable Embedded SQL)E-57E.51PREPARE (Executable Embedded SQL)E-59E.52ROLLBACK (Executable Embedded SQL)E-60E.53SAVEPOINT (Executable Embedded SQL)E-63E.54SELECT (Executable Embedded SQL)E-64E.55SET DESCRIPTOR (Executable Embedded SQL)E-67E.56UPDATE (Executable Embedded SQL)E-68E.57VAR (Oracle Embedded SQL Directive)E-72xxii

E.58FWHENEVER (Embedded SQL Directive)E-73Pro*COBOL for WindowsF.1F.2Compiling and Linking Pro*COBOL ApplicationsF-1F.1.1How to Use the IDEF-1F.1.2How to Use the Animator ProductsF-2F.1.3The COBOL and CBLLINK CommandsF-2F.1.4The COBSQL CommandF-2Sample ProgramsF-3F.2.1Building the Demonstration TableF-3F.2.2Building the Sample ProgramsF-3F.2.3Sample FilesF-4Indexxxiii

List of Tables1-1Directories1-51-2Header Files1-62-1Embedded SQL Statements — Directives2-32-2Embedded SQL Statements — Executable SQL2-32-3Relational Operators4-1Summary of Oracle Built-In Datatypes4-24-2External Datatypes4-34-3Date Format4-54-4Pseudocolumns and Internal Datatypes4-94-5Functions and Internal Datatypes4-94-6Host Variable Declarations4-124-7Compatible Oracle Internal Datatypes4-154-8Globalization Support Parameters4-304-9Conversions Between Internal and External Datatypes4-364-10Formats for Date Strings4-374-11Host Variable Equivalencing4-394-12Parameters for Host Variable Equivalencing4-414-13VARNUM Examples4-426-1Legal Datatype Conversions6-127-1Host Tables Valid in SELECT INTO7-2Host Tables Valid in UPDATE7-117-3DB2 Array Syntax vs. Oracle Precompiler Syntax7-218-1Predefined Classes8-2DSNTIAR Error Codes and Their Meanings8-138-3Parameter Datatypes8-198-4SQLSTATE Codes8-268-5Status Variable Behavior with ASSUME SQLCODE NO and MODE ANSI ANSI14and DECLARE SECTION YES8-62-157-78-48-30Status Variable Behavior with ASSUME SQLCODE YES and MODE ANSI ANSI14 and DECLARE SECTION YES8-319-1Appropriate Method to Use9-310-1ANSI SQL Datatypes10-410-2DYNAMIC Option Settings10-910-3TYPE CODE Option Settings10-1010-4Definitions of Descriptor Item Names10-13xxiv

10-5Oracle Extensions to Definitions of Descriptor Item Names10-1310-6Descriptor Item Names for SET DESCRIPTOR10-1510-7Extensions to Descriptor Item Names for SET DESCRIPTOR10-1511-1Internal Datatypes and Related Codes11-1311-2Oracle External and Related COBOL Datatypes11-1311-3PL/SQL Datatype Equivalences with Internal Datatypes11-1411-4Datatype Exceptions to the SQLPR2 Procedure11-1713-1LOB Access M

Pro*COBOL Features and Benefits1-4. Directory Structure1-5. Header Files1-6. Library File1-6. Known Problems, Restrictions, and Workarounds 1-6. Compatibility, Upgrading, and Migration1-7. Precompiler Concepts. Key Concepts of Embedded SQL Programming 2-1. Steps in Developing an Embedded SQL Application 2-1.