With the introduction of schemas in Firebird 6.0, the syntax <name>.<name>
- used for tables, views, procedures,
and functions (both standalone and packaged) - introduces ambiguity when resolving object names using the schema
search path. The ambiguity arises between:
<schema>.<object>
(a schema and its object)<package>.<object>
(a package and its object)
This document focuses on name resolution rules for tables, views, procedures, and functions within queries and code blocks.
To resolve these ambiguities, Firebird introduces a scope specifier, represented by the %
symbol. This
allows unambiguous referencing of objects.
<name> % { SCHEMA | PACKAGE } . <name>
select *
from plg$profiler%schema.plg$prof_sessions;
execute procedure rdb$profiler%package.pause_session;
call rdb$profiler%package.pause_session();
select rdb$time_zone_util%package.database_version()
from system%schema.rdb$database;
select *
from rdb$time_zone_util%package.transitions('America/Sao_Paulo', timestamp '2017-01-01', timestamp '2019-01-01');
Firebird resolves object names following a structured sequence of rules. Once an object is located, the resolution process halts, ensuring no ambiguity errors occur.
-
name1.name2.name3
- Look for routine
name3
inside packagename2
, inside schemaname1
.
- Look for routine
-
name1%schema.name2
- Look for object
name2
inside schemaname1
.
- Look for object
-
name1%package.name2
- Look for object
name2
inside a packagename1
using the schema search path.
- Look for object
-
name1.name2
- If inside a package named
name1
, look for routinename2
in the same package. - Look in schema
name1
for objectname2
. - Look for object
name2
inside a packagename1
using the schema search path.
- If inside a package named
-
name
- Look for subroutine
name
. - If inside a package, look for routine
name
in the same package. - Look for object
name
using the schema search path.
- Look for subroutine
Note: Object resolution also depends on the context in which they are used. For example, in
select * from name1.name2
,name2
could be a table, view, or procedure. However, inexecute procedure name1.name2
,name2
must be a procedure. This distinction means that anexecute procedure
command versus aselect
command can resolve to different objects.