SQL/MP Programming Manual for COBOL

Writing Pathway Servers
HP NonStop SQL/MP Programming Manual for COBOL529758-003
E-4
CALL Model: SQL Main Program
CALL Model: SQL Main Program
This CALL 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.
update-parts.
MOVE partnum OF parts-info TO partnum OF parts-record.
MOVE inventory OF parts-info TO inventory OF parts-record.
EXEC SQL UPDATE $mkt.sample.parts
SET inventory = :parts-record.inventory
WHERE partnum = :parts-record.partnum
END-EXEC.
insert-parts.
MOVE partnum OF parts-info TO partnum OF parts-record.
MOVE partname OF parts-info TO partname OF parts-record.
MOVE inventory OF parts-info TO inventory OF parts-record.
MOVE location OF parts-info TO location OF parts-record.
MOVE price OF parts-info TO price OF parts-record.
EXEC SQL INSERT INTO $mkt.sample.parts
VALUES ( :parts-record.partnum,
:parts-record.partname,
:parts-record.inventory,
:parts-record.location,
:parts-record.price )
END-EXEC.
sql-error.
* Return the error code as a positive number.
*
MOVE 9999 TO reply-code OF entry-reply.
MOVE sqlcode OF sqlca TO error-code.
MULTIPLY error-code BY -1 GIVING error-code END-MULTIPLY.
sql-warning.
MOVE 9998 TO reply-code OF entry-reply.
MOVE sqlcode OF sqlca TO error-code.
sql-notfnd.
MOVE 9999 TO reply-code OF entry-reply.
MOVE sqlcode OF sqlca TO error-code.
Example E-1. PERFORM Model (page 3 of 3)