OPEN statement [ESQL] [SP]
572
♦
Sybase The simple OPEN cursor-name syntax is supported by
Adaptive Server Enterprise. None of the other clauses are supported in
Adaptive Server Enterprise stored procedures. Open Client/Open Server
supports the USING descriptor or host variable syntax.
♦ The following examples show the use of OPEN in Embedded SQL.
1. EXEC SQL OPEN employee_cursor;
2. EXEC SQL PREPARE emp_stat FROM
’SELECT empnum, empname FROM employee WHERE name
like ?’;
EXEC SQL DECLARE employee_cursor CURSOR FOR
emp_stat;
EXEC SQL OPEN employee_cursor USING :pattern;
♦ The following example is from a procedure or trigger.
BEGIN
DECLARE cur_employee CURSOR FOR
SELECT emp_lname
FROM employee;
DECLARE name CHAR(40);
OPEN cur_employee;
LOOP
FETCH NEXT cur_employee into name;
...
END LOOP
CLOSE cur_employee;
END
Examples