Subject Re: exists(EXECUTE STATEMENT ...
Author rcrfb
--- In firebird-support@yahoogroups.com, Bjoern Reimer <reimer@s...>
wrote:
> Hi Helen,
>
> >>Hi,
> >>
> >> (Firebird 1.5.1 CS on Linux)
> >> in PSQL the following statement doesn't work:
> >>
> >> [...]
> >> "SQL" = 'SELECT "Id" FROM "SomeTable" WHERE "Fieldname" ='||
> >> "ParameterOfSP";
> >>
> >> IF (not exists(EXECUTE STATEMENT "SQL")) THEN
> >> [...]
> >>
> >>
> >> Did I make a syntax error
>
> HB> :-)
>
> >>or is this a missing feature of firebird?
>
> HB> EXECUTE STATEMENT is a PSQL statement syntax in its own right.
You can't
> HB> use it as some sort of extended "variable" to substitute into
syntax of a
> HB> DSQL statement (or any other statement at all).
>
> HB> On the other side of the coin, an EXISTS() predicate can not
take any kind
> HB> of argument except a subquery.
>
> Ok.
> But would be a nice enchantment, wouldn't it?
> As EXISTS only Checks, whether there is a result or not it should be
> possible I think.
>
> [...]
>
>
> HB> Back to the drawing board? You'll find the description and
examples in the
> HB> v.1.5 Release Notes.
>
> I've read them but there was nothing about Exists :-)
>
> I 've changed the query to a select count("Id")... INTO :"Counter"
> which perfectly works.
>
>
> HB> By the way, did you know that these infernal double quotes are
not required?
>
> Yes, but I normally I use mixed case variables. They are better
> readable I think! But I know that many people are to lazy to enter
> this two chars....
>
Hi Bjoern,

you really need these quotes here because you created the tables (and
columns, ..) using these quotes. Without quotes, all these objects
will be automatically converted to uppercase; this hits all (?)
database objects like tables, indices, columns, constraints (I really
do not know if that's true for UDFs or for PLSQL-Variables).
So
create table "SomeTable" ...
creates a table 'SomeTable' (casesensitive) while
create table SomeTable ...
creates a table'SOME_TABLE' (caseinsensitive)

But Helen is right - good SQL-Style is not to use quotes.
Anyway you can use mixed case, but the database won't :-)


Roger

>
> Thank you
>
>
> Bjoern
>
> --
> SOFTbaer --- reimer@s... --- www.softbaer.de