SQL/MP Programming Manual for COBOL

HP NonStop SQL/MP Programming Manual for COBOL529758-003
E-1
E Writing Pathway Servers
Writing a Pathway application that accesses a NonStop SQL/MP database is similar to
writing an application that accesses an Enscribe database. In either case, you manage
terminal requests and displays in the requester portion of the application and perform
database manipulation in the servers. When coding a Pathway application that
accesses an SQL/MP database, you embed the SQL DML statements in the server
code.
Most Pathway servers use subroutines. Subroutines are efficient because they reduce
the amount of coding to a minimum. Also, subroutines separate the database
manipulation operations from the main logic, which makes it easier to develop and
maintain programs.
This appendix provides sample program code to illustrate two possible models for
writing Pathway servers that use subroutines to separate the database manipulation
operations from the main logic.
PERFORM model. This model uses COBOL PERFORM statements in the main
logic flow of a program to execute subroutines in the same program. When the
PERFORM is executed, the program enters the subroutine, performs the
requested function, and returns control to the next instruction in the main logic.
CALL model. This model uses COBOL CALL statements in the main program to
call subprograms. In this model, a program consists of a collection of subprograms
managed by a main program.
If the main program passes arguments to the subprogram, the subprogram must
contain a Linkage Section. If no arguments are passed, the subprogram need not
contain a Linkage Section. In HP COBOL, a main program cannot contain a
Linkage Section.
PERFORM Model
This PERFORM model Pathway server program modifies a single file, called PARTS in
the sample database, depending on the value of the ENTRY-TYPE flag of the message
received. When the flag is U, the server updates the inventory count for the specified
part number. When the flag is I, it inserts a new PARTS record.
The reply message fields REPLY-CODE and ERROR-CODE are set as follows:
Reply Message REPLY-CODE ERROR-CODE
Operation successful 0 N.A.
Error, operation not performed 9999 Positive SQLCODE value
(transformed from original negative
value)
Warning, but operation successful 9998 Positive SQLCODE value
Invalid ENTRY-TYPE 9997 N.A.