SQL/MP Programming Manual for C
Data Retrieval and Modification
HP NonStop SQL/MP Programming Manual for C—429847-008
4-6
Using a Primary Key Value to Select Data
 :customer.postcode
 FROM sales.customer
 WHERE customer.custnum = :find_this_customer
 BROWSE ACCESS;
/* Process data returned by the SELECT statement */
...
}
int main(void)
{
EXEC SQL WHENEVER NOT FOUND CALL :not_found_function; 
find_record(); 
...
}
Using a Primary Key Value to Select Data 
This SELECT statement returns an employee’s first name, last name, and department 
number from the EMPLOYEE table using a primary key value (EMPNUM column). The 
WHERE clause specifies that the selected row contains a primary key with a value 
equal to the host variable find_this_employee. The SELECT statement retrieves 
only one row because the primary key value is unique. 
find_this_employee = input_empnum /* set host variable */
EXEC SQL SELECT employee.first_name,
 employee.last_name,
 employee.deptnum 
 INTO :employee.first_name,
 :employee.last_name,
 :employee.deptnum
 FROM persnl.employee 
 WHERE employee.empnum = :find_this_employee; 
Multirow SELECT Statement
Applications frequently request a group of rows for display on a screen, then request 
the next sequential group of rows.
If the operation is performed in a Pathway environment, a context-free server must 
receive the starting position for requesting the next set of records from the requester. It 
cannot save the starting position from a previous operation. 
Assume that the initial request from the requester passes a blank or zeros, and that 
each subsequent request passes the search column values of the last record returned. 
The server uses the values sent from the requester to establish the starting position in 
the table. The server fetches the next set of rows from that position.
These examples illustrate several ways to define cursors that reposition on a key 
value. The illustrations start with a simple solution and proceed to increasingly complex 
solutions.










