From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | Louis Foucart <lfoucart(at)dcc(dot)uchile(dot)cl> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: parse error when executing a simple plpgsql function |
Date: | 2003-05-21 15:32:57 |
Message-ID: | 3ECB9C29.6020002@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Louis Foucart wrote:
> 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';
You don't have any "return next" or "return" statements in this
function. You need a "for x in statement loop", etc, just like you are
doing in data_get_column()
> 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 ?
I don't understand this question -- maybe an example of what you want to
do would help.
Joe
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Cameron | 2003-05-21 16:12:02 | Re: Unaccounted for disk use |
Previous Message | Joe Conway | 2003-05-21 15:20:47 | Re: connect by [prior] |