Pentaho

 View Only
  • 1.  Read a SYS_REFCURSOR

    Posted 03-20-2023 17:22

    Hello dear community, I need to be able to extract the value of a cursor that is inside a store procedure. Although I can get the sp to run normally I can't get the value of the SYS_REFCURSOR. Has anyone ever been through this that can help me? thank you so much



    ------------------------------
    Marcelo Zapata
    Application Services Manager
    IT
    ------------------------------


  • 2.  RE: Read a SYS_REFCURSOR

    Posted 03-28-2023 00:43

    To extract the value of a SYS_REFCURSOR inside a stored procedure, you can declare a variable of type SYS_REFCURSOR and use the OPEN, FETCH, and CLOSE statements to manipulate the cursor.

    Here's an example:

    DECLARE
      my_cursor SYS_REFCURSOR;
      cursor_result VARCHAR2(100);
    BEGIN
      my_procedure(my_cursor);

      LOOP
        FETCH my_cursor INTO cursor_result;
        EXIT WHEN my_cursor%NOTFOUND;
        -- do something with cursor_result
      END LOOP;

      CLOSE my_cursor;
    END;

    In this example, we declare a variable called my_cursor of type SYS_REFCURSOR. We then call a stored procedure called my_procedure that populates my_cursor with data. We then use a loop to fetch each row from the cursor and do something with the resulting data.

    Note that you'll need to replace my_procedure with the name of your stored procedure and cursor_result with the appropriate data type for the data you're fetching.  MyHealthOnline



    ------------------------------
    Diana Stanley
    Chief Financial Officer
    Glicks Furniture
    ------------------------------



  • 3.  RE: Read a SYS_REFCURSOR

    Posted 03-29-2023 11:54

    Please be carefull giving solutions using chatGPT.



    ------------------------------
    Carl Messner
    Data Analyst
    MCSF
    ------------------------------



  • 4.  RE: Read a SYS_REFCURSOR

    Posted 03-28-2023 10:12

    It sounds like you are trying to extract the value of a SYS_REFCURSOR that is inside a stored procedure. While you are able to run the stored procedure normally, you are having trouble getting the value of the SYS_REFCURSOR. It would be helpful to have more information on what programming language and database system you are using, as the solution may differ based on those details. However, some potential solutions could involve using output parameters, explicitly defining the cursor variable, or using a fetch statement to retrieve the cursor results.



    ------------------------------
    Diana Stanley
    Chief Financial Officer
    Glicks Furniture
    ------------------------------