View and function - Mailing list pgsql-general

From DaVinci
Subject View and function
Date
Msg-id 20010417123526.A18798@fangorn.net
Whole thread Raw
Responses Re: View and function
List 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 by date:

Previous
From: Anand Raman
Date:
Subject: Re: Schema Import
Next
From: "Marcelo Pereira"
Date:
Subject: Select