EasyManua.ls Logo

HP NonStop SQL/MP - Page 256

HP NonStop SQL/MP
331 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C429847-008
10-58
Detailed Dynamic SQL Program
850 int setupvarbuffers ( sqldaptr sqlda )
851 { /* begin setupvarbuffers */
852
853 int num_entries; /* number of sqlvar entries */
854 int mem_reqd; /* buffer size */
855 int i; /* loop index */
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 mem_reqd = sqlda->sqlvar[i].data_len;
869 break;
870
871 /* ---------------------------------------------------- */
872 case _SQLDT_ASCII_V : /* VARCHAR datatype */
873 mem_reqd = sqlda->sqlvar[i].data_len + 2;
874 break;
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 /* NOTE ON SCALE INFORMATION */
884 /*-------------------------------------------- */
885 /* Bits 0 through 7 of sqlda->sqlvar[i].data_len */
886 /* have the scale information for the numeric */
887 /* data types. Either remember this scale */
888 /* information and later use the values in the */
889 /* host variables appropriately or set the */
890 /* scale information to 0 (which can lead to */
891 /* truncated values on retrievals and inability */
892 /* to provide scaled values through input */
893 /* parameters) */
894 /*-------------------------------------------- */
895 /* Set scale information to 0 (see note above) */
896 /*-------------------------------------------- */
897 sqlda->sqlvar[i].data_len = sqlda->sqlvar[i].data_len & 0377;
898
899 /*--------------------------------------------*/
900 /* Extract length from bits 8:15 */
901 /*--------------------------------------------*/
902 mem_reqd = sqlda->sqlvar[i].data_len & 0377;
903 break;
904
905 /* ---------------------------------------------------- */
906 default: /* UNSUPPORTED types */
907
908
909 printf( "\n**** Error: Unsupported Datatype: %s\n",
910 get_dtname( sqlda->sqlvar[i].data_type ));
911 return (-1);
912
Example 10-8. Detailed Dynamic SQL Program (page 15 of 22)

Table of Contents

Related product manuals