SQL Programming Manual for TAL
Examples of Dynamic NonStop SQL Programs
HP NonStop SQL Programming Manual for TAL—527887-001
C-20
Detailed Dynamic SQL Program
Page 9 [1] $VOL1.S04.TALDYN 1991-10-15 13:42:28
request^invars
291. 000000 0 0 INT PROC request^invars (sqlda, cnames);
292. 000000 1 0
293. 000000 1 0 !******************************************************!
294. 000000 1 0 ! PROC request^invars: !
295. 000000 1 0 ! This proc prompts for a value for each input parameter.!
296. 000000 1 0 ! !
297. 000000 1 0 ! Returns 0 if successful, -1 otherwise !
298. 000000 1 0 !*******************************************************!
299. 000000 1 0
300. 000000 1 0 STRUCT .EXT sqlda(sqlda^type); !IN: Input SQLDA
301. 000000 1 0 STRING .EXT cnames; !IN: contains parameter names
302. 000000 1 0
303. 000000 1 0 BEGIN
304. 000000 1 1
305. 000000 1 1 STRING .param^name[0:MAX^COLUMN^NAME^SIZE]; ! current
parameter name
306. 000000 1 1 INT namelen; ! length of current parameter name
307. 000000 1 1 INT nameix; ! index into parameter names string
308. 000000 1 1 INT input^num; ! number of parameters to be
obtained
309. 000000 1 1 INT count^read;
310. 000000 1 1 INT i;
311. 000000 1 1 INT .EXT param^ (sql^types); ! pointer to parameter
value
312. 000000 1 1 INT maxlen; ! maximum length of string parameter
313. 000000 1 1 INT .EXT ind^; ! pointer used to set null indicator
314. 000000 1 1 INT(32) temp; ! hold result from DNUMIN for 16-bit
case
315. 000000 1 1 ! (NUMIN will not accept an extended
address)
316. 000000 1 1
317. 000000 1 1 PRINT^BLANK^LINE;
318. 000015 1 1 PUT^STR ("Please provide data for input params");
319. 000033 1 1 PRINT^LINE;
320. 000046 1 1
321. 000046 1 1 PUT^STR ("------------------------------------");
322. 000064 1 1 PRINT^LINE;
323. 000077 1 1
324. 000077 1 1 PRINT^BLANK^LINE;
325. 000107 1 1
326. 000107 1 1 --
327. 000107 1 1 -- Get number of input variables.
328. 000107 1 1 --
329. 000107 1 1
330. 000107 1 1 input^num := sqlda.num^entries;
331. 000115 1 1
332. 000115 1 1 nameix := 1;
333. 000117 1 1
334. 000117 1 1
335. 000117 1 1 FOR i := 0 TO (input^num - 1) DO
336. 000121 1 1 BEGIN
337. 000121 1 2 !
338. 000121 1 2 ! Get a parameter name
339. 000121 1 2 !
340. 000121 1 2
341. 000121 1 2 namelen := cnames[nameix];
342. 000127 1 2 IF namelen THEN -- Is the parameter named?
343. 000131 1 2 param^name ':=' cnames[nameix+1] FOR namelen;
344. 000142 1 2
345. 000142 1 2 nameix := cnames[nameix] + 2 + nameix;
346. 000153 1 2
347. 000153 1 2 !**********************************************************!