Subject | Re: [Firebird-Architect] Exec. statement parameters |
---|---|
Author | Vlad Khorsun |
Post date | 2007-12-14T10:32:46Z |
> Vlad,Yes.
>
> We do not have parameters in EXEC. STMT, boolean datatype, named
> parameters for SPs and named parameters in DSQL.
> So here examples with my preferred syntax for boolean datatype,I don't agree with your EXEC BLOCK changes.
> parameters in EXEC. STMT and named parameters for SPs.
> I didn't even put examples of DSQL named parameters.
> Please try to reproduce this code with your syntax. You will see howexecute block (
> ambiguous and confusion it is (will be, when all constructions are
> available).
>
> -------------
> -- procedure p(i boolean);
>
> -- should be valid
> execute block (
> i integer
> ) returns (
> o boolean
> )
> as
> begin
> select a = c from t where a = :i into :o;
> execute procedure p(i = 1);
> end;
i integer = ?
) returns (
o boolean
)
as
begin
select a = c from t where a = :i into :o;
execute procedure p(i = 1);
end;
I see no problem here
> -- should be validexecute block (
> execute block (
> i integer
> ) returns (
> o boolean
> )
> as
> begin
> execute statement 'select a = c from t where a = ?' (i) into :o;
> end;
i integer = ?
) returns (
o boolean
)
as
begin
execute statement 'select a = c from t where a = :x' (x = i) into :o;
end;
Again, no problem
> -- should be validexecute block (
> execute block (
> i integer
> ) returns (
> o boolean
> )
> as
> begin
> execute statement 'select a = c from t where ? is true' (i = 1) into :o;
> end;
i integer = ?
) returns (
o boolean
)
as
begin
execute statement 'select a = c from t where :x is true' (x = i = 1) into :o;
-- or
execute statement 'select a = c from t where :x is true' (x = (i = 1)) into :o;
end;
There is chance for ambiguity in x = i = 1 expression
> -- should be validexecute block (
> execute block (
> i integer
> ) returns (
> o boolean
> )
> as
> begin
> execute statement 'select a = c from t where a = :i' (i := i) into :o;
> execute procedure p(i := i = 1);
> end;
i integer = ?
) returns (
o boolean
)
as
begin
execute statement 'select a = c from t where a = :i' (i = i) into :o;
execute procedure p(i = i = 1);
-- or
execute procedure p(i = (i = 1));
end;
Same as above
> -- should be validexecute block (
> execute block (
> i integer
> ) returns (
> o boolean
> )
> as
> begin
> execute statement 'select a = c from t where :i is true' (i = 1) into :o;
> end;
i integer = ?
) returns (
o boolean
)
as
begin
execute statement 'select a = c from t where :i is true' (i = 1) into :o;
end;
No problems at all
> -------------You not answer on my question :
why "x = a = b" is not ambiguous in PSQL block of code
but is ambiguous in EXEC STMT input parameter syntax ?
If we decide both examples are ambuguois then we will fail to introduce support
of boolean expressions or will force users to use := for assignment (or == for comparison).
If we decide both are not ambuguois then no problems except of not very clear look
of expressions like x = a = b = c = d, which have workaround with brackets :
x = ((a = b) = (c = d))
> PS: I don't know exactly how Borland implemented boolean type in IB.AFAIR, they just implemented data type. No expressions support.
> I've only heard it's ugly.Yes, but there are no more complains from users about absent BOOLEAN data type ;)
Regards,
Vlad