SQL Programming Manual for Pascal

Examples of Dynamic NonStop SQL Programs
HP NonStop SQL Programming Manual for Pascal528614-001
C-15
Detailed Dynamic SQL Program
254 0 {**********************************************************}
255 0 {* DEALLOC_SQLDA : Deallocate storage for a SQLDA on the heap.
*}
256 0 {**********************************************************}
257 0 procedure dealloc_sqlda(var sqldap : P_SQLDA_HDR);
258 1 var
259 1 heap : P_ANY; { scratch pointer }
260 1 begin
261 2 if (sqldap = NIL) then { heap has not been alloc'd }
262 3 return; { got nothing to do }
263 2 heap.sqldap := sqldap; { load local pointer }
264 2 FREE(heap.xa); { deallocate the storage }
265 2 sqldap := NIL; { clear the input pointer }
266 2 end; { of proc dealloc_sqlda }
267 0
268 0 {**********************************************************}
269 0 {* DISPLAY_RESULT : Display a record fetched from the
database. *}
270 0 {**********************************************************}
271 0 procedure display_result(sqldap : P_SQLDA_HDR; nambufp
: P_CHAR_BUF);
272 1 const
273 1 LINE_SIZE = 80; { equal to size of screen }
274 1 SEPARATOR = ' : '; { between col name and data }
275 1 var
276 1 char_size : integer; { size of a character }
277 1 data_type : integer; { it means what it says! }
278 1 i,j : integer; { loop index }
279 1 len : integer; { parameter name length }
280 1 nc : integer; { number of output columns }
281 1 sqlvar_size : integer; { size of a SQLVAR_TYPE }
282 1 namp : P_ANY; { ptr to a name buffer }
283 1 valp : P_ANY; { ptr to the value }
284 1 varp : P_ANY; { ptr to a SQLVAR structure }
285 1 begin
286 2 nc := sqldap^.num_entries; { # output columns }
287 2 namp.bufp := nambufp;
288 2 varp.sqldap := sqldap; { set ptr to 1st SQLVAR }
289 2 varp.i := varp.i + sizeof(SQLDA_HDR);
290 2 char_size := sizeof(char);
291 2 sqlvar_size := sizeof(SQLVAR_TYPE);
292 2
293 2 writeln;
294 2