Subject Re: [ib-support] SQL Question
Author Svein Erling Tysvær
Hi Robert!

>Why does this need two instances of Mempay2?

Because you're a) updating it and b) using a subselect do determine the
existence of a record within it.

>What does SELECT 1 mean at <--- below?
> WHERE (EXISTS (SELECT 1 FROM MEMPAY2 M2 <---

Nothing - you're just interested in there being a record and don't care
what it contains. Using
WHERE (EXISTS (SELECT 'Norwegian humour' FROM MEMPAY2 M2
would work equally well - just consuming slightly more resources.

>Why is an SP, "the safe route"?
Probably because the way you originally wrote your query updated every
single row in your table satisfying your criteria (including those where
your subselect returned null) and that such an error would have been easier
to spot in a SP.

Set