From: | Louis Foucart <lfoucart(at)dcc(dot)uchile(dot)cl> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | parse error when executing a simple plpgsql function |
Date: | 2003-05-21 07:27:30 |
Message-ID: | AE28FBC2-8B5D-11D7-8C8D-003065F38028@dcc.uchile.cl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi,
When I execute the function get_column as select * from
get_column('dat', 1), I have a parse error like this:
parse error at or near ";"
Here is the code for the get_column() function:
create or replace function get_column(char(3), int8) returns setof daf
as
'
declare
database alias for $1;
begin
if database = ''dat'' then
select * from data_get_column($2);
else if database = ''mat'' then
select * from material_get_column ($2);
else if database = ''act'' then
select * from activity_get_column ($2);
end if;
end;
'
language 'plpgsql';
And here is a prototype of the methods data_get_column():
create or replace function data_get_column(int8) returns setof daf as
'
declare
r daf%rowtype;
begin
for r in select father_id, denom, abbrev from data_columns
return next r;
end loop;
return;
end
'
language 'plpgsql';
And here the type used:
create type daf as (father_id int8, denom varchar(40), abbrev
varchar(15));
Moreoever I want to make them better to return only one result of type
daf as the primary key of data_columns is id. Can you help me to design
this kind of function ?
Thank you very much for your attention,
Louis Foucart.
From | Date | Subject | |
---|---|---|---|
Next Message | Jean-Michel POURE | 2003-05-21 07:50:52 | Re: ENCODING (Unicode) |
Previous Message | Dave Page | 2003-05-21 07:18:45 | Re: ENCODING (Unicode) |