SQL/MP Programming Manual for COBOL

HP NonStop SQL/MP Programming Manual for COBOL529758-003
4-1
4 Data Retrieval and Modification
This section describes how to access data in a NonStop SQL/MP database by using
the Data Manipulation Language (DML) statements in a COBOL program.
Topics include:
Opening and Closing Tables and Views on page 4-2
Single-Row SELECT Statement on page 4-4
INSERT Statement on page 4-6
UPDATE Statement on page 4-8
DELETE Statement on page 4-10
Using SQL Cursors on page 4-12
Table 4-1 provides some guidelines for using these statements.
Table 4-1. SQL/MP Statements for Data Retrieval and Modification
NonStop SQL/MP Statement Description
Single-Row SELECT statement Retrieves a single row of data from a table or
protection view and places the specified column
values in host variables. Use when you need to
retrieve only a single row.
SELECT statement with a cursor Retrieves a set of rows from a table or view, one row
at a time, and places the specified column values in
host variables. Use when you need to retrieve more
than one row.
INSERT statement Inserts one or more rows into a table or protection
view. Use for all INSERT operations.
UPDATE statement without a cursor Updates the values in one or more columns in a
single row or a set of rows of a table or protection
view. Use when you do not need to test a column
value in a row before you update the row.
UPDATE statement with a cursor Updates the values in one or more columns in a set
of rows, one row at a time. Use when you need to test
a column value in a row before you update the row.
DELETE statement without a cursor Deletes a single row or a set of rows from a table or
protection view. Use when you do not need to test a
column value in a row before you delete the row.
DELETE statement with a cursor Deletes a set of rows, one row at a time, from a table
or protection view. Use when you need to test a
column value in a row before you delete the row.