Re: Return cursor

From: alla(at)sergey(dot)com (Alla)
To: pgsql-general(at)postgresql(dot)org(dot)pgsql-sql(at)postgresql(dot)org
Subject: Re: Return cursor
Date: 2001-05-25 14:32:47
Message-ID: 9275d56e.0105250632.667d5bed@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

"Sergey E. Volkov" <sve(at)raiden(dot)bancorp(dot)ru> wrote in message news:<9ej088$ulc$1(at)news(dot)tht(dot)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 :-((

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-05-25 14:33:41 Re: COPY with default values?
Previous Message Manuel Durán Aguete 2001-05-25 14:29:08 [URGENT] How to generata a unique string id

Browse pgsql-sql by date

  From Date Subject
Next Message Roberto Mello 2001-05-25 14:49:03 Large Objects Documentation
Previous Message Tom Lane 2001-05-25 14:29:31 Re: Problems with pg_dump (on Debian i386)