Subject Re: [firebird-support] DBKEY or cursor in PSQL
Author Helen Borrie
At 07:16 AM 5/12/2008, you wrote:
>This is probably a newbie question but I have never before tried this
>particular trick. (I always use surrogate keys, go figure)
>I have a table where I want to update a specific row returned from a
>query, but, the only guaranteed unique identifier happens to the dbkey.
>This is for a one-time process that I wish to perform in PSQL.
>for example
>for select FOO, RDB$DB_KEY from YAK into :var_foo, :var_yak
><do some work>
>update YAK set Foo=:var_work where RDB$DB_KEY=:var_yak;
>I need to know what type of variable :var_yak needs to be defined as.
>I could also use a cursor and current type syntax but I have not been
>able to find example code for this.

Actually, the cursor syntax uses the rdb$db_key to determine WHERE CURRENT position anyway. No variables: the loop knows where it is...

The old syntax (pre Fb 2)

for select FOO from YAK
into :var_foo, :var_yak
do begin
<do some work>
update YAK set Foo=:var_work
where current of aCursor ;

If you're on Fb 2 or hgher, you'll already be aware of the PSQL cursor enhancements that came with v.2....