HP 3000 Manuals

Invoking the COBOL Preprocessor [ ALLBASE/SQL COBOL Application Programming Guide ] MPE/iX 5.0 Documentation


ALLBASE/SQL COBOL Application Programming Guide

Invoking the COBOL Preprocessor 

The COBOL preprocessor can be invoked to either

   *   Only check the syntax of embedded SQL commands, or

   *   Check the syntax of embedded SQL commands, create compilable
       output, store a module in a DBEnvironment, and create an
       installable module file.

Syntax Checking Mode 

You use the following RUN command to only check the syntax of the SQL
commands embedded in a file equated to SQLIN.

     :RUN PSQLCOB.PUB.SYS;INFO="(SYNTAX)"

Description.   

   *   The preprocessor does not access a DBEnvironment when it is run in
       this mode.

   *   When performing only syntax checking, the preprocessor does not
       convert the SQL commands into COBOL statements.  Therefore SQLOUT
       does not contain any preprocessor generated calls to ALLBASE/SQL
       external procedures.

   *   SQLCONST, SQLVAR, and SQLMOD are created, but are incomplete.

Authorization.   

You do not need ALLBASE/SQL authorization when you use the preprocessor
to only check SQL syntax.  In other words, the tables that store who has
DBA, RESOURCE, and OWNER privileges on tables are not checked.

Example.   

     :FILE SQLIN=COBEX2 
     :RUN PSQLCOB.PUB.SYS;INFO="(SYNTAX)" 

                                               WED, OCT 25, 1991,  1:38 PM
     HP36216-E1.02          COBOL Preprocessor/3000            ALLBASE/SQL
     (C) COPYRIGHT HEWLETT-PACKARD CO. 1982,1983,1984,1985,1986,1987,1988,
     1989,1990,1991. ALL RIGHTS RESERVED.

     Syntax checked.
      1 ERRORS     0 WARNINGS
     END OF PREPROCESSING.

     PROGRAM TERMINATED IN AN ERROR STATE.  (CIERR 976)
     :EDITOR
     HP32501A.07.20 EDIT/3000 FRI, OCT 27, 1991,  9:35 AM
     (C) HEWLETT-PACKARD CO. 1990
     /T SQLMSG;L ALL UNN
     FILE UNNUMBERED

                   .
                   .
                   .
     SQLIN                = COBEX2.SOMEGRP.SOMEACCT

             SELECT PARTNUMBER, PARTNAME, SALESPRICE INTO :PARTNUMBER, :PARTNAME,
             :SALESPRICE :SALESPRICEIND, FROM PURCHDB.PARTS WHERE PARTNUMBER =
             :PARTNUMBER ;

     ******  ALLBASE/SQL errors (DBERR 10977)
     ******  in SQL statement ending in line 176
     ***     Unexpected keyword.  (DBERR 1006)

     Syntax checked.

      1 ERRORS   0 WARNINGS
     END OF PREPROCESSING.

     /

          The line 176 referenced in SQLMSG is the line in 
          SQLIN where the erroneous SQL command ends. 

Full Preprocessing Mode 

You use the following RUN command to both check SQL syntax and create
output files from SQLIN that can be processed by the COBOL compiler.
This RUN command also stores a module in the DBEnvironment named and
creates a file containing an installable version of the module.

                                                {MODULE(ModuleName)}
                                                {OWNER (OwnerName) }
:RUN PSQLCOB.PUB.SYS;INFO= "DBEnvironmentName [({{DROP {PRESERVE}} }
                                                {{     {REVOKE  }} }
                                                {{               } }
                                                {{NODROP         } }

|...|]"

Parameters.   

DBEnvironmentName       identifies the DBEnvironment in which a module is
                        to be stored.  You may use a backreference to a
                        file defined in a file equation for this
                        parameter.

ModuleName              assigns a name to the stored module.  Module
                        names must follow the rules governing ALLBASE/SQL
                        basic names as described in the ALLBASE/SQL 
                        Reference Manual.  If a module name is not
                        specified, the preprocessor uses the PROGRAM-ID
                        as the module name.

OwnerName               associates the stored module with a User 
                        @Account, a ClassName, or a GroupName.  You can
                        specify an owner name for the module only if you
                        have DBA authority in the DBEnvironment where the
                        module is to be stored.  If not specified, the
                        owner name is your log-on User @Account.  Any
                        object names in SQLIN not qualified with an owner
                        name are qualified with the OwnerName specified
                        by the preprocessor.

DROP                    deletes any module currently stored in the
                        DBEnvironment by the ModuleName and OwnerName 
                        specified in the INFO string.

NODROP                  terminates preprocessing if any module currently
                        exists in the DBEnvironment by the ModuleName and
                        OwnerName specified in the INFO string.  If not
                        specified, NODROP is assumed.

PRESERVE                is specified when the program being preprocessed
                        already has a stored module and you want to
                        preserve existing RUN authorities for that
                        module.  If not specified, PRESERVE is assumed.
                        PRESERVE cannot be specified unless DROP is also
                        specified.

REVOKE                  is specified when the program being preprocessed
                        already has a stored module and you want to
                        revoke existing RUN authorities for that module.
                        REVOKE cannot be specified unless DROP is also
                        specified.

Description.   

   *   Before invoking the preprocessor in this mode when the program
       being preprocessed already has a stored module, ensure that the
       earlier version of the program is not being executed.

   *   The preprocessor starts a DBE session in the DBEnvironment named
       in the RUN command by issuing a CONNECT TO 'DBEnvironmentName'
       command.  If the autostart flag is OFF, the DBE session can be
       initiated only after a START DBE command has been processed.

   *   If the DBEnvironment to be accessed is operating in single-user
       mode, preprocessing can occur only when another DBE session for
       the DBEnvironment does not exist.

   *   When the preprocessor's DBE session begins, ALLBASE/SQL processes
       a BEGIN WORK command.  When preprocessing is completed, the
       preprocessor submits a COMMIT WORK command, and any sections
       created are committed to the system catalog.  If the preprocessor
       detects an error in the source file, it processes a ROLLBACK WORK
       command before terminating, and no sections are stored in the
       DBEnvironment.  Preprocessor warnings do not prevent sections from
       being stored.

   *   Since all preprocessor DBE sessions initiate only one transaction,
       any log file space used by the session is not available for re-use
       until after the session terminates.  If rollforward logging is not
       in effect, you can issue the CHECKPOINT command in ISQL before 
       preprocessing to increase the amount of available log space.
       Refer to the ALLBASE/SQL Database Administration Guide for
       additional information on log space management, such as using the
       START DBE NEWLOG command to increase the size of the log and
       recovering log space when rollforward logging is in effect.

   *   During preprocessing, system catalog pages accessed for embedded
       commands are locked.  In multiuser mode, other DBE sessions
       accessing the same objects must wait, and the potential for a
       deadlock exists.  Refer to the ALLBASE/SQL Database Administration 
       Guide for information on operations that lock system catalog
       pages.

   *   For improved runtime performance, use ISQL to submit the UPDATE
       STATISTICS command before preprocessing for each table accessed in
       a data manipulation command when an index on that table has been
       added or dropped and when data in the table is often changed.

Authorization.   

To preprocess a program for the first time in this mode, you need CONNECT
or DBA authority in the DBEnvironment the program accesses.  After a
stored module exists, you need module OWNER or DBA authority in the
DBEnvironment.

Example.   

     :FILE SQLIN=COBEX2 
     :RUN PSQLCOB.PUB.SYS;INFO=& 
     "PartsDBE (MODULE(COBEX2) OWNER(OwnerP@SomeAcct) REVOKE DROP)" 

                                               WED, OCT 25, 1991,  1:38 PM
     HP36216-E1.02            COBOL Preprocessor/3000          ALLBASE/SQL
     (C) COPYRIGHT HEWLETT-PACKARD CO. 1982,1983,1984,1985,1986,1987,1988,
     1989,1990,1991. ALL RIGHTS RESERVED.

      0 ERRORS     1 WARNINGS
     END OF PREPROCESSING.

     END OF PROGRAM
     :EDITOR
     HP32501A.07.20 EDIT/3000 FRI, OCT 27, 1991,  10:17 AM
     (C) HEWLETT-PACKARD CO. 1990
     /T SQLMSG;L ALL UNN 
     FILE UNNUMBERED

                  .
                  .
                  .
     SQLIN                = COBEX2.SOMEGRP.SOMEACCT
     DBEnvironment        = partsdbe
     Module Name          = COBEX2

             SELECT PARTNUMBER, PARTNAME, SALESPRICE INTO :PARTNUMBER, :PARTNAME,
             :SALESPRICE :SALESPRICEIND FROM PURCHDB.PARTS WHERE PARTNUMBER =
             :PARTNUMBER ;

     ******  ALLBASE/SQL warnings (DBWARN 10602)
     ******  in SQL statement ending in line 133
     ***     User SomeUser@SomeAcct does not have SELECT authority on PURCHDB.PARTS.
     (DBERR 2301)

       1 Sections stored in DBEnvironment.

      0 ERRORS   1 WARNINGS
     END OF PREPROCESSING

     /

Using the Preprocessor UDC's 

Two UDC's for invoking the COBOL preprocessor are provided with
ALLBASE/SQL in the HPSQLUDC.PUB.SYS file:

   *   PCOB, illustrated in Figure 2-12, invokes the preprocessor in full
       preprocessing mode.  You specify the source file name, a
       DBEnvironment name, and a name for SQLMSG (if you do not want
       preprocessor messages to go to $STDLIST).

              :PCOB SourceFileName,DBEnvironment 

       The PCOB UDC uses the following preprocessor INFO string
       parameters:

              ModuleName is the name of the source file.

              OwnerName is the log-on User@Account.

              PRESERVE and DROP are in effect.

   *   PPCOB, illustrated in Figure 2-13, invokes the preprocessor in
       full preprocessing mode, then invokes the COBOL compiler if
       preprocessing is successful and the linker if compilation is
       successful.

To use this UDC, you specify the source file name, a DBEnvironment name,
and an executable file name.  You can specify a name for SQLMSG if you do
not want preprocessor messages to go to $STDLIST:

     :PPCOB SourceFileName,DBEnvironment,ExecutableFileName 

This UDC uses the following preprocessor INFO string parameters:

       ModuleName is the source file name.

       OwnerName is the log-on User@Account.

       PRESERVE and DROP are in effect.

If you make your own version of the UDC's, do not modify the record
attributes for any of the preprocessor output files.  Only modify the
file limit (disc=FileLimit) if required.


NOTE Because the UDC's purge the preprocessor message file, if messages are sent to $STDLIST an error message appears when you use the UDC's, but preprocessing continues.
________________________________________________________ | | | PCOB srcfile,dbefile,msgfile=$stdlist | | continue | | setvar _savefence hpmsgfence | | setvar hpmsgfence 2 | | continue | | purge !msgfile | | purge sqlout | | purge sqlmod | | purge sqlvar | | purge sqlconst | | setvar hpmsgfence _savefence | | deletevar _savefence | | file sqlin = !srcfile | | file sqlmsg = !msgfile; rec=-80,16,f,ascii | | file sqlout; disc=10000,32; rec=-80,16,f,ascii| | file sqlmod; disc=1023,10,1; rec=250,,f,binary | | file sqlvar; disc=2048,32; rec=-80,16,f,ascii| | file sqlconst; disc=2048,32; rec=-80,16,f,ascii| | continue | | run psqlcob.pub.sys;info="!dbefile (drop)" | | reset sqlin | | reset sqlmsg | | reset sqlout | | reset sqlmod | | reset sqlvar | | reset sqlconst | ________________________________________________________ Figure 2-12. UDC for Preprocessing SQLIN ________________________________________________________ | | | PPCOB srcfile,dbefile,pgmfile,msgfile=$stdlist | | continue | | setvar _savefence hpmsgfence | | setvar hpmsgfence 2 | | continue | | purge !msgfile | | purge sqlout | | purge sqlmod | | purge sqlvar | | purge sqlconst | | setvar hpmsgfence _savefence | | deletevar _savefence | | file sqlin = !srcfile | | file sqlmsg = !msgfile; rec=-80,16,f,ascii | | file sqlout; disc=10000,32; rec=-80,16,f,ascii| | file sqlmod; disc=1023,10,1; rec=250,,f,binary | | file sqlvar; disc=2048,32; rec=-80,16,f,ascii| | file sqlconst; disc=2048,32; rec=-80,16,f,ascii| | continue | | run psqlcob.pub.sys;info="!dbefile (drop)" | | if jcw <= warn then | | continue | | cob85xlk sqlout,!pgmfile,$null | | endif | | reset sqlin | | reset sqlmsg | | reset sqlout | | reset sqlmod | | reset sqlvar | | reset sqlconst | ________________________________________________________ Figure 2-13. UDC for Preprocessing, Compiling, and Preparing SQLIN The example in Figure 2-14 illustrates the use of PPCOB on an SQLIN that could be successfully preprocessed, but failed to compile because a COBOL error exists in the file. In addition to generating an error message for the COBOL error, the COBOL compiler generates several warning messages. The warning messages are normal and will not cause runtime problems; they are due to the way the COBOL preprocessor declares some of the variables in SQLVAR. ________________________________________________________________________________ | | | :PPCOB COBEX2,PARTSDBE,COBEX2P | | | | WED, OCT 25, 1991, 1:38 PM | | HP36216-E1.02 COBOL Preprocessor/3000 ALLBASE/SQL | | (C) COPYRIGHT HEWLETT-PACKARD CO. 1982,1983,1984,1985,1986,1987,1988, | | 1989,1990,1991. ALL RIGHTS RESERVED. | | | | SQLIN = COBEX2.SOMEGRP.SOMEACCT | | DBEnvironment = partsdbe | | | | | | Module Name = COBEX2 | | 1 Sections stored in DBEnvironment. | | | | 0 ERRORS 0 WARNINGS | | END OF PREPROCESSING. | | | | END OF PROGRAM | | | | PAGE 0001 COBOL II/XL HP31500A.03.00 [85] Copyright Hewlett-Pa... 1987 | | LINE # SEQ # COL ERROR SEV TEXT | | -------------------------------------------------------------------------| | 00048 08 051 W REDEFINING ITEM SQLREC1 IS SMALLER THAN | | REDEFINED ITEM. | | 00053 08 051 W REDEFINING ITEM SQLREC2 IS SMALLER THAN | | REDEFINED ITEM. | | 00055 08 051 W REDEFINING ITEM SQLREC3 IS SMALLER THAN | | REDFINED ITEM. | | | | 0 ERROR(s), 0 QUESTIONABLE, 3 WARNING(s) | | | | DATA AREA IS 580 BYTES. | | CPU TIME = 0.00:02. WALL TIME = 0:00:08. | | | | END OF PROGRAM | | END OF COMPILE | | HP Link Editor/XL (HP30315A.04.04) Copyright Hewlett-Packard Co 1986 | | | | LinkEd> link ;to=cobex2p | | | | END OF LINK | | | ________________________________________________________________________________ Figure 2-14. Sample UDC Invocation The line number referenced in the compiler output messages is the COBOL statement number in the compiler output listing. Because PPCOB sends the compiler output listing to $null, you must reinvoke the compiler, sending the compiler listing to an output file, to identify the line in error: :BUILD COBLIST;DISC=10000,32;REC=-80,16,F,ASCII :COB85XL SQLOUT,$OLDPASS,COBLIST The COBOL syntax error flagged in the example in Figure 2-14 appears as follows in COBLIST: 00261 DISPAY "SELECT PartNumber, PartName and SalesPrice". If you use TDP's COBOL mode to create SQLIN, the actual line number containing any COBOL error in SQLOUT appears in the SEQ column of the COBOL compiler message. Therefore you can use this approach to eliminate recompiling in order to identify the location of COBOL errors. In this case, the error is at line 15.7 in SQLOUT. LINE SEQ COL ERROR SEV TEXT ------------------------------------------------------------------- . . . 00261 015700 19 410 S SYNTAX ERROR. FOUND: SELECT PartNumber, PartName and SalesPrice; EXPECTING ONE OF THE FOLLOWING: . SECTION . . .


MPE/iX 5.0 Documentation