SQL Programming Manual for Pascal
Using Dynamic SQL
HP NonStop SQL Programming Manual for Pascal—528614-001
7-26
Dynamically Allocating Memory
Figure 7-7. Allocating Memory for Values (page 1 of 2)
. . .
{ Declare pointers for an SQLVAR structure and for the names}
{ buffer. These pointers will receive as starting values     }
{ INPUT_SQLDA_PTR and INPUT_NAMESBUF_PTR:      }
VAR
SQLVAR_PTR : PTR_TO_ANY;
NAMESPTR : PTR_TO_ANY;
{ Declare a pointer to memory where the parameter value will    }
{ be stored:                                         }
PARAM_PTR : PTR_TO_ANY;
{ Declare a variable for the data type:             }
DATA_TYPE: INTEGER;
{ Declare a variable for size of an SQLVAR entry, to be used      }
{ in calculating the offset from one parameter description         }
{ to the next:                       }
SQLVAR_SIZE : INTEGER;
{ Declare a loop counter:}
COUNT : INTEGER;
. . .
{ Calculate the size of an SQLVAR entry in an input SQLDA.   }
{ SQLVAR_TYPE is defined in the main program and was        }
{ described earlier:                                    }
SQLVAR_SIZE := SIZEOF(SQLVAR_TYPE);
{ Position the names buffer pointer to the beginning of the        }
{ names buffer:                                      }
NAMESPTR.CHAR_FIELD := INPUT_NAMESBUF_PTR;
{ Position the pointer to the input SQLDA:           }
SQLVAR_PTR.SQLDA_HEADER_FIELD := INPUT_SQLDA_PTR;
{ Move past the header:                   }
SQLVAR_PTR.INT32_FIELD := SQLVAR_PTR.INT32_FIELD
+ SIZEOF(SQLDA_HEADER);
VST0707.vsd










