Subject Re: [ib-support] Newbie : Update with select statement
Author Jenny Sigvardsdotter
Hi again!
Thanks for your reply Set but:
I think I was not clear when I asked my question. The
:new_batchid is a parameter and not a field in akt. So
I cant select it from akt.
What I want is to update aktkonto only where it is
connected to an akt via aktid and the akt has EBV = 1.
I�m not sure I made it clearer by that explanation :-)

The last part is not needed here but excellent in an
other query so I�m going to use it there instead.


--- Svein Erling Tysvaer
<svein.erling.tysvaer@...> wrote:
> Hi again Jenny!
>
> You have to kind of split this into two and use a
> subselect:
>
> UPDATE aktkonto
> set batchid=(select new_batchid
> from akt a1
> where a1.aktid = aktkonto.aktid
> and a1.EBV = 1)
> where aktkonto.batchcode = 1
> and exists(select 1
> from akt a2
> where a2.aktid = aktkonto.aktid
> and a2.EBV = 1)
>
> The exists is to make sure that batchid isn't
> updated if there should
> happen to be any aktid that exists in aktkonto but
> not in akt. If this is
> never the case, you do not need the last part.
>
> Set
>
> At 03:02 27.08.2002 -0700, you wrote:
> >UPDATE aktkonto
> >set batchid=:new_batchid,
> >from akt
> >where akt.aktid = aktkonto.aktid
> >and aktkonto.batchcode = 1
> >and akt.EBV = 1
>
>


__________________________________________________
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com