This is a migrated thread and some comments may be shown as answers.

postgres function returning a list

2 Answers 41 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jose
Top achievements
Rank 1
Jose asked on 26 Aug 2013, 01:46 AM
Hi,

I have been using OPenAccess with Oracle.
Stored procedures returning a refcursor are working fine.
Now I am beginning to use Postgres, but using refcursor or returning a table allways gives me an error.
Seeking a working example (postgres function + ORM class + Web(Forms/MVC)
Thanks
Zpaulo

2 Answers, 1 is accepted

Sort by
0
Jose
Top achievements
Rank 1
answered on 28 Aug 2013, 10:07 AM
Got help from a friend:

- instead of using return cursor
CREATE OR REPLACE FUNCTION f1()
  RETURNS refcursor AS
$BODY$
declare
 refout refcursor;
begin
open refout for
  select col1 , col2 from tab1 ; 
return refout;
end;

use
A)
 CREATE TYPE ty_1 AS
   (col1 integer,
    col2 character (1));
B)
CREATE OR REPLACE FUNCTION f1()
  RETURNS SETOF ty_1 AS
$BODY$
begin
  RETURN QUERY
  select col1 , col2 from t1  ; 
end;
---
On ORM : get function -> domain method -> retrieve result shape -> create compex type



0
Damyan Bogoev
Telerik team
answered on 28 Aug 2013, 01:29 PM
Hi Jose,

I am glad to see you have managed to resolve the issue on your side.

Should you have further questions, do not hesitate to contact us back.

Regards,
Damyan Bogoev
Telerik
OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
Tags
General Discussions
Asked by
Jose
Top achievements
Rank 1
Answers by
Jose
Top achievements
Rank 1
Damyan Bogoev
Telerik team
Share this question
or