SQL/MP Programming Manual for C
Data Retrieval and Modification
HP NonStop SQL/MP Programming Manual for C—429847-008
4-8
INSERT Statement
Do not code this request with this WHERE clause:
WHERE LAST_NAME > :LAST-LNAME
AND FIRST_NAME > :LAST-FNAME
This clause does not retrieve names with the same last name as :LAST-LNAME and a
first name greater than :LAST-FNAME.
Also, do not code this request with this WHERE clause:
WHERE ( (LAST_NAME = :LAST-LNAME
AND FIRST_NAME > :LAST-FNAME)
OR LAST_NAME > :LAST-LNAME)
This clause would produce the correct results, but very slowly. Whenever possible,
avoid the OR disjunctive in a WHERE clause.
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 runs
an INSERT statement to transfer these host variable values to the table.
To run 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
that you include in a SELECT statement. For details, see Required Access Authority
on page 7-1.
NonStop SQL/MP returns these values to sqlcode after an INSERT statement.
If an INSERT statement runs 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, use the SQLCADISPLAY or SQLCATOBUFFER 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 (¦100) A warning occurred;
sqlcode contains the first warning number.