SQL/MP Programming Manual for COBOL

Data Retrieval and Modification
HP NonStop SQL/MP Programming Manual for COBOL529758-003
4-8
Inserting a Timestamp
Inserting a Timestamp
This example inserts a timestamp value into COLUMNA of TABLET. The COLUMNA
definition specifies the data type TIMESTAMP DEFAULT CURRENT. This example
uses the JULIANTIMESTAMP and CONVERTTIMESTAMP system procedures and the
SQL CONVERTTIMESTAMP function.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 DATETIME PIC S9(18) COMP.
EXEC SQL END DECLARE SECTION END-EXEC.
PROCEDURE DIVISION.
MAIN-DRIVER.
...
* Get current Julian timestamp in Greenwich mean time.
ENTER TAL "JULIANTIMESTAMP" GIVING DATETIME.
* Convert timestamp to local time.
ENTER TAL "CONVERTTIMESTAMP" USING DATETIME GIVING DATETIME.
...
* Insert value into COLUMNA of TABLET.
EXEC SQL INSERT INTO TABLET (COLUMNA)
VALUES ( CONVERTTIMESTAMP (:DATETIME))
END-EXEC.
UPDATE Statement
The UPDATE statement updates the values in one or more columns in a single row or
a set of rows of a table or protection view. (To update a set of rows one row at a time
by using a cursor, see Using SQL Cursors on page 4-12.)
To execute an UPDATE statement, a process started by the program must have read
and write access to the table or view being updated and read access to any table or
view specified in subqueries of the search condition. For information about process
access, see Required Access Authority on page 7-1.
For audited tables and views, SQL/MP holds a lock on an updated row until the TMF
transaction is committed or rolled back. For a nonaudited table, SQL/MP holds the lock
until the program releases it.