| United States-English |
|
|
|
![]() |
ALLBASE/SQL COBOL Application Programming Guide: HP 9000 Computer Systems > Chapter 3 Embedding SQL CommandsDefining and Manipulating Data |
|
You embed data definition and data manipulation commands in the PROCEDURE DIVISION. You can embed the following SQL commands to create objects or change existing objects:
Data definition commands are useful for such activities as creating temporary tables or views to simplify data manipulation or creating an index that improves the program's performance:
The index created with this command expedites data access operations based on partial key values:
SQL has four basic data manipulation commands:
These four commands can be used for various types of data manipulation operations:
In all non-dynamic data manipulation operations, you use host variables to pass data back and forth between your program and the DBEnvironment. Host variables can be used in the data manipulation commands wherever the syntax in the allows them. The SELECT command shown at 8 in Figure 3-1 “Sample Program COBEX2 ” retrieves the row from PURCHDB.PARTS that contains a part number matching the value in the host variable named in the WHERE clause (PARTNUMBER). The three values in the row retrieved are stored in three host variables named in the INTO clause (PARTNUMBER, PARTNAME, and SALESPRICE). An indicator variable (SALESPRICEIND) is also used in the INTO clause, to flag the existence of a null value in column SALESPRICE:
You can also use host variables in non-SQL statements; in this case, omit the colon:
All host variables used in the PROCEDURE DIVISION must be declared in the DATA DIVISION, as discussed earlier in this chapter under "Declaring Host Variables". |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||