Re: parse error when executing a simple plpgsql function - Mailing list pgsql-novice

From Joe Conway
Subject Re: parse error when executing a simple plpgsql function
Date
Msg-id 3ECB9C29.6020002@joeconway.com
Whole thread Raw
In response to parse error when executing a simple plpgsql function  (Louis Foucart <lfoucart@dcc.uchile.cl>)
List 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


pgsql-novice by date:

Previous
From: Joe Conway
Date:
Subject: Re: connect by [prior]
Next
From: Renê Salomão
Date:
Subject: Installing PlPerl