Subject | Re: Can you guess the result of this query? :) |
---|---|
Author | Adam |
Post date | 2006-08-13T23:34:02Z |
--- In firebird-support@yahoogroups.com, Milan Babuskov <milanb@...>
wrote:
Just confirmed it though through experimentation. :D
I am predicting at some stage you will end up with a singleton type
error when your 'select new.old from new where old.old = new.old'
statement manages to return more than a single value.
I don't think the obscurity would be of much help though considering
there are some pretty simple tricks to checking the value inside the
procedure.
But don't ever do that to me on Monday morning again. My brain just
doesn't work this early ;)
Adam
wrote:
>NEW or
> Who says we don't want FB to be strict with ambiguity:
>
> create table new ( old INTEGER );
> SET TERM ^ ;
> CREATE TRIGGER NEW_BU1 FOR NEW ACTIVE BEFORE UPDATE POSITION 0 AS
> BEGIN
> select new.old from new where old.old = new.old
> into new.old;
> END^
> SET TERM ; ^
>
> INSERT INTO NEW (OLD) VALUES (1);
> update new set old = 2;
> select * from NEW;
>
> Can you guess what this query would return? 1, 2 or NULL? ;)
>
> P.S. This is only for fun. I doubt anyone would name their tables
> OLD.I did guess 1, although I did not have confidence in my assumption.
Just confirmed it though through experimentation. :D
I am predicting at some stage you will end up with a singleton type
error when your 'select new.old from new where old.old = new.old'
statement manages to return more than a single value.
I don't think the obscurity would be of much help though considering
there are some pretty simple tricks to checking the value inside the
procedure.
But don't ever do that to me on Monday morning again. My brain just
doesn't work this early ;)
Adam