Subject | Re: [IB-Architect] Enhanced handling of EXECUTE PROCEDURE statement |
---|---|
Author | Markus Kemper |
Post date | 2000-06-16T22:00:01Z |
Jason,
view and a trigger as seen in the following example.
---
connect 'test.gdb'
user 'sysdba' password 'masterkey';
drop database;
create database 'test.gdb'
user 'sysdba' password 'masterkey';
set auto off;
create domain ch10 char( 10 );
create domain sint smallint;
commit;
create table t0 (
id sint,
f1 ch10,
f2 ch10
);
commit;
create table t1 (
id sint,
f1 ch10
);
commit;
create table t2 (
id sint,
f1 ch10
);
commit;
insert into t0 values ( 1, 'test', 'data' );
commit;
create view t4 ( id, f1, f2 ) as
select t1.id, t1.f1, t2.f1
from t1, t2
where t1.id = t2.id;
commit;
set term ^^;
create trigger trg_ins_for_t4 for t4
active before insert position 10
as begin
insert into t1 values ( new.id, new.f1 );
insert into t2 values ( new.id, new.f2 );
end^^
commit^^
set term ;^^
insert into t4 ( id, f1, f2 )
select id, f1, f2 from t0;
commit;
select * from t4;
commit;
----
Output:
D:\work\temp>isql -i test.sql
Use CONNECT or CREATE DATABASE to specify a database
Database: 'test.gdb', User: sysdba
ID F1 F2
====== ========== ==========
1 test data
> I would have to say because it allows one to take action on multiple tables.You might be able to accomplish your goal with a "non-updatable"
> If I were just dealing with one table and needed to do various manipulations
> I would just use a trigger.
view and a trigger as seen in the following example.
---
connect 'test.gdb'
user 'sysdba' password 'masterkey';
drop database;
create database 'test.gdb'
user 'sysdba' password 'masterkey';
set auto off;
create domain ch10 char( 10 );
create domain sint smallint;
commit;
create table t0 (
id sint,
f1 ch10,
f2 ch10
);
commit;
create table t1 (
id sint,
f1 ch10
);
commit;
create table t2 (
id sint,
f1 ch10
);
commit;
insert into t0 values ( 1, 'test', 'data' );
commit;
create view t4 ( id, f1, f2 ) as
select t1.id, t1.f1, t2.f1
from t1, t2
where t1.id = t2.id;
commit;
set term ^^;
create trigger trg_ins_for_t4 for t4
active before insert position 10
as begin
insert into t1 values ( new.id, new.f1 );
insert into t2 values ( new.id, new.f2 );
end^^
commit^^
set term ;^^
insert into t4 ( id, f1, f2 )
select id, f1, f2 from t0;
commit;
select * from t4;
commit;
----
Output:
D:\work\temp>isql -i test.sql
Use CONNECT or CREATE DATABASE to specify a database
Database: 'test.gdb', User: sysdba
ID F1 F2
====== ========== ==========
1 test data