returning a cursor from a function?

Started by Matthew Hixsonabout 20 years ago3 messagesgeneral
Jump to latest
#1Matthew Hixson
hixson@poindextrose.org

I have a create function statement that works with Oracle 8i and I'm
trying to create this function in Postgres 8.1.2.

CREATE OR REPLACE FUNCTION pr_user( p0 CHAR ) RETURN
Types.cursor_type IS
rs Types.cursor_type;
BEGIN
OPEN rs FOR
SELECT us.approval_type_code AS us_approval_type_code FROM wbs_users
us WHERE upper( us.username ) = upper( p0 );
return rs;
END;

Could someone lend me a hand here?
Thanks in advance,
-M@

#2Michael Fuhr
mike@fuhr.org
In reply to: Matthew Hixson (#1)
Re: returning a cursor from a function?

On Tue, Jan 31, 2006 at 10:37:47PM -0800, Matthew Hixson wrote:

I have a create function statement that works with Oracle 8i and I'm
trying to create this function in Postgres 8.1.2.

See the PL/pgSQL documentation, in particular the section on cursors,
which has several examples. You might also be interested in the
"Porting from Oracle PL/SQL" section.

http://www.postgresql.org/docs/8.1/interactive/plpgsql.html
http://www.postgresql.org/docs/8.1/interactive/plpgsql-cursors.html
http://www.postgresql.org/docs/8.1/interactive/plpgsql-porting.html

--
Michael Fuhr

#3Matthew Hixson
hixson@poindextrose.org
In reply to: Michael Fuhr (#2)
Re: returning a cursor from a function?

Thanks, Michael. Don't know how I missed those.
-M@

On Jan 31, 2006, at 10:55 PM, Michael Fuhr wrote:

Show quoted text

On Tue, Jan 31, 2006 at 10:37:47PM -0800, Matthew Hixson wrote:

I have a create function statement that works with Oracle 8i and I'm
trying to create this function in Postgres 8.1.2.

See the PL/pgSQL documentation, in particular the section on cursors,
which has several examples. You might also be interested in the
"Porting from Oracle PL/SQL" section.

http://www.postgresql.org/docs/8.1/interactive/plpgsql.html
http://www.postgresql.org/docs/8.1/interactive/plpgsql-cursors.html
http://www.postgresql.org/docs/8.1/interactive/plpgsql-porting.html

--
Michael Fuhr