SQL Programming Manual for TAL
Dynamic NonStop SQL Operations
HP NonStop SQL Programming Manual for TAL—527887-001
7-3
Writing a Dynamic SQL Pathway Server
Writing a Dynamic SQL Pathway Server
If you are writing a TAL server that interfaces with Pathway and uses dynamic SQL
statements, follow these steps:
1. Use the TAL SOURCE directive to include the declarations in the EXTDECS file for
the Guardian OPEN, READUPDATE, and REPLY system procedures:
?SOURCE $SYSTEM.SYSTEM.EXTDECS (OPEN, READUPDATE, REPLY)
Except for constructing the SQL statement, these tasks are not unique to servers
using SQL. You perform these tasks in addition to the tasks you would perform for
any dynamic SQL program:
2. Define storage for the messages to be received from the SCREEN COBOL
requester.
3. Define a character string to contain the statement that the program will construct
from the input.
4. Call the OPEN and READUPDATE procedures to read $RECEIVE.
5. Construct the SQL statement:
•
Check values passed from the requester in the buffer to decide what the
statement includes.
•
As each value is read, concatenate the corresponding text to form the
statement.
For example, suppose the screen describes a personnel record. If any column
does not have a value, the user can enter N. The request message you defined is
named LIST^MSG. This code checks the EMPNUM field in LIST^MSG and, if
required, concatenates the text “empnum” to the statement you are constructing:
STRING .cmd [0:199];
STRING .cmd^end;
cmd ':=' "SELECT " -> @cmd^end;
...
IF list^msg.empnum <> "N" THEN
cmd^end ':=' "EMPNUM " -> @cmd^end;
The statement now contains the string “SELECT EMPNUM”. You continue to
construct the entire statement based on the values the user entered.
6. After the database request has been processed, construct the reply message.
Instead of formatting and displaying the output values, you assign the values to the
reply message. The first field in the reply message record must contain the reply
code to communicate with the SCREEN COBOL requester.
7. Call REPLY to send the reply message to the requester (screen program).