SQL Programming Manual for TAL

Dynamic NonStop SQL Operations
HP NonStop SQL Programming Manual for TAL527887-001
7-26
Using the Names Buffer
Figure 7-4. Getting Parameter Values (page 2 of 2)
nameix := 1;
FOR i := 0 TO (input^num - 1) DO
BEGIN
! Read the length for a parameter name, starting at
! the second byte in the length field (assumes no
! name ever contains more than 255 characters).
namelen := inamesbuf^ptr[nameix];
! If parameter has a name, save the name in PARAM^NAME:
IF namelen THEN
param^name ':=' inamesbuf^ptr[nameix + 1] FOR namelen;
! Move index to next length field:
nameix := namelen + 2 + nameix;
! Request input value based on data type:
! Set pointer to storage for current parameter value:
@param^ := sqlda.sqlvar[i].var^ptr;
maxlen := sqlda.sqlvar[i].data^len;
CASE sqlda.sqlvar[i].data^type OF
BEGIN
SQLDT^ASCII^F,
SQLDT^ASCII^F^UP -> ! Prompt for value for a string
! of maximum MAXLEN characters
! Read the parameter value into the memory pointed to by
! VAR^PTR, the address of which is in param^.param^.v^char
! references the character field in struct sql^types.
CALL READX(term, param^.v^char, maxlen);
! Read values for other data types. Sample calls are:
! For VARCHAR: CALL READX (term, param^.v^varchar.val,
! maxlen,param^.varchar.len);
! For NUMERIC: 1.Prompt and CALL WRITEREAD
! (term, buf, $INT(@next^buf - @sbuf),
! 25, count^read);
! 2.Call DNUMIN to convert input to numeric.
! For DATETIME CALL READX (term, param^.v^datetime
! FOR $OCCURS(param^.v^datetime) );
END; ! end CASE
END;
VST0704.vsd