EasyManua.ls Logo

Sybase Adaptive Server Anywhere - Page 544

Sybase Adaptive Server Anywhere
1182 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
FETCH statement [ESQL] [SP]
526
FETCH RELATIVE 0 always re-fetches the row.
PURGE clause The PURGE clause is for use in embedded SQL only. It
causes the client to flush its buffers of all rows, and then send the fetch
request to the server. Note that this fetch request may return a block of rows.
FOR UPDATE clause The FOR UPDATE clause indicates that the
fetched row will subsequently be updated with an UPDATE WHERE
CURRENT OF CURSOR statement. This clause causes the database server
to put a write lock on the row. The lock will be held until the end of the
current transaction. See "How locking works" on page 413 of the book ASA
User’s Guide.
ARRAY clause The ARRAY clause is for use in Embedded SQL only. It
allows so-called wide fetches, which retrieve more than one row at a time,
and which may improve performance.
To use wide fetches in embedded SQL, include the fetch statement in your
code as follows:
EXEC SQL FETCH . . . ARRAY nnn
where ARRAY nnn is the last item of the FETCH statement. The fetch count
nnn can be a host variable. The SQLDA must contain nnn * (columns per
row) variables. The first row is placed in SQLDA variables 0 to (columns
per row)-1, and so on.
$ For a detailed example of using wide fetches, see the section "Fetching
more than one row at a time" on page 36 of the book ASA Programming
Interfaces Guide.
SQL/92 Entry level feature. Use in procedures is a Persistent Stored
Module feature.
Sybase Supported in Adaptive Server Enterprise.
The following is an Embedded SQL example.
EXEC SQL DECLARE cur_employee CURSOR FOR
SELECT emp_id, emp_lname FROM employee;
EXEC SQL OPEN cur_employee;
EXEC SQL FETCH cur_employee
INTO :emp_number, :emp_name:indicator;
The following is a procedure example:
BEGIN
DECLARE cur_employee CURSOR FOR
SELECT emp_lname
FROM employee;
DECLARE name CHAR(40);
OPEN cur_employee;
LOOP
Standards and
compatibility
Example

Table of Contents

Related product manuals