SQL/MP Programming Manual for C
Introduction
HP NonStop SQL/MP Programming Manual for C—429847-008
1-4
Calling SQL/MP System Procedures
Example 1-1 shows an example of static SQL statements embedded in a C program:
For more information, see Section 3, SQL/MP Statements and Directives and
Section 4, Data Retrieval and Modification.
Calling SQL/MP System Procedures
NonStop SQL/MP provides system procedures, written in TAL, that perform various
SQL operations and functions. For example, the SQLCADISPLAY procedure returns
error information from the SQLDA structure after an SQL statement runs.
You call SQL system procedures from a C program in the same manner you call other
system procedures (for example, FILE_OPEN_, FILE_CLOSE_, or WRITEREAD). The
cextdecs header file contains source declarations for these procedures that you can
include in a program. This example calls the SQLCADISPLAY procedure by using all
default parameters:
#include <cextdecs(SQLCADISPLAY)>
...
SQLCADISPLAY( (short *) &sqlca);
... /* Process information from the SQLCA structure */
For more information, see Section 5, SQL/MP System Procedures
and Section 11,
Character Processing Rules (CPRL) Procedures.
Example 1-1. Static SQL Statements in a C Program
/* C variable declarations */
...
EXEC SQL BEGIN DECLARE SECTION;
struct in_parts_struc /* host variables */
{
short in_partnum;
long in_price;
char in_partdesc[19];
} in_parts;
EXEC SQL END DECLARE SECTION;
void insert_function(void)
{
...
in_parts.in_partnum = 4120;
in_parts.in_price = 6000000;
strcpy (in_parts.in_partdesc, "V8 DISK OPTION ");
EXEC SQL
INSERT INTO $vol5.sales.parts (partnum, price, partdesc)
VALUES (:in_parts.in_partnum,
SETSCALE (:in_parts.in_price,2), /* scale is 2. */
:in_parts.in_partdesc);
... }