/usr/share/doc/firebird/sql.extensions
---------------- Cursor variables ---------------- Function: Allow usage of explicit or implicit cursors without needing the use of INTO clause in FETCH and FOR SELECT. An explicit cursor automatically becomes a cursor variable. An implicit cursor (FOR SELECT) needs the {AS CURSOR <name>} clause to become a cursor variable. Author: Adriano dos Santos Fernandes <adrianosf@gmail.com> Dmitry Yemanov <dimitr@users.sf.net> Syntax rules: 1) To unambiguously access a cursor variable, the cursor name should be prefixed by a colon. 2) A cursor variable may be accessed without a colon prefix, but in this case, depending on the scope of contexts present in a query, the name may resolve to a query context intead of a cursor. 3) It's allowed to use the colon prefix with trigger's NEW and OLD contexts. 4) Cursor variables are read-only. 5) A FOR SELECT without AS CURSOR needs the use of INTO, while with AS CURSOR it's not required, but still allowed. With FETCH, INTO is now optional. 6) It's allowed now to use the colon prefix when assigning to variables or NEW's fields. 7) Reading from a cursor variable returns the current field values. That means an UPDATE (with WHERE CURRENT OF) also updates the fields for subsequent reads. And DELETE (with WHERE CURRENT OF) makes subsequent reads to return NULL. Examples: 1. execute block returns (o char(31)) as declare c cursor for ( select rdb$relation_name name from rdb$relations ); begin open c; while (1 = 1) do begin fetch c; if (row_count = 0) then leave; o = :c.name; suspend; end close c; end 2. execute block returns (o char(31)) as begin for select rdb$relation_name name from rdb$relations as cursor c do begin o = :c.name; suspend; end end 3. execute block returns (o1 char(31), o2 char(31)) as begin for select rdb$relation_name from rdb$relations where rdb$relation_name = 'RDB$RELATIONS' as cursor c do begin for select :c.rdb$relation_name x1, -- prefixed, resolves to C cursor c.rdb$relation_name x2 -- unprefixed, resolved to this query rdb$relations (c) from rdb$relations c where rdb$relation_name = 'RDB$DATABASE' as cursor d do begin o1 = :d.x1; o2 = :d.x2; suspend; end end end
.
Edit
..
Edit
README.PSQL_stack_trace.txt
Edit
README.aggregate_filter.md
Edit
README.aggregate_tracking
Edit
README.alternate_string_quoting.txt
Edit
README.autonomous_transactions.txt
Edit
README.blob_append.md
Edit
README.builtin_functions.txt
Edit
README.case
Edit
README.coalesce
Edit
README.column_type_psql.txt
Edit
README.common_table_expressions
Edit
README.context_variables
Edit
README.context_variables2
Edit
README.cumulative_roles.txt
Edit
README.current_time
Edit
README.cursor_variables.txt
Edit
README.cursors
Edit
README.data_type_results_of_aggregations.txt
Edit
README.data_types
Edit
README.db_triggers.txt
Edit
README.ddl.txt
Edit
README.ddl_access.txt
Edit
README.ddl_triggers.txt
Edit
README.default_parameters
Edit
README.derived_tables.txt
Edit
README.distinct
Edit
README.domains_psql.txt
Edit
README.exception_handling
Edit
README.execute_block
Edit
README.execute_statement
Edit
README.execute_statement2
Edit
README.explicit_locks
Edit
README.expression_indices
Edit
README.external_connections_pool
Edit
README.floating_point_types.md
Edit
README.global_temporary_tables
Edit
README.hex_literals.txt
Edit
README.identity_columns.txt
Edit
README.iif
Edit
README.isc_info_xxx
Edit
README.joins.txt
Edit
README.keywords
Edit
README.leave_labels
Edit
README.length
Edit
README.linger
Edit
README.list
Edit
README.management_statements_psql.md
Edit
README.mapping.html
Edit
README.merge.txt
Edit
README.null_value
Edit
README.nullif
Edit
README.offset_fetch.txt
Edit
README.order_by_expressions_nulls
Edit
README.packages.txt
Edit
README.plan
Edit
README.regr_functions.txt
Edit
README.returning
Edit
README.rows
Edit
README.savepoints
Edit
README.scrollable_cursors.txt
Edit
README.select_expressions
Edit
README.sequence_generators
Edit
README.set_bind.md
Edit
README.set_role
Edit
README.set_transaction.txt
Edit
README.similar_to.txt
Edit
README.sql_security.txt
Edit
README.statistical_functions.txt
Edit
README.subroutines.txt
Edit
README.substring_similar.txt
Edit
README.time_zone.md
Edit
README.trim
Edit
README.universal_triggers
Edit
README.update_or_insert
Edit
README.user_management
Edit
README.view_updates
Edit
README.window_functions.md
Edit