Try this script:
create table emp (
empno int,
ename char(10),
jobchar(12),
hiredate date,
saldecimal(10,2),
commint,
deptno int,
nivel int,
mgrint
);
create view vista
as select empno, ename, job
from emp
where job='SALESMAN';
create function view_upd() returns opaque as '
begin
if tg_op = ''INSERT'' then
if new.job = ''SALESMAN'' then
INSERT INTO emp VALUES (new.empno,new.ename,new.job);
return new;
else
raise notice ''impossible to add records where JOB is
not "SALES
return null;
end if;
end if;
end;
' language 'plpgsql';
create trigger t_add before insert
on vista for each row execute procedure view_upd();
abdelkrim ha scritto:
> it is possible to insert into a view ?
>
> thanks
--
______________________________________________________________
PostgreSQL 6.5.0 on i586-pc-linux-gnu, compiled by gcc 2.7.2.3
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Jose'