Dynamic SQL Operations
HP NonStop SQL/MP Programming Manual for C—429847-008
10-23
Developing a Dynamic SQL Program
Developing a Dynamic SQL Program
Specify the SQL Pragma
Specify the SQL pragma to indicate to the SQL compiler that your program contains
embedded SQL statements. For information about the SQL pragma, see
Section 6,
Explicit Program Compilation
.
Copy any External Declarations
Copy any required external declarations, including SQL system procedures and
C header files:
#include <cextdecs(SQLCADISPLAY)> ;
#include <stdioh>;
#include <sqlh>; /* data-type literals */
#include <stdlibh>; /* malloc and free */
#include <stringh>; /* strcpy, strncpy */
Declare the
sqlcode
Variable and Host Variables
Declare the
sqlcode
variable and any required host variables:
short sqlcode;
EXEC SQL BEGIN DECLARE SECTION;
char statement_buffer[MAX_STATEMENT1];
EXEC SQL INVOKE =employee AS employee_struct;
struct employee_struct employee_row;
input_sqlda_ptr... /* pointer to input SQLDA */
output_sqlda_ptr ... /* pointer to output SQLDA */
input_namesbuf_ptr... /* pointer to input names buffer */
output_namesbuf_ptr.../* pointer to output names buffer */
...
EXEC SQL END DECLARE SECTION;
Specify Any WHENEVER Directives
If you use WHENEVER directives for error handling, code them anywhere in your
program. However, you must declare the error handling functions before you declare
the directives.
EXEC SQL WHENEVER SQLERROR CALL :handle_error;
EXEC SQL WHENEVER SQLWARNING CONTINUE;
For more information about the WHENEVER directive, see
Section 9, Error and Status
Reporting
.
Summary of Contents for NonStop SQL/MP
Page 4: ......
Page 14: ...Contents HP NonStop SQL MP Programming Manual for C 429847 008 x ...
Page 60: ...Host Variables HP NonStop SQL MP Programming Manual for C 429847 008 2 26 VARCHAR Data Type ...
Page 294: ...SQL MP Sample Database HP NonStop SQL MP Programming Manual for C 429847 008 A 6 ...