HPlogo ALLBASE/SQL FORTRAN Application Programming Guide: HP 9000 Computer Systems > Chapter 2 Using The ALLBASE/SQL FORTRAN Preprocessor

Invoking the Fortran Preprocessor

» 

Technical documentation

» Feedback

 » Table of Contents

 » Index

The FORTRAN preprocessor can be invoked in either of the following modes:

  • Syntax checking mode.

  • Full preprocessing mode.

This chapter describes how to use all the preprocessor's options, and it describes the inputs and outputs of the preprocessor command.

An example of a source file and its corresponding modified source file and preprocessor generated include file are presented.

Syntax Checking Mode

You use the following command to only check the syntax of the SQL commands embedded in the SourceFileName.sql.

Syntax

psqlfor -s [-i SourceFileName] [-p ModifiedSourceFileName] |...|

Parameters

-s

causes the preprocessor to only check SQL syntax.

-i SourceFileName

identifies the name of the input file containing the source code to be preprocessed. It is recommended that the source file have a file extension of .sql for filename clarity; however, using a suffix is not required.

-p ModifiedSourceFileName

identifies the name of the output file containing the preprocessor generated modified source code. If ModifiedSourceFileName is specified using the -p option in the option list the FORTRAN compiler requires the .f suffix to be included. If ModifiedSourceFileName is not specified in the option list, the preprocessor generated code is written to a file with the same name as the source file name but with the .f appended file extension.

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 FORTRAN constructs. Therefore the modified source code file does not contain any preprocessor generated calls to ALLBASE/SQL external procedures.

  • The include and installable module files are created, but incomplete.

Authorization

You do not need ALLBASE/SQL authorization when you use the preprocessor to only check SQL syntax.

Example

$ psqlfor -s -i mysource

   

                                MON, JUL 10, 1991,  4:48 PM

HP36217-02A.E1.00   FORTRAN Preprocessor/9000   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.



$ more sqlmsg

                                MON, JUL 10, 1991,  4:48 PM

HP36217-02A.E1.00   FORTRAN Preprocessor/9000   ALLBASE/SQL 

(C) COPYRIGHT HEWLETT-PACKARD CO. 1982,1983,1984,1985,1986,

1987,1988,1989. ALL RIGHTS RESERVED.



       SELCT PartNumber, PartName, SalesPrice

  INTO :PartNumber, :PartName :PartNameInd,

  :SalesPrice :SalesPriceInd FROM PurchDB.Parts

  WHERE PartNumber = :PartNumber;



****** ALLBASE/SQL errors.  (DBERR 10977)

****** in SQL statement ending in line 128

***    <1001> Syntax error.  (DBERR 1001)



Syntax checked.



  1 ERRORS   0 WARNINGS

END OF PREPROCESSING



The line 128 referenced in sqlmsg is the line in

mysource where the erroneous SQL command ends.

Full Preprocessing Mode

You use the following command to both check SQL syntax and create a modified source code output file from the input source file that can be compiled by the FORTRAN compiler. This command also stores a module in the DBEnvironment named and creates a file containing an installable version of the module.

Syntax

psqlfor DBEnvironmentName [-i SourceFileName] [-p ModifiedSourceFileName] [-o OwnerName] [-m ModuleName] [-d [-r] ] |...|

Parameters

DBEnvironmentName

identifies the DBEnvironment in which a module is to be stored.

-i SourceFileName

identifies the name of the input file containing the source code to be preprocessed. It is recommended that the source file have a file extension of .sql for file name clarity; however, this is not required.

-p ModifiedSourceFile Name

identifies the name of the output file containing the preprocessor generated modified source code. If ModifiedSourceFileName.f is specified by the user in the option list, the FORTRAN compiler requires the .f suffix to be included. If a module name is not specified with the -p option, the preprocessor uses the ModifiedSourceFileName as the module name. If a module name is not specified without the -p option, the preprocessor uses the SourceFileName as the module name.

-o OwnerName

associates the stored module with a user's userid, a class name, or a group name. 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, by default the owner name is your userid. Any object names found in the source file that are not qualified with an owner name are qualified with this owner name.

-m 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 Statement name as the module name.

-d

deletes any module currently stored in the DBEnvironment by the module name and owner name specified in the options list. If the -d option is not specified and the preprocessor tries to create a module with the same owner name and module name as those associated with a module already stored, preprocessing terminates with an error condition.

-r

is specified when the program being preprocessed already has a stored module and you want to revoke existing RUN authorities for that module. The -r option cannot be specified unless the -d option is also specified. If the -r option is not specified, nodrop is assumed and all existing RUN authorities for that module are to be preserved.

Description

  1. When the program being preprocessed already has a stored module, be sure to use the -d option, or else an error will result. Also, be sure that no one is currently executing the module when you invoke the preprocessor. To avoid conflicts, do your preprocessing in single-user mode, during off hours.

  2. The preprocessor starts a DBE session in the DBEnvironment named in the preprocessor 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.

  3. 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.

  4. 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.

  5. 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 rollback logging is 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.

  6. 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. Therefore minimize competing transactions when preprocessing an application program. Refer to the ALLBASE/SQL Database Administration Guide for information on operations that lock system catalog pages.

  7. 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.

  8. If you specify an OwnerName or ModuleName in a language other than n-computer (ASCII), be sure that the language you are using is also the language of the DBEnvironment in which the module will be stored.

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



$ psqlfor ../sampledb/PartsDBE -o joann -m joannpgm -i prog1.sql -d -r



                                MON, JUL 10, 1991,  4:48 PM

HP36217-02A.E1.00   FORTRAN Preprocessor/9000   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.



$ more sqlmsg



                                MON, JUL 10, 1991,  4:48 PM

HP36217-02A.E1.00   FORTRAN Preprocessor/9000   ALLBASE/SQL 

(C) COPYRIGHT HEWLETT-PACKARD CO. 1982,1983,1984,1985,1986,

1987,1988,1989,1990,1991. ALL RIGHTS RESERVED.



DBEnvironment        = ../sampledb/PartsDBE



Module Name          = JOANNPGM



******  SELECT PartNumber, PartName, SalesPrice INTO :PartNumber, :PartName,

     :SalesPrice WHERE PartNumber = :PartNumber

******  ALLBASE/SQL warnings.  (DBERR 10602)           |

******  User joann does not have SELECT authority on PurchDB.Parts

(DBERR 2301)

  1 Sections stored in DBEnvironment.



  0 ERRORS   1 WARNINGS

END OF PROCESSING



$


Feedback to webmaster