SQL/MP Programming Manual for COBOL

Data Retrieval and Modification
HP NonStop SQL/MP Programming Manual for COBOL529758-003
4-6
Using IN SHARE MODE or IN EXCLUSIVE MODE
EMPLOYEE.DEPTNUM
INTO :EMPLOYEE.FIRST-NAME,
:EMPLOYEE.LAST-NAME,
:EMPLOYEE.DEPTNUM
FROM PERSNL.EMPLOYEE
WHERE EMPLOYEE.EMPNUM = :FIND-THIS-EMPLOYEE
END-EXEC.
Using IN SHARE MODE or IN EXCLUSIVE MODE
If you include the keyword IN in the EXCLUSIVE MODE or SHARE MODE option after
a host variable, the statement generates a syntax error. For example, this statement
generates a syntax error because HOST-VAR IN EXCLUSIVE MODE is interpreted as
a host variable:
EXEC SQL SELECT COLUMN INTO :HOST-VAR FROM ATABLE
WHERE COLUMN > :HOST-VAR IN EXCLUSIVE MODE END-EXEC.
To prevent the syntax error, omit the keyword IN:
EXEC SQL SELECT COLUMN INTO :HOST-VAR FROM ATABLE
WHERE COLUMN > :HOST-VAR EXCLUSIVE MODE END-EXEC.
INSERT Statement
The INSERT statement inserts one or more rows into a table or protection view. To
insert data, a program moves the new data to a series of host variables and then
executes an INSERT statement to transfer the host variable values to the table.
To execute an INSERT statement, a process started by the program must have read
and write access to the table or view receiving the data and read access to tables or
views you include in a SELECT statement. For information about process access, see
Required Access Authority on page 7-1.
SQL/MP returns these values to SQLCODE after an INSERT statement.
If an INSERT statement executes successfully, the SQLCA structure contains the
number of rows inserted. (If the INSERT statement fails, do not rely on the SQLCA
structure for an accurate count of the number of rows inserted.) To return the contents
of the SQLCA structure, use the SQLCA_DISPLAY2_ or SQLCA_TOBUFFER2_
procedure.
For more information, see Section 5, SQL/MP System Procedures
, and Section 9,
Error and Status Reporting.
SQLCODE Value Description
0
The INSERT statement was successful.
100
No rows qualified for an INSERT using a SELECT statement
specification.
< 0
An error occurred; SQLCODE contains the error number.
> 0 (not 100)
A warning occurred; SQLCODE contains the first warning number.