Re: [GENERAL] insert into view !!

Поиск
Список
Период
Сортировка
От José Soares
Тема Re: [GENERAL] insert into view !!
Дата
Msg-id 37722BF4.E6289592@sferacarta.com
обсуждение исходный текст
Ответ на insert into view !!  ("abdelkrim" <haj@idianet.net>)
Список pgsql-general
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'



В списке pgsql-general по дате отправления:

Предыдущее
От: Karin Probost
Дата:
Сообщение: Re: [GENERAL] unique fields
Следующее
От: José Soares
Дата:
Сообщение: Re: [GENERAL] Datetime <> ODBC <> Access