SQL/MP Programming Manual for C

Data Retrieval and Modification
HP NonStop SQL/MP Programming Manual for C429847-008
4-10
Inserting a Timestamp Value
Inserting a Timestamp Value
This example inserts a timestamp value into tablet.columna. The columna
definition specifies the data type TIMESTAMP DEFAULT CURRENT. The example
uses the JULIANTIMESTAMP system procedures and the SQL
CONVERTTIMESTAMP function. To call system procedures, a program must include
declarations from the cextdecs header file.
#include <cextdecs(JULIANTIMESTAMP)>
...
EXEC SQL BEGIN DECLARE SECTION;
long long dtvar;
EXEC SQL END DECLARE SECTION;
short sqlcode;
int main(void)
{
...
/* Get Julian timestamp in GMT: */
dtvar = JULIANTIMESTAMP();
EXEC SQL BEGIN WORK;
/* Insert value into tablet: */
EXEC SQL INSERT INTO tablet (columna)
VALUES (CONVERTTIMESTAMP (:dtvar));
EXEC SQL COMMIT WORK;
...
}
UPDATE Statement
The UPDATE statement updates the values in one or more columns in a single row or
in a set of rows of a table or protection view.
To update a set of rows, one row at a time using a cursor, see Using SQL Cursors on
page 4-14.
To run 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 tables or views
specified in subqueries of the search condition. For details, see Required
Access Authority on page 7-1.
For audited tables and views, NonStop SQL/MP holds a lock on an updated row until
the TMF transaction is committed or rolled back. For a nonaudited table, NonStop
SQL/MP holds the lock until the program releases it.