EasyManua.ls Logo

HP NonStop SQL/MP - Page 254

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-56
Detailed Dynamic SQL Program
724 if ( ( strncmp(host1, "same", 4) == 0 ) ||
725 ( strncmp(host1, "SAME", 4) == 0 ) )
726 { /* restore the saved query to host1 and display it */
727 strncpy ( host1, host2, max_query_size ); /* do an 'fc' */
728 printf( "\nRe-executing Query >> ");
729 host1[last_query_size] = '\0'; /* temporarily null terminate */
730 puts( host1 ); fflush (stdout); /* display query */
731 host1[last_query_size] = ' '; /* restore the blank */
732
733 }
734 else
735 { /* backup the query and remember its size */
736 strncpy ( host2, host1, max_query_size ); /* backup the query */
737 last_query_size = query_len; /* remember size */
738 }
739 return (0);
740 } /* end: read_query */
741
742 /* *************************************************** */
743 /* FUNCTION adjust_sqlda_scale_types */
744 /* This function takes an SQLDA as a parameter and, */
745 /* for sqlda.num_entries, adjusts the recommended */
746 /* (by SQL) data types and scales to what C supports. */
747 /* */
748 /* Setting up buffers for supported data types */
749 /* involves modifying the data_len and data_type */
750 /* of the SQLVAR entry to reflect the data attributes */
751 /* of the allocated buffers. For example, an input */
752 /* parameter or output variable with */
753 /* data_type == _SQLDT_DEC_LSS and */
754 /* data_len == 7 (assuming scale = 0) */
755 /* can be modified to have */
756 /* data_type == _SQLDT_32BIT_S and */
757 /* data_len == 4 */
758 /* and a 4 byte buffer can be allocated for it */
759 /* */
760 /* Scale is set to 0 */
761 /* Data_type is set to nearest equivalent supported */
762 /* type */
763 /* */
764 /* *************************************************** */
765 int adjust_sqlda_scale_types ( sqldaptr sqlda )
766
767 { /* begin adjust_sqlda_scale_types */
768
769 int num_entries; /* number of sqlvar entries */
770 int i; /* loop index */
771
772 num_entries = sqlda->num_entries;
773
774 for (i = 0; i < num_entries; i++)
775 {
776 switch (sqlda->sqlvar[i].data_type) {
777 /* ---------------------------------------------------- */
778 case _SQLDT_16BIT_S : /* SMALLINT */
779 case _SQLDT_16BIT_U : /* UNSIGNED SMALLINT */
780 case _SQLDT_32BIT_S : /* INTEGER */
781 case _SQLDT_32BIT_U : /* UNSIGNED INTEGER */
782 case _SQLDT_64BIT_S : /* SIGNED LARGEINT */
783
784 /*--------------------------------------------*/
785 /* set scale information to 0 */
786 /*--------------------------------------------*/
Example 10-8. Detailed Dynamic SQL Program (page 13 of 22)

Table of Contents

Related product manuals