Subject | RE: [firebird-support] Subselects |
---|---|
Author | Bogdan Mugerli |
Post date | 2004-03-16T13:27:17Z |
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;
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
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 againProbably a coincidence.
>PS.: this problem should have been solved years agoIt 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