Subject Re: [firebird-support] DBKEY or cursor in PSQL
Author Dalton Calford
Thanks Helen,

This is a query running on a FB 1.54 server, so I am stuck with the old
syntax.

best regards

Dalton

On Fri, 2008-12-05 at 08:10 +1100, Helen Borrie wrote:
> 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
> >begin
> ><do some work>
> >update YAK set Foo=:var_work where RDB$DB_KEY=:var_yak;
> >end
> >
> >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
> FOR UPDATE
> into :var_foo, :var_yak
> AS CURSOR aCursor
> do begin
> <do some work>
> update YAK set Foo=:var_work
> where current of aCursor ;
> end
>
> If you're on Fb 2 or hgher, you'll already be aware of the PSQL cursor
> enhancements that came with v.2....
>
> ./heLen
>
>
>
>
>
>


[Non-text portions of this message have been removed]