Subject | Re: Firebird Trigger Local Variable Gotcha |
---|---|
Author | Adam |
Post date | 2006-04-03T05:04:02Z |
> Interesting. Is there a built-in text logging feature planned forNot that I am aware of, the roadmap is available of FirebirdSQL.org.
> Firebird?
> It might come in handy for something like this that needs fullwrites
> tracing. Otherwise maybe i'll cook up some stored procedure that
> to an EXTERNAL TABLE.... someone stop me before i'm barking up thewrong
> tree again :).No that would also work, and in some ways is probably neater.
> So maybe to prevent the same bug to ever see me face to face again,the
> would it be better to change the "check whether something exists"
> construct from :
> ...
> select (blah) from (blah_table) into :blah_var;
> if (:blah_var is null) then begin
> -- normal processing here
> end;
> ...
>
> to
> ...
> if (exists(blah blah blah)) then begin
> select (blah) from (blah_table) into :blah_var;
> ...
> -- normal processing here
> end
> ...
>
> The downside is that it'd be slightly slower due to having to do
> query twice.Well the best way is
blah_var = NULL;
select (blah) from (blah_table) into :blah_var;
if (:blah_var is null) then begin
-- normal processing here
end;
I don't like the exists check because it is doubling the work. It is
also introducing another place you will need to maintain the query.
Whether that is significant enough to worry about, only you can
answer.
Of course if you do not need to know the value you are selecting but
only care about whether such a record exists, then exists is perfect
for that.
> +1 Clairvoyant. I'm a longtime Delphi guy :).Adam