On Tue, Aug 16, 2022 at 3:48 AM Mark Rotteveel <m...@lawinegevaar.nl> wrote:

>
> Am I reading this correctly that your proposal is to use the following
> syntax?
>
> execute sql (p1 integer, p2 varchar(50))
> do
>    select * from t where t.id = :p1 and t.name = :p2
>
> So, no explicit positional parameter markers ('?')?
>
>
Not exactly. I split proposal in two:

1) Add named parameters

This will become valid (in server):

-----
select *
    from rdb$database
    where rdb$relation_id = :relation_id or
               rdb$relation_id = :relation_id

Will report a single parameter, with name RELATION_ID.
-----

Unnamed parameters (question marks) will still be allowed.

-----
select *
    from rdb$database
    where rdb$relation_id = :relation_id or
               rdb$relation_id = ? or
               rdb$relation_id = :relation_id

This will report parameters in order: RELATION_ID, unnamed
-----

With this, EXECUTE BLOCK can be simplified and "= ?" in input parameters
becomes optional.

2) Add EXECUTE SQL (maybe with another name)

It will support named and unnamed parameters.

So, given your example, it would be valid, but this one too:

-----
execute sql (p1 integer)
do
     select *
         from t
         where t.id = :p1 and
                    t.name = :p2 and
                    t.whatever = ?
-----

Explicit parameters in the argument list will be like EXECUTE BLOCK (may
use or not "= ?").

In this way we create a path that we should have already created many times
ago, to avoid clients doing server business.

Only who can want would use unnamed parameters, and since these are
top-level commands, one would not use them if their framework does not
support them.


Adriano
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to