Subject Re: [firebird-support] Updating with rdb$db_key
Author Ann W. Harrison
buppcpp@... wrote:
> Since the DB_KEY is binary/hex values how do you update a row by using a
> literal string?
>
> The following examples don't work:
> "UPDATE mytable set qty = 5 where rdb$db_key = '0000022600000001'"
> "UPDATE mytable set qty = 5 where rdb$db_key = 0x0000022600000001" (this one
> works in SQL Server)
>

No, neither of those work. We don't implement the 0x indicator for hex
values (yet). This sequence does work:

SQL> create table t1 (f1 integer);
SQL> insert into t1 (f1) values (1);
SQL> create table selector (f1 char(8) character set octets);
SQL> insert into selector (f1) select rdb$db_key from t1;
SQL> select f1 from t1 t
SQL> select t.f1 from t1 t
CON> join selector s on s.f1 = t.rdb$db_key;

F1
============

1


You'll need to store the rdb$db_key value into an appropriate length
byte array - char (x) character set octets. It is neither a printable
string nor a number, so neither the 'xxx' or nnn value format works.

Regards,


Ann