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-19 21:35:38 |
Message-ID: | D51D401D-8A41-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 | Josh Berkus | 2003-05-19 21:44:00 | Re: 7.2.1 => 7.3.2 |
Previous Message | Nabil Sayegh | 2003-05-19 10:35:19 | 7.2.1 => 7.3.2 |