Re: Return cursor - Mailing list pgsql-general

From alla@sergey.com (Alla)
Subject Re: Return cursor
Date
Msg-id 9275d56e.0105250632.667d5bed@posting.google.com
Whole thread Raw
In response to Re: Return cursor  (Alexander Dederer <dederer@spb.cityline.ru>)
List pgsql-general
"Sergey E. Volkov" <sve@raiden.bancorp.ru> wrote in message news:<9ej088$ulc$1@news.tht.net>...
> If you are planing  to use ecpg :
>
> exec sql declare cuserbase cursor for
>      select column1, column2, column3 from my_table order by 1;
> exec sql open cuserbase;

Thanks, but this is exactly what I am trying to avoid - having select statements
in client applications.

I want to write stored procedures with all the logic and give the names
and parameters to my developers, so they could just do the fetch.

In this case, I'll be free to change any underlying logic - tables' names,
column names, select statements itself, add some extra logic to the
where clause etc

Alla

P.S. If you are curious, I found something like this:

create function edf_load_user_base()
returns setof edv_user_base as '
select * from edv_user_base
where ... (complex where clause)'
language 'sql';

And then call it as following:

select column1(edf_load_user_base()), column2(edf_load_user_base()) etc

Does anybody know how I can return setof of something other than table%rowtype,
i.e. can I define a record type my_record and do something like this:

create function edf_load_user_base()
returns setof my_record
....

Sorry to be a pain, but I have a deadline to do the migration and
not enough time to do my research :-((

pgsql-general by date:

Previous
From: Yann Ramin
Date:
Subject: Re: database size including indexes
Next
From: "Arve Fahlvik"
Date:
Subject: Problems with backup