Subject | Re: [IB-Architect] Syntax of Declare Variable in storedprocs |
---|---|
Author | Frank Ingermann |
Post date | 2001-12-12T19:32:12Z |
Hi Ann / all,
"Ann W. Harrison" wrote:
Yes, i thought about that, too. But then: why would one use domains in the
first place for *columns*? -> check constraints, not null constraints,
defaults, character sets etc.
None of these (except for the charset maybe) makes any sense when declaring
vars in sp's. Should the engine raise an exception when a var based on a
"not null" domain isn't initialized properly to a non-null value? Should it
fill vars automatically with the default value as set in the domain ? Should
it enforce check constraints when you assign a value to a var somewhere in
a for..select loop ?? while it runs, or at Commit time ???
Moreover (as Helen pointed out): imagine you have a bunch of sp's using
vars based on a domain dom_x declared as integer. Then you go and change
that domain to be char(32). (i know this is academic as probably nobody ever
would do this, but the engine does not prevent you from doing it, so it is
a possible source of problems.) The re-definition of a domain would have
to imply re-compiling all the sp's that use it... the more you think about
it, the more problems come to mind.
I don't know very much about BLR and ODS, but afaikt they (both?) would have
to be changed to accomplish "vars based on domains" - that's why i asked for
a rather minor change in syntax rather than something with such a big impact...
(and the next question would definetly be "when i can use domains to declare
vars, why can't i use them to declare procedure parameters??"... i'll leave
that up to you as it has been discussed several times over ;-)
- and yes, i freely admit the only reason for my suggestion ís my laziness
in typing plus the fact that i'm used to declare vars that way in Delphi -
my no. 1 feature wish for FB x.x would be "please make the sp parser not
complain when i put a semicolon behind END where it doesn't like it!",
then i could write sp's {almost} like procs in Delphi... that aside.....
so, my vote (fwiw, and who am i to decide?) :
YES to: vardef ::= "declare variable" ident { "," ident } datatype ";".
as it's rather easy to implement and has low impact, but
NO to: vardef ::= "declare variable" ident [{ "," ident }] domain ";".
(unless someone *really* sees through all the implications and is
willing and able to do all the coding & testing :-)
regards,
fingerman
"Ann W. Harrison" wrote:
> At 09:12 AM 12/12/2001 +0100, Peter wrote:(wrt declare vars based on domains:)
> >How about declaring vars as domains
> >
> >declare variable i1 domain_integer;
> >
> >is this ever going to happen?
>
> At the moment, procedure variables are ephemeral -
> they completely disappear into the blr format of
> the procedure. But it's certainly a good idea.
Yes, i thought about that, too. But then: why would one use domains in the
first place for *columns*? -> check constraints, not null constraints,
defaults, character sets etc.
None of these (except for the charset maybe) makes any sense when declaring
vars in sp's. Should the engine raise an exception when a var based on a
"not null" domain isn't initialized properly to a non-null value? Should it
fill vars automatically with the default value as set in the domain ? Should
it enforce check constraints when you assign a value to a var somewhere in
a for..select loop ?? while it runs, or at Commit time ???
Moreover (as Helen pointed out): imagine you have a bunch of sp's using
vars based on a domain dom_x declared as integer. Then you go and change
that domain to be char(32). (i know this is academic as probably nobody ever
would do this, but the engine does not prevent you from doing it, so it is
a possible source of problems.) The re-definition of a domain would have
to imply re-compiling all the sp's that use it... the more you think about
it, the more problems come to mind.
I don't know very much about BLR and ODS, but afaikt they (both?) would have
to be changed to accomplish "vars based on domains" - that's why i asked for
a rather minor change in syntax rather than something with such a big impact...
(and the next question would definetly be "when i can use domains to declare
vars, why can't i use them to declare procedure parameters??"... i'll leave
that up to you as it has been discussed several times over ;-)
- and yes, i freely admit the only reason for my suggestion ís my laziness
in typing plus the fact that i'm used to declare vars that way in Delphi -
my no. 1 feature wish for FB x.x would be "please make the sp parser not
complain when i put a semicolon behind END where it doesn't like it!",
then i could write sp's {almost} like procs in Delphi... that aside.....
so, my vote (fwiw, and who am i to decide?) :
YES to: vardef ::= "declare variable" ident { "," ident } datatype ";".
as it's rather easy to implement and has low impact, but
NO to: vardef ::= "declare variable" ident [{ "," ident }] domain ";".
(unless someone *really* sees through all the implications and is
willing and able to do all the coding & testing :-)
regards,
fingerman