SQL Programming Manual for TAL

Examples of Dynamic NonStop SQL Programs
HP NonStop SQL Programming Manual for TAL527887-001
C-29
Detailed Dynamic SQL Program
Page 18 [1] $VOL1.S04.TALDYN 1991-10-15 13:42:28
setupvarbuffers
700. 000067 1 3 _SQLDT_DEC_LSE, ! DECIMAL LSE
701. 000067 1 3 _SQLDT_DEC_TSS, ! DECIMAL TSS
702. 000067 1 3 _SQLDT_DEC_TSE -> ! DECIMAL TSE
703. 000067 1 3 mem^reqd := sqlda.sqlvar[i].data^len.<8:15>;
704. 000103 1 3 _SQLDT_DATETIME .. _SQLDT_INT_D_F -> ! Date-time
705. 000104 1 3 mem^reqd := sqlda.sqlvar[i].data^len.<8:15>;
706. 000120 1 3 OTHERWISE ->
707. 000121 1 3 PUT^STR ("This data type is not supported: ");
708. 000137 1 3 PUT^INT^MID (sqlda.sqlvar[i].data^len);
709. 000170 1 3 PRINT^LINE;
710. 000203 1 3 return -1;
711. 000210 1 3 END; !end of case
712. 000550 1 2
713. 000550 1 2 !*******************************************************!
714. 000550 1 2 ! Allocate memory for the data value and assign the byte
address !
715. 000550 1 2 ! of the data buffer to var^ptr of sqlvar[i]. !
716. 000550 1 2 !*******************************************************!
717. 000550 1 2 sqlda.sqlvar[i].var^ptr := GETPOOL(pool^head,
$DBL(mem^reqd));
718. 000571 1 2 IF sqlda.sqlvar[i].var^ptr = -1d THEN
719. 000606 1 2 BEGIN
720. 000606 1 3 PUT^STR ("Getpool memory management error");
721. 000624 1 3 PRINT^LINE;
722. 000637 1 3 CALL ABEND;
723. 000644 1 3 END;
724. 000644 1 2
725. 000644 1 2 !*******************************************************!
726. 000644 1 2 ! If null^info is set, allocate a buffer for the indicator
value !
727. 000644 1 2 ! and assign its address to ind^ptr of sqlvar[i]. !
728. 000644 1 2 !*******************************************************!
729. 000644 1 2 IF sqlda.sqlvar[i].null^info = -1 THEN
730. 000660 1 2 BEGIN
731. 000660 1 3 sqlda.sqlvar[i].ind^ptr := GETPOOL(pool^head, $DBL(2));
732. 000701 1 3 IF sqlda.sqlvar[i].ind^ptr = -1d THEN
733. 000716 1 3 BEGIN
734. 000716 1 4 PUT^STR ("Getpool memory management error");
735. 000734 1 4 PRINT^LINE;
736. 000747 1 4 CALL ABEND;
737. 000754 1 4 END;
738. 000754 1 3 @ind^ptr^ := sqlda.sqlvar[i].ind^ptr;
739. 000767 1 3 ind^ptr^ := 0; ! set memory IND^PTR points at to 0
740. 000771 1 3 END;
741. 000771 1 2 END; ! end of for
742. 001004 1 1
743. 001004 1 1 return 0;
744. 001006 1 1 END; ! of proc setupvarbuffers
745. 000000 0 0
746. 000000 0 0
747. 000000 0 0
748. 000000 0 0