| Firebird Documentation Index → Firebird 2.0 Language Ref. Update → PSQL statements → DECLARE |
![]() |
Available in: PSQL
Added in: 2.0
Description: Declares a named cursor and binds it to its own SELECT statement. The cursor can later be opened, used to walk the result set, and closed again. Positioned updates and deletes are also supported. PSQL cursors are available in triggers, stored procedures and EXECUTE BLOCK statements.
Syntax:
DECLARE [VARIABLE]cursornameCURSOR FOR (select-statement);
Example:
execute block
returns (relation char(31), sysflag int)
as
declare cur cursor for
(select rdb$relation_name, rdb$system_flag from rdb$relations);
begin
open cur;
while (1=1) do
begin
fetch cur into relation, sysflag;
if (row_count = 0) then leave;
suspend;
end
close cur;
end
See also: OPEN cursor, FETCH cursor, CLOSE cursor
Changed in: 1.5
Description: In Firebird 1.5 and above, a PSQL local variable can be initialized upon declaration. The VARIABLE keyword has become optional.
Syntax:
DECLARE [VARIABLE]varnamedatatype[{= | DEFAULT}value];
Example:
create procedure proccie (a int) returns (b int) as declare p int; declare q int = 8; declare r int default 9; declare variable s int; declare variable t int = 10; declare variable u int default 11; begin<intelligent code here>end
| Firebird Documentation Index → Firebird 2.0 Language Ref. Update → PSQL statements → DECLARE |