Subject Re: [firebird-support] Data type of rdb$db_key
Author Pavel Cisar
Hi,

RDB$DB_KEY is a strange beast. It's in fact a binary array of bytes,
eight bytes long for each source table included in output (i.e. it could
be longer than eight bytes for views for example).

db_key could be stored in char(8xsource streams) field / local variable,
but it's not regular cstring, if anything it should be char(x) character
set octets :-)

Now to the difference you have seen:

> SQL> select rdb$db_key from articulos;
>
> DB_KEY
> ================
>
> 0000008500000001
> 0000008500000002
>
> but
>
> SQL> select * from proves('ARTICULOS');
>
> NUM
> ================
>
> ŕ
> ŕ

That's because ISQL has special handling for rdb$db_key fields. isql
*knows* that they may contains unprintable characters and are in fact
binary arrays, so shows them as hex numbers. But your stored procedure
obfuscated the rdb$db_key, so isql treat it as any other varchar.

Solution is quite simple, rename your SP's output parameter from NUM to
DB_KEY.

Of course, this is a special "feature" of isql, and you'll get "mangled"
output in other tools that do not support it, like IBExpert etc.

Best regards
Pavel Cisar (ICQ: 89017288)
http://www.ibphoenix.com
For all your upto date Firebird and
InterBase information