Subject RE: [firebird-support] Subselects
Author Bogdan Mugerli
Thanx

Bogdan

It is not a very safe query. This should be more robust:

SELECT
m.VALID_FROM,
m.PRICE
FROM MATERIALCENA m
WHERE
m.MATERIALid = :IMATERIALID
AND m.VALID_FROM =
(select max(MC.VALID_FROM from materialcena mc
where mc.materialid = :imaterialid
and mc.VALID_FROM <= 'today')
INTO :VALID_FROM, :PRICE;

>After we restarted the server, the results are ok again

Probably a coincidence.

>PS.: this problem should have been solved years ago

It was solved years ago. It's really up to you to write good SQL to avoid
unpredictable results like you have observed. Fb 1.5 is much tighter on
these multi-table queries than its predecessors. To make use of the
improvement, write tight, clean SQL. Laxness with aliasing in self-referent
queries isn't clean.

/heLen




Yahoo! Groups Links