SQL Programming Manual for TAL
Examples of Dynamic NonStop SQL Programs
HP NonStop SQL Programming Manual for TAL—527887-001
C-31
Detailed Dynamic SQL Program
Page 20 [1] $VOL1.S04.TALDYN     1991-10-15 13:42:28
      free^sqlda
804. 000000 0 0 PROC free^sqlda (sqlda);
805. 000000 1 0
806. 000000 1 0 !*******************************************************!
807. 000000 1 0 ! PROC free^sqlda:      !
808. 000000 1 0 ! This proc accepts an sqlda as a parameter and  !
809. 000000 1 0 ! frees all memory that was allocated for the data  !
810. 000000 1 0 ! buffers (pointed to as sqlvar[i].var^ptr), the  !
811. 000000 1 0 ! indicator variables (pointed to as sqlvar[i].ind^ptr), !
812. 000000 1 0 ! and for the sqlda and sqlvar entries.   !
813. 000000 1 0 !         !
814. 000000 1 0 ! The proc assumes that if a nonnull sqlda address  !
815. 000000 1 0 ! is passed, then sqlda.num^entries has a valid value. !
816. 000000 1 0 !         !
817. 000000 1 0 !******************************************************!
818. 000000 1 0
819. 000000 1 0 STRUCT .ext sqlda (sqlda^type); ! IN--Pointer to SQLDA
820. 000000 1 0
821. 000000 1 0 BEGIN
822. 000000 1 1 INT i;
823. 000000 1 1 INT .EXT ptr; ! temporary pointer for freeing memory
          pointed
824. 000000 1 1   ! at by var^ptr or ind^ptr
825. 000000 1 1
826. 000000 1 1 if @sqlda = NULL^ADDR then return;
827. 000007 1 1
828. 000007 1 1 FOR i := 0 TO sqlda.num^entries-1 DO
829. 000011 1 1 BEGIN
830. 000011 1 2  @ptr := sqlda.sqlvar[i].var^ptr;
831. 000024 1 2  if @ptr <> NULL^ADDR then
832. 000031 1 2  begin
833. 000031 1 3  CALL PUTPOOL(pool^head, ptr);
834. 000037 1 3  if <> then
835. 000040 1 3  begin
836. 000040 1 4  PUT^STR ("PUTPOOL memmory management error");
837. 000056 1 4  PRINT^LINE;
838. 000071 1 4  call ABEND;
839. 000076 1 4  end;
840. 000076 1 3  end;
841. 000076 1 2  @ptr := sqlda.sqlvar[i].ind^ptr;
842. 000111 1 2  if @ptr >= 0D then ! ***** don't know why <>
       NULL^ADDR doesn't work ****
843. 000114 1 2  begin
844. 000114 1 3  CALL PUTPOOL(pool^head, ptr);
845. 000122 1 3  if <> then
846. 000123 1 3  begin
847. 000123 1 4  PUT^STR ("PUTPOOL memory management error");
848. 000141 1 4  PRINT^LINE;
849. 000154 1 4  call ABEND;
850. 000161 1 4  end;
851. 000161 1 3  end;
852. 000161 1 2  END;
853. 000174 1 1
854. 000174 1 1 call PUTPOOL (pool^head, sqlda);
855. 000202 1 1 if <> then
856. 000203 1 1  begin
857. 000203 1 2  PUT^STR ("PUTPOOL memory management error");
858. 000221 1 2  PRINT^LINE;
859. 000234 1 2  call ABEND;
860. 000241 1 2  end;










