SQL Programming Manual for TAL
Dynamic NonStop SQL Operations
HP NonStop SQL Programming Manual for TAL—527887-001
7-29
Allocating and Filling in Output Variables
Figure 7-5. Displaying Output (page 1 of 3)
-- Get number of columns to output in current row:
output^num := osqlda^ptr.num^entries;
-- SQL^TYPES is a structure with fields of different
-- SQL data types equivalenced to each other
INT i; --loop counter
INT .EXT param^(sql^types); -- ptr to where to put
-- column value
BEGIN
INT length;
INT nameix; --index into column names buffer
INT output^num; --number of columns output by SELECT
INT datalen; --length of a column value
--Put an INT(32) into the line, starting at beginning:
DEFINE PUT^DBL(n) = @next^buf := @sbuf;
@next^buf := @next^buf +
$DBL(DNUMOUT(next^buf, n,10)) #;
PROC display^result(osqlda^ptr, onamesbuf^ptr);
STRUCT .EXT osqlda^ptr(sqlda^type); --output SQLDA ptr
STRING .EXT onamesbuf^ptr; -- ptr to buffer with column
-- names of table
DEFINE PUT^STR(s) = @next^buf := @sbuf;
next^buf ':=' s -> @next^buf #;
--Put an integer into the line, starting at beginning:
DEFINE PUT^INT(n) = @next^buf := @sbuf;
@next^buf := @next^buf +
$DBL(DNUMOUT(next^buf, $DBL(n),10)) #;
--Put an integer into the line, starting after the
--beginning:
DEFINE PUT^INT^MID(n) = @next^buf := @next^buf +
$DBL(DNUMOUT(next^buf, $DBL(n),10)) #;
-- Global declarations used in printing output:
STRING .EXT next^buf; --ptr to end of data in buffer
--Put a string into the line, starting at beginning:
-- Declare, open, fetch, and close the cursor.
-- before executing this code.
VST0705.vsd