declare function with IN and OUT parameter as well as refcursor - Mailing list pgsql-general

From Frank Motzkat/IC3S AG
Subject declare function with IN and OUT parameter as well as refcursor
Date
Msg-id 002401c5f0d0$b7c2fc00$234011ac@gump.ic3s.de
Whole thread Raw
Responses Re: declare function with IN and OUT parameter as well as refcursor
List pgsql-general

Hi community,

 

I would like to declare a function with IN and OUT parameters as well as a refcursor as return value.

For example something like this:

 

This doesn’t work. It gives the compilation error ‘ERROR:  function result type must be integer because of OUT parameters’

CREATE OR REPLACE FUNCTION reffunc2(IN key int, INOUT name int) RETURNS refcursor

AS $$

DECLARE

    ref refcursor;

BEGIN

    OPEN ref FOR SELECT col FROM test;

    RETURN ref;

END;

$$ LANGUAGE plpgsql;

 

This works …

CREATE OR REPLACE FUNCTION reffunc2(IN key int) RETURNS refcursor

AS $$

DECLARE

    ref refcursor;

BEGIN

    OPEN ref FOR SELECT col FROM test;

    RETURN ref;

END;

$$ LANGUAGE plpgsql;

 

I’m wondering how I should declare such a function, or isn’t possible at all with postgres 8.1 ? With MS-Sql and Oracle such functions are no problem at all.

 

Thanks a lot for any reply in advance !

 

Cheers,

 

frank

 

 

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Delete statement does not work with PostgreSQL 8.0.1
Next
From: Martijn van Oosterhout
Date:
Subject: Re: declare function with IN and OUT parameter as well as refcursor