12.3. RDB$SQL
A package with utility routines to work with dynamic SQL.
12.3.1. Procedure EXPLAIN
A selectable procedure that returns a tabular representation of a query’s plan, without executing the query.
SQLtype
BLOB SUB_TYPE TEXT CHARACTER SET UTF8— query statement
PLAN_LINEtype
INTEGER— plan’s line orderRECORD_SOURCE_IDtype
BIGINT— record source idPARENT_RECORD_SOURCE_IDtype
BIGINT- parent record source idLEVELtype
INTEGER— indentation level (may have gaps in relation to parent’s level)SCHEMA_NAMEtype
RDB$SCHEMA_NAME— schema name of object (table, procedure)PACKAGE_NAMEtype
RDB$PACKAGE_NAME— package name of a stored procedureOBJECT_NAMEtype
RDB$RELATION_NAME— object (table, procedure) nameALIAStype
RDB$SHORT_DESCRIPTION— alias nameRECORD_LENGTHtype
INTEGER— record length for the record sourceKEY_LENGTHtype
INTEGER— key length for the record sourceACCESS_PATHtype
RDB$DESCRIPTION— friendly plan description
As SQL statements can contain quotes, it is recommended to use alternative string literals (Q-literals). If your statement text also contains Q-literals, make sure to use another start and end pair.
Example single line
select *
from RDB$SQL.EXPLAIN('select * from EMPLOYEE where EMP_NO = ?');
Example multi-line (with Q-literal)
select *
from RDB$SQL.EXPLAIN(q'{
select *
from (
select FULL_NAME NAME from EMPLOYEE
union all
select CUSTOMER NAME from CUSTOMER
)
where NAME = ?
}');
12.3.2. Procedure PARSE_UNQUALIFIED_NAMES
A selectable procedure that parses a list of unqualified SQL identifiers and returns a row for each identifier. The input must follow syntax rules for names and the output of unquoted names are uppercased.
NAMEStype
VARCHAR(8191) CHARACTER SET UTF8— list of SQL identifiers
NAMEtype
RDB$RELATION_NAME— a single SQL identifier, normalised to how identifiers are stored in the metadata tables
select *from RDB$SQL.PARSE_UNQUALIFIED_NAMES('schema1, schema2, "schema3", "schema 4", "schema ""5"""');-- SCHEMA1-- SCHEMA2-- schema3-- schema 4-- schema "5"