How to create a Ref cursor table

I have a proc that returns a Ref Cursor, what is the easiest way to create a table based on the return of the ref cursor?

declare
type rc is ref cursor;
p_data rc;
Start
call_my_proc (p_data);
: result: = p_data; ((- If I run this in TOAD I can see the data here, but I want to create a table based on it rather than showing)
end;


Thank you.


Edit: sorry. typed this wrong, first time, should be right now

I recommend you read this first... {: identifier of the thread = 886365}

and then you'll have a better idea of how to make to create a table in your query.

Tags: Database

Similar Questions

  • How to create a REF CURSOR from the static values?

    We call for a program of power supply (from PL/SQL) that returns a string with data (separated by {}), lines like this:
    {packetId:236,packetName:ADSL-320K-1M-3G},
    {packetId:257,packetName:ADSL-1024K-1M-20G},
    {packetId:232,packetName:ADSL-INTERANET-UNLIMITED},
    {packetId:234,packetName:ADSL-512K-3M-16G},
    ..................
    .........
    .....
    Our PL/SQL procedure should exit a REF CURSOR with lines like this:
    236,  ADSL-320K-1M-3G
    257,  ADSL-1024K-1M-20G
    232,  ADSL-INTERANET-UNLIMITED
    234,  ADSL-512K-3M-16G
    .........
    ......
    How do this pls?

    Published by: Channa on May 18, 2012 02:30

    Hello

    Channa wrote:
    It's the first gives ORA-00942: table or view does not exist for the FROM t . When I can replace the t split_t , I get ORA-32031: illegal reference to a query with the term name.

    What is at stake here pls?

    Use the name of your real of the table where I used t.
    If you don't have a table, just a string, then select the double.

  • help how to extract the ref cursor in the table field

    Hello.


    I have a query similar to the following:
    select department_id, cursor (select employee_id from employees where department_id = d.department_id)
      from departments d
    Expecting to get several lines, I want this select this option to be in bulk sampled in a table variable nested (of another type of nested table) which is copied to an out parameter in a procedure. I have some doubts:
    1 should. what I create the column in the inner nested table that will keep the result of the ref cursor? Ref cursor colunm? A sort of column Adrien?
    2. If the column in the nested table inside that will keep the result of the ref cursor is another array, how can I write the result of the entire query in a single volume?

    (I want to bulk collect everything in a single query, I know how to do with pl/sql do not inflate but using two nested for loops, that's what I try to avoid).


    Thanks in advance.

    It would be simpler:

    declare
        type dep_emp_list_tbl_type
          is table of sys.OdciVarchar2List;
        v_dep_emp_list_tbl dep_emp_list_tbl_type;
        v_dep_id_tbl sys.OdciNumberList;
    begin
        select  department_id, cast(multiset(select employee_id from hr.employees where department_id = d.department_id) as sys.OdciVarchar2List)
          bulk collect into v_dep_id_tbl,v_dep_emp_list_tbl
          from hr.departments d;
    end;
    /
    

    SY.

  • Create a REF CURSOR as an array of display/temp

    Hello world

    I had to upgrade a number of Crystal Reports Using REF CURSOR as part of an ERP upgrade project. The new version of the ERP application supports more use of the REF CURSOR and only supports the use of views/tables.

    I don't see how I can rewrite the REF CURSOR (which are defined in the PL/SQL procedures), in the form of VIEWS / TEMP TABLES with a single call. That is to say when the user runs the report.

    Can anyone suggest a method of conversion of the REF CURSOR in view/Temp Table without the two steps, the steps to populate a temporary table and then, i.e. 1 - 2 - query the table in the report. ??? -I was looking at a Pipelining as an option but again could reach with only two stages, pre filling before running the report.

    Any advice would be greatly received.

    Kind regards

    David.

    I found a solution by creating a FUNCTION with a PIPELINED return cursor, and then create a temporary table in the result set. Not really ideal was to use a Pragma AUTONOMOUS_TRANSACTION, but will work for me.

    Thank you

    David.

  • The use of bind variables in dynamic query created for Ref Cursor

    Hello

    I'm in a situation where there is a Ref cursor to which the query is built execution based on a loop. This is why the number of links would be known until the program runs.
    The application is currently using literals instead of bind variables.

    code snippet of the above is
    strSql: = "select * from emp where 1 = 1 and ().

    loop cursor1
    If cond is true then
    strSql = strSql | "ename = ' |" Cursor1.ColumnName;
    end loop;

    Open cursor2 for strSql;

    How to use links in the example above.

    sb92075 wrote:

    user13019948 wrote:
    Hello

    Here is the code I have my trying to change literal-based link to the base.

    What do you mean by "based bind?

    who, what, how determines the values to be 'bound '?

    He's referring to the coding style. He is currently using concatenated literal, and the goal is to change it to use the bindings.

    If I understand this it is known as method 4 dynamic SQL and requires DBMS_SQL. There are examples autour but they vary according to the type of statement being generated - SELECT statements require column lists to be parsed, unlike the INSERT/UPDATE/DELETE.

    This came up recently on my current project and I hit a demo. Here a table of names and values accepted procedure and had to build these in a single WHERE clause along the lines of

    AND t_names(i) = t_values(i)
    

    for an undetermined number of elements in the array. For this demonstration, I used a table that we called "attribute" (don't ask) which has columns including 'attribute_id' and 'name', and I need to build a query along the lines of

    select description from attribute where attribute_id = :b1 and name = :b2
    

    by the way '1012' and 'ISIN' respectively. (I use a table better and after a CREATE statement for her but I have to rush right now, sorry).

    declare
       k_sql_base        constant varchar2(500) := 'select description from attribute';
    
       t_names           constant varchar2_t := varchar2_t('attribute_id',  'name');
       t_values          constant varchar2_t := varchar2_t('1012',          'ISIN');
    
       l_sql             varchar2(500) := k_sql_base;
       l_rows_fetched    integer := 0;
       l_value           varchar2(4000);
    
       l_cursor_handle   integer;
    
    begin
       -- Construct the SQL statement with column names and bind variables e.g.
       -- 'select description from mars.attribute where attribute_id = :b1 and name = :b2'
       for i in t_names.first .. t_names.last loop
          l_sql := l_sql ||
             case i
                when t_names.first then ' where ' else ' and '
             end ||
             t_names(i) || ' = :b' || i;
       end loop;
    
       dbms_output.put_line('SQL statment = ' || l_sql); 
    
       -- Parse the statement we built above (the remaining steps require a parsed cursor):
       l_cursor_handle := dbms_sql.open_cursor;
       dbms_sql.parse(l_cursor_handle, l_sql, dbms_sql.native);
    
       -- Associate the 1st column of output with variable l_value - required for SELECT statements:
       -- (actually the 3rd param here 'column' seems to be only used to get a datatype, in this case we want a string -
       -- dbms_sql.column_value actually extracts the value into a specified variable, which can be different.
       -- All examples in the documentation pass a local variable without further comment, so not entirely clear what this does other than set the output datatype.)
       dbms_sql.define_column(l_cursor_handle, 1, l_value, 4000);
    
       -- Now go through values array binding actual values to :bn variables in the cursor (similar to USING clause of EXECUTE IMMEDIATE)
       for i in t_values.first .. t_values.last loop
          dbms_sql.bind_variable(l_cursor_handle, ':b'||i, t_values(i));
          dbms_output.put_line('Bound :b'||i || ' as ' || t_values(i));
       end loop;
    
       -- Open the cursor and fetch the result (no loop here because we are expecting a single-row result):
       l_rows_fetched := dbms_sql.execute_and_fetch(l_cursor_handle);
    
       -- 'Returns value of the cursor element for a given position in a cursor'
       -- Copy the value of column 1 to variable l_value (has to match
       -- dbms_sql.column_value(l_cursor_handle, 1, l_value);
       dbms_sql.column_value(l_cursor_handle, 1, l_value);
    
       dbms_output.put_line('Result = ''' || l_value || '''');
    
       dbms_sql.close_cursor(l_cursor_handle);
    end;
    

    Hope that helps...

  • How to pass a REF CURSOR from a function

    I tried to compile the following function:

    CREATE or REPLACE FUNCTION example
    RETURN REFCURSOR
    IS
    heart REFCURSOR;
    BEGIN
    OPEN FOR heart
    "SELECT x FROM table";
    RETURN cur;.
    END;

    but I get:

    PLS-00201: identifier 'REFCURSOR' must be declared.

    Can you help me in the right syntax? I never return a REF CURSOR to a function.
    Is my Version of Oracle 8.1.7

    Thank you!

    You cannot use SYS_REFCURSOR in Oracle 8i.
    The work is approximately as follows

    create or replace package my_pk as
    type my_cur is REF CURSOR;
    end my_pk;
    
    -- Now write your function
    create or replace function my_func return my_pk.my_cur
    as
    l_cur my_pk.my_cur;
    begin
    open l_cur for select * from table_name;
    return l_cur;
    end my_func;
    

    Thank you
    Andy

  • How to read my ref cursor return user defined cursor type

    Hello
    I have the types defined as follows:
    TYPE MY_RECORD IS RECORD (
    COL1 TABLE1.COL1%TYPE,
    COL2 TABLE1.COL2%TYPE
       );
    
    TYPE MY_CURSOR IS REF CURSOR
    RETURN MY_RECORD;
    It is used as a return type in a stored procedure.
    I have a pl/sql block, where I make a call to MS that returns this cursor.
    How to read individual values for SP?
    SQL> create or replace package pkg
    as
       type my_record is record (col1 emp.empno%type, col2 emp.ename%type);
    
       type my_cursor is ref cursor
          return my_record;
    
       procedure p (cur out my_cursor);
    end pkg;
    /
    Package created.
    
    SQL> create or replace package body pkg
    as
       procedure p (cur out my_cursor)
       as
       begin
          open cur for
             select   empno, ename
               from   emp
              where   rownum <= 2;
       end p;
    end pkg;
    /
    Package body created.
    
    SQL> declare
       cur     pkg.my_cursor;
       e_rec   pkg.my_record;
    begin
       pkg.p (cur);
    
       loop
          fetch cur into   e_rec;
    
          exit when cur%notfound;
          dbms_output.put ('Empno: ' || e_rec.col1);
          dbms_output.put_line ('; Ename: ' || e_rec.col2);
       end loop;
    
       close cur;
    end;
    /
    Empno: 7369; Ename: SMITH
    Empno: 7499; Ename: ALLEN
    PL/SQL procedure successfully completed.
    
  • How to clear the Ref Cursor runtime error

    Hello everyone,
    the code as follows
    create or replace 
    procedure Country_sel(key in varchar2)
    as
    cc Res_RelcountryLan.countrycode%type;
    len Res_Language.langname_en%type;
    lid Res_Language.langid%type;
    ab Res_Language.Abrivation%type;
    type refcursorr is ref cursor;
    cur refcursorr;
    d_stmt varchar2(100);
    begin
    d_stmt := 'select RCL.countrycode,RL.langid,RL.langname_'||key||',
    RL.Abrivation from  Res_RelCountryLan RCL inner join Res_Language RL ON RCL.LangId = RL.LangId';
    open cur for d_stmt;
    loop
    fetch cur into cc,lid,len,ab;
    if cur%found then
    dbms_output.put_line(cc||lid||len||ab);
    else
    exit;
    end if;
    end loop;
    close cur;
    commit;
    end  Country_sel;
    When I run this code im getting
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    ORA-06512: at "RASOOL.COUNTRY_SEL", line 11
    ORA-06512: at line 6
    can you please help me get rid of this problem.


    thanking you,
    Prakash
    
    d_stmt varchar2(100); 
    

    Increase the size of d_stmt. Your an a larger string assignment

    
    d_stmt := 'select RCL.countrycode,RL.langid,RL.langname_'||key||',RL.Abrivation from  Res_RelCountryLan RCL inner join Res_Language RL ON RCL.LangId = RL.LangId'; 
    

    The size of the string above is more than 100 characters.

  • How to create a logical fact table in a layer MDB?

    Hello

    I have 3 Dimension table - 2 are in a schema and the last is another schema. Using this 3 dimension tables, I need to create a logical fact table.
    So, my question is if we can create this table made by joining these 3 dimension table that are 2 different schema s?

    Thank you

    Hi Kuldip,
    Business is never a problem.

    Presentation layer is used to group similar business lines tables.
    It's just for users to understand or requirrment.

    You can use different domain tables to create a report. However the MDB and the physical joins is given in the tables to the RPD. It is compulsory to join tables in MDB layer and the physical layer to be used in the analysis.

    Hope that clarifies.

    A course if you think perticular table is used in the object anaother are, so you must add this table to the domain of the RPD. (Which makes sense)

    Mark if it is correct,

    Bachelot

  • How to create the 2d cursor?

    How can I create slider 2d, something like the square with the point of the mouse controlled inside in the upper left corner in the photo, so I don't need to use 2 separate cursors for x and y?

    Altenbach says:

    Create a style point (not lines) cursor and cursor movement events for x and y.

    Here's what I had in mind (LV 8.0). Modify if needed.

  • How to create a unique temporary table delete automatically after the join?

    I have a lot of users simultaneously accessing web applications.
    My problem is how to fix the SELECT WHERE IN('..') clause ...

    I read a lot of threads with the same option...

    (1) open the connection and start transaction
    2) create temporary table
    (3) Insert (insert batch) data
    (4) the main objective. SELECT JOIN or SELECT WHERE IN (SUBQUERY).
    (5) end of transaction and close the connection

    How can I ensure that the temporary table created was deleting/moving on 5)?

    Thank you very much..

    You can do this by using global temporary tables. Also data from the temporary table is automatically deleted after that validation but the table will remain.

    for example

    CREATE TEMPORARY TABLE global today_sales
    ON COMMIT DELETE ROWS
    AS SELECT * FROM Orders WHERE order_date = SYSDATE;

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14231/tables.htm#i1006400

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/statements_7002.htm#i2153132

    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14200/statements_7002.htm#i2153132

    Concerning
    Rajesh

    Published by: Rajesh on June 10, 2010 15:34

  • How to create and populate a table of specific size

    How can I write a script in a table to a specific size?

    Matt

    If you want to exactly hit the mark 5 MB or do you not care as long as you exceed 5MB?

    If all you want to do is more than 5MB create a table in the desired table space:

    CREATE TABLE big (id number, filler varchar2(1024))
    TABLESPACE your_table_space
    STORAGE (INITIAL 4M NEXT 1M);
    

    Then insert a bunch of folders:

    insert into big (select level, rpad('x', 1024, 'x') from dual connect by level <= 5*1024);
    

    That should do it.

  • How to create a pagination ADF Table in JDev 11.1.2.3.0?

    Hello

    I have a requirement to create ADF Table Pagination in Jdev 11.1.2.3.0.

    11.1.1.7 Jdev, I see there is an option to create a pagination by setting "scrollpolicy = page.

    I'm not able to find such a property in Jdev 11.1.2.3.

    Y at - it another option to do this declaratively?  I want to avoid java coding for this.

    But if the coding of java is the only way, ask to suggest a better/more secure approach for this.

    Thank you and best regards,

    Tejas desrousseaux

    I'm afraid that you do not have this option for 11.1.2.3.0 out of the box, but you can make it work, please see below:

    Andrejus Baranovskis Blog: Oracle ADF 11 g Table custom paging

  • How to create a form of table layout using iterator?

    I want to make several elements in a table format using an iterator. Can someone guide me on how to align the different columns, as in a table?

    I can't use the built in table because I want to change the display later using javascript and the af:table component does not work with it.

    The table will be in a panelsplitter element. The code I have right now:

    <af:iterator id="i1"
                       value="#{bindings.DenormPlanLine1.collectionModel}"
                       var="row"
                       rows="#{bindings.DenormPlanLine1.rangeSize}">
                        <af:panelGroupLayout id="pg1" layout="horizontal"
                                             inlineStyle="width:800.0px;">
                          <f:facet name="separator">
                            <af:spacer width="5" height="1" />
                          </f:facet>
                          <af:outputText value="#{row.StartDate}"  styleClass="sDate"/>
                          <af:outputText value="#{row.FinishDate}" styleClass="fDate"/>
                          <af:outputText value="#{row.DenormWbsLevel}" styleClass="level"/>
                          <af:outputText value="#{row.DisplaySequence}" styleClass="dSequence"/>
                          <af:outputText value="#{row.ElementVersionId}" styleClass="elVersionId"/>
                          <af:outputText value="#{row.TaskType}" styleClass="taskType"/>
                          <af:outputText value="#{row.PercentComplete/100}" styleClass="percent">
                            <af:convertNumber type="percent" />
                          </af:outputText>
                        </af:panelGroupLayout>
                        <af:spacer width="100%" />
                        </af:iterator>
    

    User, please tell us your Jdev version!

    Check out this sample http://andrejusb.blogspot.de/2011/05/oracle-adf-11g-custom-table-pagination.html

    Timo

  • How to create an interactive cursor that returns a numeric value.

    Hello world

    I am trying to create an interactive slider that the user can drag an icon from left to right, in order to select a numerical value. This numeric value will be output to a dynamic text box to capture the data. Please see the example at the link below...

    http://www.carbontrust.co.UK/solutions/CarbonFootprinting/carbonfootprintindicator.htm

    I welcome suggestions of action script to create a slider like that.

    Thanks for your help

    Just as an example, open a new file and add a movieclip on the stage... give it an instance name of "handle" and place it at x = 0, y = 100.  Then place this code in a layer of actons (code red, it's how the drag limits are set)

    handle.addEventListener (MouseEvent.MOUSE_DOWN, mouseDown)

    function mouseDown(event:MouseEvent):void {}
    handle.startDrag (false, new Rectangle (0, handle.y, 200, 0));
    }
    handle.addEventListener (MouseEvent.MOUSE_UP, mouseReleased);

    function mouseReleased(event:MouseEvent):void {}
    handle.stopDrag ();
    }

Maybe you are looking for