ODBC Server Reference Manual
Stored Procedures
HP NonStop ODBC Server Reference Manual—429151-002
5-16
Developing a Stored Procedure in C
(data)
---------------------------------------------------- */
typedef struct SQLDA_TYPE *sdaptr;
sdaptr sdai21;
sdaptr sdao21;
/* ------------------------------------------------------
Set up SQLDA for the column headings
---------------------------------------------------- */
sdaptr sdan21;
typedef char (*arrayptr) [1000];
arrayptr colnames21;
char temp_stmt21[max_stmt_len + 1];
/* area for null_ind values */
short int NULL_ind[max_columns];
int input_value;
/* ------------------------------------------------------
Invoke employee table
---------------------------------------------------- */
exec sql invoke =employee as employee_type;
struct employee_type emp_rec;
EXEC SQL DECLARE emp21_cursor cursor FOR
select empnum,
first_name,
last_name,
deptnum
from =employee
where deptnum = :input_value
browse access;
EXEC SQL END DECLARE section;
•
The routine INITIALIZE_SPE_21 itself is used for setting up the SQLDA
structure to be used for the input parameter:
/* ------------------------------------------------------
SQLDA for storing the column definition for the input
parameter and the input value. The space needed is
dependent on how many input parameters are used. This
area is used by GET_INPUT_PARAMS
---------------------------------------------------- */
sdai21 = allocate_SQLDA (SPE_21_max_inputs, FALSE);
strncpy (sdai21->eye_catcher, SQLDA_EYE_CATCHER, 2);
sdai21->num_entries = SPE_21_max_inputs;
•
Finally, there is code in INITIALIZE_SPE_21 for setting up the SQLDAs for the
column descriptions and row data:
/* -----------------------------------------------------
SQLDA for storing the column definition and column
headings needs to be allocated. The space needed is
dependent on how many columns are to be returned. This
area is used by ENCODE_ROW_DESCRIPTOR.