On 15/08/2022 04:16, Simonov Denis via Firebird-devel wrote:
> 
> Very good feature, reminds me of the functionality from Oracle
> 
> WITH Procedure p1 ...
>  AS
> ...
> FUNCTION f1 ...
> AS
> ...
> SELECT...
> 

Plus, DECLARE VAR := ?

But things are very less useful for them due to their BEGIN...END blocks
not capable of produce multiple rows result, nor subfunctions not able
to be pipelined, etc.


> However, it's not entirely clear to me how client applications handle
> named parameters (which will be replaced with "?")? It seems to me
> unnamed parameters "?" (which in client applications will most likely be
> named) leave either in the <input parameter list> or in the request
> itself. I vote for them to remain only in the request.
> 

Firebird does not have any support for client named parameters.

As Mark told, it will require client support.


> Just try to implement EXECUTE STATEMENT with your syntax and support for
> named parameters, then it will become clear what I'm talking about. My
> option is this.
> 

I suppose if standalone statements is going to have support of named
parameters as EXECUTE STATEMENT, undeclared named parameters are going
to be automatically declared and comes after the explicit ones.


> Syntax:
> 
> execute sql
>     [<subroutines>]
> do <sql command>
> 
> Here is how it can be used:
> 
> execute sql
>     declare function subfunc (i1 integer) returns integer
>     as
>     begin
>         return i1;
>     end
> 
>     declare procedure subproc (i1 integer) returns (o1 integer)
>     as
>     begin
>         o1 = i1;
>         suspend;
>     end
> do
> select subfunc(?) + o1
>     from subproc(?)
> 

This reduces a lot the usefulness of the statement and I do not agree.

A path I can follow is to be like Oracle and have the "parameters"
declared as variables:

-----
execute sql
    declare variable p1 integer = ?;
    declare variable p2 integer = ?;

    declare function subfunc (i1 integer) returns integer
    as
    begin
        return i1;
    end

    declare procedure subproc (i1 integer) returns (o1 integer)
    as
    begin
        o1 = i1;
        suspend;
    end
do
select subfunc(:p1) + o1
    from subproc(:p2 + ?)
-----

But I still prefer parameters to be parameters, like in EXECUTE BLOCK.


Adriano


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

Reply via email to