Subject | Re: [firebird-support] How to query all variable names from a database? |
---|---|
Author | Mark Rotteveel |
Post date | 2019-06-06T20:07:32Z |
On 2019-06-06 21:37, Gabor Boros mlnglsts@... [firebird-support]
wrote:
it isn't stored in the metadata tables contrary to parameters or
columns.
The variable name is available in the source column
(RDB$PROCEDURE_SOURCE), but as far as I can tell from small experiments
it isn't even in the compiled BLR, eg use CAST(RDB$PROCEDURE_BLR AS BLOB
SUB_TYPE TEXT) to show the BLR in 'readable' form. This is actually
pretty logical, because the name is only relevant for the human reading
and writing the code. For the runtime it is just a 'slot' with a
numerical id where a value is stored.
So there is no other mechanism to get variable names than to parse the
RDB$PROCEDURE_SOURCE yourself.
Mark
wrote:
> Hi All,Firebird has no need for the variable name as queryable information, so
>
> I need to know all stored procedure variable names from a (2.5)
> database. I not see these in system tables like parameters or fields.
> But I see these with a text editor. For example...
>
> Create a new database and a procedure in it:
>
> CREATE PROCEDURE MY_PROC AS DECLARE VARIABLE MY_VAR INTEGER; BEGIN END
>
> Set RDB$PROCEDURES.RDB$PROCEDURE_SOURCE to NULL.
>
> Backup the database with gbak. I see MY_VAR text in the resulting
> backup
> file (and in the restored database) with a text editor.
>
> So, where is the variable names stored and how to query these?
it isn't stored in the metadata tables contrary to parameters or
columns.
The variable name is available in the source column
(RDB$PROCEDURE_SOURCE), but as far as I can tell from small experiments
it isn't even in the compiled BLR, eg use CAST(RDB$PROCEDURE_BLR AS BLOB
SUB_TYPE TEXT) to show the BLR in 'readable' form. This is actually
pretty logical, because the name is only relevant for the human reading
and writing the code. For the runtime it is just a 'slot' with a
numerical id where a value is stored.
So there is no other mechanism to get variable names than to parse the
RDB$PROCEDURE_SOURCE yourself.
Mark