TMF Introduction (G06.24+)
TMF Application Programming
HP NonStop Transaction Management Facility (TMF) Introduction—522414-001
5-5
Accessing SQL Data
Accessing SQL Data
The NonStop SQL interface to TMF is implicit through the SQL data manipulation
statements SELECT, FETCH, DELETE, INSERT, and UPDATE. The application
selects the level of isolation. The locks to provide the selected isolation are
subsequently managed by TMF and the file system.
Applications can access a NonStop SQL database by using SQL statements
embedded in host language programs, including C, C++, COBOL85, and TAL.
The following example shows a cursor that accesses data from the PARTS table and
declares the intention of updating the data. (A cursor is a mechanism through which a
program retrieves a set of rows defined by the SELECT statement.)
EXEC SQL DECLARE list_by_partdesc_cursor CURSOR FOR
SELECT partnum, partdesc, price, qty_available
FROM sales.parts
WHERE (partdesc = :partdesc OF parts)
SERIALIZABLE ACCESS
FOR UPDATE OF PARTDESC, PRICE, QTY_AVAILABLE
END-EXEC.
After defining the set of rows, the program can retrieve them one-by-one and perform
update or delete operations on them; the program processes the cursor like a
sequential file.
The row in which the cursor is currently located is locked for exclusive access because
the FOR UPDATE clause was specified. As the program accesses rows through the
cursor, the rows remain locked until the transaction commits.
If this cursor were defined without the FOR UPDATE clause, the stable access option
would cause only the row in which the cursor is currently located to be locked with a
shared lock. The lock would be released when the next row becomes the current
position.
If this cursor were defined without the FOR UPDATE clause but with repeatable
access, all rows accessed through the cursor would remain locked until the transaction
commits.
Accessing Enscribe Data
Access to an Enscribe database is achieved either through programming language
statements or, for some languages, through calls to the system procedures for the
NonStop Kernel operating system. When applications access audited Enscribe files,
TMF automatically manages their transactions and data locking.
Standard language input/output provides access to Enscribe data for these languages:
COBOL, COBOL85, and FORTRAN. TACL has a built-in function, #REQUESTER,
that provides for reading and writing to Enscribe files.
System procedure calls provide access to Enscribe data for these languages: C, C++,
and TAL.