Subject Re: [firebird-support] How to Join to a Selectable Stored Procedure
Author Alexandre Benson Smith
Rick Debay wrote:
> I didn't know you could pass parameters from other tables in to a stored
> procedure inside a query. This will be very useful.
> BTW, what error will you get if you don't use an outer join?
>
>

Yes you can ! It's really nice !

Run this simple test case. Be carefull don't run it on you production
server since it does a count(*) it will be slow if you have tons of
records...

1.) Create this procedure;

set term ^;

create or alter procedure Foo (Name varchar(50)) returns (RecordCount
integer) as
begin
Execute Statement 'Select count(*) from ' || Name into :RecordCount;
suspend;
end^

set term ;^
commit;

2.) Run with inner join
select
R.RDB$Relation_Name, F.RecordCount
from
RDB$Relations R join
Foo (R.RDB$Relation_Name) F on (1=1)

you get
No current record for fetch operation
Invalid argument in EXECUTE STATEMENT - cannot convert to string
Statement: select
R.RDB$Relation_Name, F.RecordCount
from
RDB$Relations R join
Foo (R.RDB$Relation_Name) F on (1=1)


3.) Run with outer join
select
R.RDB$Relation_Name, F.RecordCount
from
RDB$Relations R join
Foo (R.RDB$Relation_Name) F on (1=1)

you get the correct results.

see you !

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