Subject Re: [firebird-support] Several SP parameters requested only
Author Alexandre Benson Smith
Adomas Urbanavicius wrote:

>Yes, in fact this is how it done now, but as far, as engine knows what
>is requested : why should app client about passing aditional args.
>And by the way, I think, VIEWS work in this way.
>
>
Adomas,

In an ideal world maybe :-)

But I think will be hard to the engine to know what parameters is
requested and transmogrify the code to handle this, and even harder to
know what parts of the calc should be performed beacuse other parts
depend on it.

Lets examie this pseudo-code

create procedure MyProc returns (a integer, b integer, c integer) as
begin
for
select
a, b, c
from
MyTable
into
:a, :b, :c
do begin

if (a > c) then
c = a;

Suspend;
end
end;

if I do

select a, b, c from MyProc the procedure should be executed entirely

if I do

select B from MyProc the If should not be execute neither column A and C
should be read from the table and the SP would be transmogrified to:
create procedure MyProc returns (a integer, b integer, c integer) as
begin
for
select
b
from
MyTable
into
:b
do begin
Suspend;
end
end;

I think it is a hard work don't you think ?

and what about this one:
create procedure MyProc returns (a integer, b integer, c integer) as
begin
for
select
a.a, b.b, c.c
from
MyTableA a join
MyTableB b on (a.id = b.id) join
MyTableC c on (c.id = b.id)
into
:a, :b, :c
do begin

if (a > c) then
c = a;

Suspend;
end
end;

if I do

select B from MyProc

should it be modified to:

create procedure MyProc returns (a integer, b integer, c integer) as
begin
for
select
b.b
from
MyTableB b
into
:b
do begin
Suspend;
end
end;

?

If so, the result coud not be the same since the joins are removed it
will retrieve records from MyTableB that has no correspondece on
MyTableA and MyTableC

I think it is to dificult to in run time modify a compiled code and even
don't know if the BLR will contain enough data to make those assumptions.

Have you looked at Execute Statement ? Maybe it can help you...


About the views:
The view has a pre-define select statement that is executed by the
engine so if you have a view like:

Create MyView (A, B, C) as
select
A.A, B.B, C.C
from
MyTableA A join
MyTableB B on (B.ID = A.ID) join
MyTableC C on (C.ID = B.ID)

and issue

select B from MyView, the join will be performed in any way, take a look
at the execution plan to confirm it.

see you !

--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br