HP NonStop SQL/MP Programming Manual page 256

For c
Table of Contents

Advertisement

Dynamic SQL Operations
Example 10-8. Detailed Dynamic SQL Program (page 15 of 22)
850
int setupvarbuffers ( sqldaptr sqlda )
851
{
852
853
int num_entries;
854
int mem_reqd;
855
int i;
856
857
/* ---------------------------------------------------
858
/* Handle unsupported types; set scale information to 0. */
859
/* ---------------------------------------------------
860
adjust_sqlda_scale_types( sqlda );
861
862
num_entries = sqlda->num_entries;
863
for (i = 0; i < num_entries; i++)
864
{
865
switch (sqlda->sqlvar[i].data_type) {
866
/* ---------------------------------------------------- */
867
case _SQLDT_ASCII_F : /* CHAR datatype */
868
869
870
871
/* ---------------------------------------------------- */
872
case _SQLDT_ASCII_V : /* VARCHAR datatype */
873
874
875
876
/* ---------------------------------------------------- */
877
case _SQLDT_16BIT_S : /* SMALLINT */
878
case _SQLDT_16BIT_U : /* UNSIGNED SMALLINT */
879
case _SQLDT_32BIT_S : /* INTEGER */
880
case _SQLDT_32BIT_U : /* UNSIGNED INTEGER */
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
/* ---------------------------------------------------- */
906
default:
907
908
909
910
911
912
HP NonStop SQL/MP Programming Manual for C—429847-008
/* begin setupvarbuffers
mem_reqd = sqlda->sqlvar[i].data_len;
break;
mem_reqd = sqlda->sqlvar[i].data_len + 2;
break;
/*--------------------------------------------
/* NOTE ON SCALE INFORMATION
/*--------------------------------------------
/* Bits 0 through 7 of sqlda->sqlvar[i].data_len
/* have the scale information for the numeric
/* data types. Either remember this scale
/* information and later use the values in the
/* host variables appropriately or set the
/* scale information to 0 (which can lead to
/* truncated values on retrievals and inability
/* to provide scaled values through input
/* parameters)
/*--------------------------------------------
/* Set scale information to 0 (see note above)
/*--------------------------------------------
sqlda->sqlvar[i].data_len = sqlda->sqlvar[i].data_len & 0377;
/*--------------------------------------------*/
/* Extract length from bits 8:15
/*--------------------------------------------*/
mem_reqd = sqlda->sqlvar[i].data_len & 0377;
break;
printf( "\n**** Error: Unsupported Datatype: %s\n",
get_dtname( sqlda->sqlvar[i].data_type ));
return (-1);
/* number of sqlvar entries
/* buffer size
/* loop index
/* UNSUPPORTED types
10-58
Detailed Dynamic SQL Program
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/

Advertisement

Table of Contents
loading

Table of Contents