View and function

Поиск
Список
Период
Сортировка
От DaVinci
Тема View and function
Дата
Msg-id 20010417123526.A18798@fangorn.net
обсуждение исходный текст
Ответы Re: View and function  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список pgsql-general
 Hello.

 I am trying to insert a tupla in a view with rules for inserting from a
 function. This is my data:

-----------------------------------------------------------------------
create table dirección (
    cod     serial primary key,
    calle       text,
    vía         int2    references vía(cod),
    localidad   int4    references localidad(cod),
    provincia   int4    references provincia(cod)
);
create index dir_calle_ndx on dirección (calle);
create index dir_via_ndx on dirección (vía);
create index dir_localidad_ndx on dirección (localidad);
create index dir_provincia_ndx on dirección (provincia);

create view v_dirección as
    select * from dirección
;

create rule v_dirección_ins as on insert to v_dirección do instead
    (insert into dirección(calle,vía,localidad,provincia) values (
        NEW.calle,
        NEW.vía,
        NEW.localidad,
        NEW.provincia);
        select currval('dirección_cod_seq'))
;

create function pilpot(calle) returns integer as '
declare
    c alias for $1;
    n integer;
begin
    insert into v_dirección(calle) values (c);
    get diagnostics n = result_oid;
    return n;
end;
' language 'plpgsql';

------------------------------------------------------------------

 I get an error when creating function of type:

     ERROR:  ProcedureCreate: arg type 'calle' is not defined

 but when I try that insert from psql prompt, all works well.

 Where is my mental bug? :)

 Thanks.

                                                 David

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

Предыдущее
От: Anand Raman
Дата:
Сообщение: Re: Schema Import
Следующее
От: "Marcelo Pereira"
Дата:
Сообщение: Select