SQL Programming Manual for TAL

Examples of Dynamic NonStop SQL Programs
HP NonStop SQL Programming Manual for TAL527887-001
C-3
Dynamic SQL Program
The TAL compiler listing for TALDYNEZ is shown on the following pages.
Page 1 [1] $VOL1.S04.TALDYNEZ 1991-10-15 13:41:54
TAL - T9250C30 - (01NOV91)
Copyright Tandem Computers Incorporated 1976, 1978, 1981-83, 1985, 1987-91
1. 000000 0 0 ?SQL NOWHENEVERLIST
2. 000000 0 0 ?SYMBOLS, INSPECT, SAVEABEND, NOMAP, NOCODE, NOGMAP,
NOLMAP, DATAPAGES 64
3. 000000 0 0 ?SEARCH \SYS1.$SYSTEM.SYSTEM.TALLIB
Search file: \SYS1.$SYSTEM.SYSTEM.TALLIB 1991-08-30 11:14:19
4. 000000 0 0
5. 000000 0 0 !--------------------------------------------------------
6. 000000 0 0 ! This program finds the average salary for employees
7. 000000 0 0 ! according to criteria established by the user. The
8. 000000 0 0 ! program contains a SELECT statement for the EMPLOYEE
9. 000000 0 0 ! table; the user enters the selection criteria, which
10. 000000 0 0 ! the program concatenates to the SELECT statement as a
11. 000000 0 0 ! WHERE clause.
12. 000000 0 0 !--------------------------------------------------------
13. 000000 0 0
14. 000000 0 0 LITERAL MAXCMD = 1000;
15. 000000 0 0 LITERAL NULL^ADDR = %HFFFC0000%D;
16. 000000 0 0
17. 000000 0 0 -- Variables for terminal I/O:
18. 000000 0 0 INT .HOME^TERM[0:11],
19. 000014 0 0 HOME^TERM^NUM,
20. 000014 0 0 NUM^READ,
21. 000014 0 0 .IBUF[0:99];
22. 000160 0 0 STRING .SBUF := @IBUF '<<' 1;
23. 000160 0 0
24. 000160 0 0 -- Pointer to end of the I/O buffer:
25. 000160 0 0 STRING .BUF^END;
26. 000160 0 0
27. 000160 0 0 --Copy in declarations for data type literals:
28. 000160 0 0 ?NOLIST
31. 000160 0 0
32. 000160 0 0 -- Other necessary declarations:
33. 000160 0 0
34. 000160 0 0 INT SQLCODE; -- for error checking
35. 000160 0 0 INT(32) AVERAGE; -- for output value
36. 000160 0 0 STRING .CMD[0:MAXCMD - 1]; -- array for SQL statement user
enters
37. 001144 0 0 STRING .CMD^END; -- ptr to end of command string
38. 001144 0 0
39. 001144 0 0 EXEC SQL INCLUDE SQLCA;
39. 001144 0 0 EXEC SQL INCLUDE SQLCA;
Source file: [3] $SYSTEM.#3189 1991-10-15 13:42:05
1. 001144 0 0 struct .SQLCA;
2. 001144 0 0 BEGIN
3. 001144 0 1 STRING filler^[0:429];
4. 001144 0 1 END; -- SQLCA
Source file: [1] $VOL1.S04.TALDYNEZ 1991-10-15 13:36:01
40. 001473 0 0 EXEC SQL INCLUDE SQLSA;
40. 001473 0 0 EXEC SQL INCLUDE SQLSA;
Source file: [4] $SYSTEM.#3190 1991-10-15 13:42:07
1. 001473 0 0 STRUCT .sqlsa;
2. 001473 0 0 BEGIN
3. 001473 0 1 STRING eye^catcher[0:1];
4. 001473 0 1 INT version;
5. 001473 0 1 STRUCT dml;