Calling Sql/Mp System Procedures; Example 1-1. Static Sql Statements In A C Program - HP NonStop SQL/MP Programming Manual

For c
Table of Contents

Advertisement

Introduction
Example 1-1
shows an example of static SQL statements embedded in a C program:

Example 1-1. Static SQL Statements in a C Program

/* C variable declarations */
...
EXEC SQL BEGIN DECLARE SECTION;
struct in_parts_struc
{
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)
:in_parts.in_partdesc);
... }
For more information, see
Section 4, Data Retrieval and

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
Character Processing Rules (CPRL)
HP NonStop SQL/MP Programming Manual for C—429847-008
VALUES (:in_parts.in_partnum,
SETSCALE (:in_parts.in_price,2), /* scale is 2. */
Section 3, SQL/MP Statements and Directives
Modification.
Section 5, SQL/MP System Procedures
Calling SQL/MP System Procedures
/* host variables */
Procedures.
1-4
");
and
and
Section 11,

Advertisement

Table of Contents
loading

Table of Contents