postgres function returning a list

3 posts, 0 answers
  1. Jose
    Jose avatar
    4 posts
    Member since:
    Dec 2011

    Posted 25 Aug 2013 Link to this post

    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. Jose
    Jose avatar
    4 posts
    Member since:
    Dec 2011

    Posted 28 Aug 2013 Link to this post

    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



  3. DevCraft banner
  4. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 28 Aug 2013 Link to this post

    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.
Back to Top