View and function

From: DaVinci <bombadil(at)wanadoo(dot)es>
To: Lista PostgreSql <pgsql-general(at)postgresql(dot)org>
Subject: View and function
Date: 2001-04-17 10:35:26
Message-ID: 20010417123526.A18798@fangorn.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marcelo Pereira 2001-04-17 12:23:02 Select
Previous Message Anand Raman 2001-04-17 09:31:50 Re: Schema Import