SQL Programming Manual for TAL

Examples of Dynamic NonStop SQL Programs
HP NonStop SQL Programming Manual for TAL527887-001
C-22
Detailed Dynamic SQL Program
Page 11 [1] $VOL1.S04.TALDYN 1991-10-15 13:42:28
request^invars
405. 000653 1 3 if namelen then
406. 000655 1 3 begin
407. 000655 1 4 PUT^STR^MID (" for " & param^name for namelen);
408. 000676 1 4 end;
409. 000676 1 3 PUT^STR^MID (": ");
410. 000712 1 3 call WRITEREAD(term,buf,$INT(@next^buf -
@sbuf),25,count^read);
411. 000726 1 3 sbuf[count^read] := 0; ! terminator for DNUMIN and scan
412. 000731 1 3 @next^buf := @sbuf;
413. 000733 1 3 while next^buf <> 0 and next^buf = " " do @next^buf :=
@next^buf[1];
414. 000750 1 3
415. 000750 1 3 IF (sqlda.sqlvar[i].null^info = -1) AND
416. 000750 1 3 (next^buf = "?") THEN
417. 000770 1 3 begin ! got a null value; set null indicator
418. 000770 1 4 @ind^ := sqlda.sqlvar[i].ind^ptr;
419. 001003 1 4 ind^ := -1;
420. 001006 1 4
421. 001006 1 4 end else begin
422. 001007 1 4
423. 001007 1 4 CASE sqlda.sqlvar[i].data^type OF
424. 001022 1 4 begin
425. 001022 1 5 _SQLDT_16BIT_S,
426. 001022 1 5 _SQLDT_16BIT_U ->
427. 001022 1 5 call DNUMIN(next^buf,temp,10);
428. 001036 1 5 ! Problems:
429. 001036 1 5 ! Unsigned should not allow minus sign.
430. 001036 1 5 ! Should check status for error.
431. 001036 1 5 ! Should check that whole string was
consumed.
432. 001036 1 5 ! Should check that value fits in 16-bits
433. 001036 1 5 param^.v^smallint := $INT(temp);
434. 001042 1 5 _SQLDT_32BIT_S,
435. 001043 1 5 _SQLDT_32BIT_U ->
436. 001043 1 5 call DNUMIN(next^buf,param^.v^int,10);
437. 001055 1 5 ! This isn't completely right for unsigned
438. 001055 1 5 ! should check status for error and should
439. 001055 1 5 ! check that whole string was consumed.
440. 001055 1 5 end;
441. 001101 1 4 end;
442. 001101 1 3
443. 001101 1 3 _SQLDT_DATETIME ->
444. 001102 1 3 PUT^STR ("Please enter a date/time value");
445. 001120 1 3 if namelen then
446. 001122 1 3 begin
447. 001122 1 4 PUT^STR^MID (" for " & param^name for namelen);
448. 001143 1 4 end;
449. 001143 1 3 PUT^STR^MID (": ");
450. 001157 1 3 PRINT^LINE;
451. 001172 1 3 param^.v^datetime ':=' " " & param^.v^datetime
452. 001172 1 3 for $OCCURS(param^.v^datetime)-1;
453. 001210 1 3 call READX (term, param^.v^datetime, $OCCURS
(param^.v^datetime));
454. 001221 1 3
455. 001221 1 3 IF (sqlda.sqlvar[i].null^info = -1) AND
456. 001221 1 3 (param^.v^datetime = "?") THEN
457. 001241 1 3 begin ! got a null value; set null indicator
458. 001241 1 4 @ind^ := sqlda.sqlvar[i].ind^ptr;
459. 001254 1 4 ind^ := -1;
460. 001257 1 4 end;
461. 001257 1 3