Subject | Re: [firebird-support] Debugging Stored Procedures |
---|---|
Author | Milan Babuskov |
Post date | 2006-07-26T18:14:12Z |
jrodenhi wrote:
select something
from sometable
into :somevariable;
I case SELECT returns the empty set, the "somevariable" doesn't become
NULL, but it is left as it was. If you don't initialize it, you have
some random data there.
Therefore, make sure you initialize variables before "select ... into"
construct:
somevariable = 'default value';
select something
from sometable
into :somevariable;
Also, at some point I think everyone of us tried:
somevariable = (select ...);
That does not work, you need to "select ... into :somevariable".
triggers you can change the values before they get written, etc. But,
PSQL is pretty much the same.
--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org
> Have you come up with any tricks forBesides what others noted, one mistake is common for beginners:
> debugging stored procedures that help you a lot?
select something
from sometable
into :somevariable;
I case SELECT returns the empty set, the "somevariable" doesn't become
NULL, but it is left as it was. If you don't initialize it, you have
some random data there.
Therefore, make sure you initialize variables before "select ... into"
construct:
somevariable = 'default value';
select something
from sometable
into :somevariable;
Also, at some point I think everyone of us tried:
somevariable = (select ...);
That does not work, you need to "select ... into :somevariable".
> Do you do anythingWell, you have new. and old. relations avaialble, and with BEFORE
> different with triggers?
triggers you can change the values before they get written, etc. But,
PSQL is pretty much the same.
> Or, maybe a little simpler, do you have aWhen it's part of SQL statement, use it. Otherwise, don't.
> simple rule for when you use a colon with a variable and when you don't?
--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org