Subject | Re: [firebird-support] Derived Tables in PSQL |
---|---|
Author | jft |
Post date | 2007-03-29T02:14:06Z |
Rade,
In a word, yes.
Try this in iSQL:
/* */
/* illustrates derived tables (including joins thereon) */
/* in procedures in FB2 */
create table TEST1(Int1 int, Int2 int);
commit;
create table TEST2(Int1 int, Int2 int);
commit;
create table TEST3(Int1 int, Int2 int);
commit;
set term ^;
recreate procedure TEST_DERIVED
as
begin
insert into TEST1(Int1,Int2)
select x,y from (select 1,111 from RDB$DATABASE) as DT1(x,y);
insert into TEST2(Int1,Int2)
select x,y from (select 1,222 from RDB$DATABASE) as DT2(x,y);
insert into TEST3(Int1,Int2)
select DT3.y, DT4.y
from (select Int1,Int2 from TEST1) as DT3(x,y)
join (select Int1,Int2 from TEST2) as DT4(x,y)
on DT3.x = DT4.x;
end^
set term ;^
commit;
execute procedure TEST_DERIVED;
commit;
select Int1,Int2 from TEST3 /* returns 111,222 */;
commit;
drop procedure TEST_DERIVED;
commit;
drop table TEST1;
drop table TEST2;
drop table TEST3;
commit;
/* */
HTH,
John
In a word, yes.
Try this in iSQL:
/* */
/* illustrates derived tables (including joins thereon) */
/* in procedures in FB2 */
create table TEST1(Int1 int, Int2 int);
commit;
create table TEST2(Int1 int, Int2 int);
commit;
create table TEST3(Int1 int, Int2 int);
commit;
set term ^;
recreate procedure TEST_DERIVED
as
begin
insert into TEST1(Int1,Int2)
select x,y from (select 1,111 from RDB$DATABASE) as DT1(x,y);
insert into TEST2(Int1,Int2)
select x,y from (select 1,222 from RDB$DATABASE) as DT2(x,y);
insert into TEST3(Int1,Int2)
select DT3.y, DT4.y
from (select Int1,Int2 from TEST1) as DT3(x,y)
join (select Int1,Int2 from TEST2) as DT4(x,y)
on DT3.x = DT4.x;
end^
set term ;^
commit;
execute procedure TEST_DERIVED;
commit;
select Int1,Int2 from TEST3 /* returns 111,222 */;
commit;
drop procedure TEST_DERIVED;
commit;
drop table TEST1;
drop table TEST2;
drop table TEST3;
commit;
/* */
HTH,
John
> -------Original Message-------
> From: radevojvodic <vrade@...>
> Subject: [firebird-support] Derived Tables in PSQL
> Sent: 29 Mar '07 04:05
>
> Hi All,
>
> Is there any possibility of using Derived Tables feature of Firebird 2
> in PSQL (stored procedure returns an error when i try to make for
> select statement with derived table join included)
>
> Rade
>
>