Select DataSet from the pl/sql table

Hi Experts,

I need to create a metric of OEM 12 c extensions. I must create a pl/sql code that can return results to OEM.

The following code works in OEM. But the problem is that I need to create a permanent table for this case.

Could you please tell any other option available to do this without creating additional objects at the database level?

Based on the requirement of the OEM, the end of the script, I have to do something like ' open: 1 to select in the <>' to return the results in a table.

Thank you.

###########################################################################################

DECLARE

TYPE cur_type IS REF CURSOR;

CURSOR c1 IS

SELECT distinct (owner: '.) ' || queue_table) as queue_table FROM dba_queues;

l_cur_string VARCHAR2 (200);

C2 cur_type;

v_queue VARCHAR2 (128);

number of v_ready;

BEGIN

run immediately "remove sys.testing";

FOR v_queue_table IN c1 LOOP

l_cur_string: ='select q_name, count (*) from ' | v_queue_table.queue_table | ' where State = 0 or (State = 1 and sysdate > nvl (delay, enq_time)) q_name group ';

OPEN c2 FOR l_cur_string;

LOOP

C2-FETCH INTO v_queue, v_ready;

OUTPUT WHEN c2% NOTFOUND;

run immediately ' insert into sys.testing values (: v_queue,: v_ready) "using v_queue, v_ready;"

OPEN: 1 for select * from sys.testing;

commit;

END LOOP;

CLOSE C2;

END LOOP;

END;

###################################################################################

In addition, committing inside of cursor loops are false.  You should never engage at the end of a business logic operation, NEVER in cursor loops.

Something along these lines (untested) is probably what you want:

var refcursor rc;

declare

SQL varchar2 (32767).

Start

SQL: = q'[select

table_name,

TO_NUMBER)

ExtractValue)

XmlType)

dbms_xmlgen. GetXml ("select count (*) c to ' |") table_name | ((' where State = 0 or (State = 1 and sysdate > nvl (delay, enq_time)) q_name group '))

(("/ LINES/LINES/C ')) County

from (select distinct owner |'.) ' || queue_table as table_name dba_queues)]';

Open: rc for sql.

end;

/

print rc;

Tags: Database

Similar Questions

  • How to remove duplicates from the PL - SQL table?

    Hi gurus,

    I have a PL - SQL table with the following structure
    Authors (SR_NO, Auth_Code, Change_Date, cost)

    This table is filled using a slider. However, this table can have a few lines in double (for column (Auth_Code)
    for example
    SR_NO      Auth_Code       Change_Date                       Cost
    1               A1             14-FEB-09 08.18.47 AM          11.00
    2               A2             14-FEB-09 08.18.56 AM       2839.00
    3               A1             15-FEB-09 08.00.02 AM      1299.00
    4               A1             15-FEB-09 07.00.00 AM        789.00
    5               A3             14-FEB-09 08.18.56 AM        312.00
    6               A4             14-FEB-09 08.19.02 AM        233.00
    I need to get the above result set select the separate lines of Auth_Code including the Change_Date is maximum (and store in another PL - SQL table for treatment later or even the removal of this table will be also!)

    of the data A1 is duplicated and a maximum Change_Date above = 15 February 09 08.00.02 AM.
    Where my PL - SQL Table that results must have given below
    SR_NO      Auth_Code       Change_Date                       Cost
    2               A2             14-FEB-09 08.18.56 AM       2839.00
    3               A1             15-FEB-09 08.00.02 AM      1299.00
    5               A3             14-FEB-09 08.18.56 AM        312.00
    6               A4             14-FEB-09 08.19.02 AM        233.00
    I'm not very aware of the PL - SQL tables and there is no chance to change the existing cursor that fills the data in this table PL - SQL.
    I guess that I need to compare each record of PL - SQL table with others, but do not know how to do this.

    Could you please help?

    Hello

    Like this?:

    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    
    SQL>
    SQL> with data as(
      2  select 1 as SR_NO, 'A1' as Auth_Code, to_date('14-FEB-09 08.18.47', 'dd-mon-yy hh24:mi:ss') as change_date,    11.00 as cost from dual union all
      3  select 2 as SR_NO, 'A2' as Auth_Code, to_date('14-FEB-09 08.18.56', 'dd-mon-yy hh24:mi:ss') as change_date,  2839.00 as cost from dual union all
      4  select 3 as SR_NO, 'A1' as Auth_Code, to_date('15-FEB-09 08.00.02', 'dd-mon-yy hh24:mi:ss') as change_date,  1299.00 as cost from dual union all
      5  select 4 as SR_NO, 'A1' as Auth_Code, to_date('15-FEB-09 07.00.00', 'dd-mon-yy hh24:mi:ss') as change_date,   789.00 as cost from dual union all
      6  select 5 as SR_NO, 'A3' as Auth_Code, to_date('14-FEB-09 08.18.56', 'dd-mon-yy hh24:mi:ss') as change_date,   312.00 as cost from dual union all
      7  select 6 as SR_NO, 'A4' as Auth_Code, to_date('14-FEB-09 08.19.02', 'dd-mon-yy hh24:mi:ss') as change_date,   233.00 as cost from dual)
      8  select * from data d where change_date = (select max(change_date) from data d2 where d.auth_code = d2.auth_code);
    
         SR_NO AUTH_CODE CHANGE_DATE       COST
    ---------- --------- ----------- ----------
             2 A2        14/02/2009        2839
             3 A1        15/02/2009        1299
             5 A3        14/02/2009         312
             6 A4        14/02/2009         233
    
    SQL>
    

    Kind regards

  • XML from the master-child tables

    Hello

    Just post here again for a quick response.

    XML from the master-child tables


    Best regards
    Hari

    Hello

    Using SQL/XML functions is the way to go in this case.

    SQL> select xmlroot(
      2           xmlelement("ROWSET",
      3             xmlagg(
      4               xmlelement("MASTER",
      5                 xmlforest(tm.master_id, tm.master_name, tm.master_location),
      6                   (
      7                    select xmlagg(
      8                             xmlelement("CHILD",
      9                               xmlforest(tc.child_id, tc.child_name, tc.child_location)
     10                             ) order by tc.child_id
     11                           )
     12                    from t_child tc
     13                    where tc.master_id = tm.master_id
     14                   )
     15               ) order by tm.master_id
     16             )
     17           )
     18         , version '1.0')
     19  from t_master tm
     20  where tm.master_id = 1
     21  ;
    
    XMLROOT(XMLELEMENT("ROWSET",XM
    --------------------------------------------------------------------------------
    
    
      
        1
        master name
        master location
        
          1
          child name 1
          child location 1
        
        
          2
          child name 2
          child location 2
        
        
          3
          child name 3
          child location 3
        
      
    
     
    

    Note that the first XMLAgg is optional here, since you want just a MASTER at a time.
    But if you need an XML document containing several masters, he will work as well.

    Alternatively, you can write a similar query with a GROUP BY clause (no correlated subquery, but a join between the master and the child instead):

    select xmlroot(
             xmlelement("ROWSET",
               xmlagg(
                 xmlelement("MASTER",
                   xmlforest(tm.master_id, tm.master_name, tm.master_location),
                     xmlagg(
                       xmlelement("CHILD",
                         xmlforest(tc.child_id, tc.child_name, tc.child_location)
                       ) order by tc.child_id
                     )
                 ) order by tm.master_id
               )
             )
           , version '1.0'
           )
    from t_master tm
         join t_child tc on tc.master_id = tm.master_id
    where tm.master_id = 1
    group by tm.master_id, tm.master_name, tm.master_location
    ;
    

    Published by: odie_63 on June 15, 2011 15:06

  • Insert rows in the PL/SQl table

    Hello
    I have a PL/SQl table that I filled through bulk collect and now I'm trying to loop through the table (actually quite a few nested loops)... Now in one of my curls, I might need to insert a new row by splitting the field in the existing row in the table. Can I insert the line in the pl/sql table in the loop without affecting the "FOR i IN tab.first... Tab.Last' loop?
    Also, what would be the index of such a line inserted into the table. Can I access it with tab.last + 1 (doesn't look like it can be done if I insert into various levels of loops).
    OR
    If I insert the lines insde loops nested, then I can access the new lines as soon as I close all the loops and open a new loop? The new lines will be at the last table.

    Any help will be appreciated...

    The expression v_arr. LAST gives the index of the last entry, so you can refer to this element as

    v_arr(v_arr.LAST)
    

    Then the attributes of this element will be

    v_arr(v_arr.LAST).attr
    

    for example

    DECLARE
        TYPE table_defs_tt IS TABLE OF user_tables%ROWTYPE INDEX BY PLS_INTEGER;
        v_mytables table_defs_tt;
    BEGIN
        SELECT * BULK COLLECT INTO v_mytables
        FROM   user_tables
        WHERE  ROWNUM <= 100;
    
        DBMS_OUTPUT.PUT_LINE(v_mytables(v_mytables.LAST).table_name);
    END;
    
  • How to select data from a remote database table?

    Hi friends,

    I think I've seen before a sqlplus program that can select data from a remote database table?

    Witnessed: IP, SID, PORT

    The following is correct?

    (I am connected to a local database)
    SELECT COUNT (*) IN THE EMP@IP:SID/PORT;


    Thank you very much


    Ms. K

    Salvation;

    I think, that you can create dblink wihtout any problem yet, it's a PROD. After your selection, you can drop dblink

    Respect of
    HELIOS

  • I can open a new browser window, but not a new tab, or by clicking on the sign more or select it from the menu. I have completely updated to firefox and also rebooted. What is going on?

    I can open a new browser window, but not a new tab, or by clicking on the sign more or select it from the menu. I have completely updated to firefox and also rebooted. What is going on?

    Try to disable or uninstall the extension "Ask Toolbar".

  • Save the selected value from the ListBox with its respective values control tab dropdown selected in another list box

    Hi all

    I'm doing a vi where I save the selected value from the ListBox with values respective tab control dropdown selected in another list box. Whenever I select Item1 can change of course and the respective tab will be open for this element. But now I want to just save the selection and put it into another ListBox.SO I can't renmove or add my wishes. Please help me.

    It will work.

    Probably not the greatest solution well.

  • Under Vista, cannot restart, select reboot from the start menu, but it stops at the place

    my computer is not restarted. When I select Restart from the Start button, computer stops and restarts do not, but power LED works. my computer is HP, 3.20 GHz, 1 GB of RAM.

    Hello

    That sounds like a hardware issue check with a real computer store (one that makes service in the House
    and not of leeks and glances at a Best Buy or other department stores) or HP support.

    Support HP & drivers
    http://welcome.HP.com/country/us/en/support.html

    Contact HP
    http://welcome.HP.com/country/us/en/contact_us.html

    HP forums
    http://h30434.www3.HP.com/PSG/

    I hope this helps.

  • Impossible to delete previously selected items from the drop-down lists at the click of the button Reset on a page of the screen.

    Hello

    I'm unable to clear previously selected items from the drop-down lists at the click of the button Reset on a page of the screen. The code I did to clear the previous value when the click on the button Reset is as below.

    {} public void onReinitialize (ActionEvent actionEvent)

    System.out.println ("onReinitialize is called ::");

    UIComponent uiComp = actionEvent.getComponent ();

    If (uiComp is nothing)

    {

    otherwise we use the button that we linked to that bean

    uiComp = getButtonResetByBean ();

    _logger.info ("reset fields: buttonID =" + uiComp.getId ());

    }

    on the other

    {

    _logger.info ("reset fields: CompID =" + uiComp.getId ());

    }

    Pass the component inside the uniforms, UIXForm, UIXSubform, UIXRegion, UIXPopup, RichCarousel

    or RichPanelCollection that contains the components to reset

    getTextIDLOV () .setValue (null);

    ResetUtils.reset (uiComp);

    }

    ---

    Using this code Iam able to clear the entrance to the text box but can not clear previously selected items from the drop-down lists when the reset button is clicked

    Can anyone please help on this issue.

    It's simple, you can set GenerateIsNullClauseForBindVars = "false" in the viewCriteria who created in EmployeeView

    After doing that it will fill the list of employees only after the Department selection

    Again check the enclosed application

    Ashish

  • Right-click DeptEmp.jsf and select run from the context menu

    Hello

    Please consider article Oracle Magazine "Catch Me If You Can ' Frank Nimphius
    at http://www.oracle.com/technetwork/issue-archive/2013/13-mar/o23adf-1897193.html

    In the article, it is offered several times to
    «... Right-click DeptEmp.jsf and select run from the context menu...'.»
    When you use JDeveloper 11.1.2.3.0 it will result in JDeveloper starting a browser requesting a URL "/ faces/DeptEmp" (without ".jsf").
    (Note that in the sample adfc - config.xml has a view with the id "DeptEmp" activity, but for pages without an activity view corresponding to the stream of unrelated task (adfc-config.) (Xml) JDeveloper starts a browser requesting a "/ faces/otherPage.jsf" URL (with ".jsf").)

    Still, I wonder if we should really run (JSF) pages, or rather an activity view in the flow of a task?

    After running into issues with calling (JSF) page URL rather than controller unbounded ADF task flows view activity URL in another forum thread [1], I try to avoid pages (JSF) (execution of the task-flow unlimited instead) running.
    to Re: login after logout is not possible using af: commandButton
    John Stegeman wrote:
    ... especially since it is very common for people new FAD (and indeed no-so-news-to-ADF people like me) to run their app via a page rather than the workflow and then wonder why it does not work :)...
    But also the Oracle documentation seems to suggest that page running a (JSF) is the way to go (or "a" way to go), see the section "41.2.1 how to run an Application in Integrated WebLogic Server "
    saying: ""in the navigation Application, select the project, a task flows, JSF page or file as the target execution. ".
    at http://docs.oracle.com/cd/E37975_01/web.111240/e16182/deployment_topics.htm#ADFFD22047

    So, who is? Is there a preferred way to run? Running a (JSF) page "also recommended"?

    -[1] ' login after logout is not possible using af: commandButton.
    during the connection after disconnection is not possible using af: commandButton

    Thank you very much
    Jan Vervecken

    Hello

    Still, I wonder if we should really run (JSF) pages, or rather an activity view in the flow of a task?

    The recommendation is to run the activity. I think it's just my laziness to boot from the JSF file in the case of the article (and given my article only has a single page in the workflow unlimited I wonder if my attempt failed, if there was a need for a navigation to another view in the flow of unlimited work). The risk from a page directly, it is a physical implementation of a view that could be used by multiple streams of different tasks (although the common use of the stubborn workflow is to go with fragments of the page, always bounded task flows could be defined using complete documents). His recommendation that you start an activity to view pages in order to ensure the ADFc is used (I wasn't even not aware of 11.2.3 to automatically change request activity instead of the file if there is an activity of referencing).

    Frank

  • How to create multiple hierarchies from the same physical table

    Hi all

    I have a physical table to join with a fact table: there are 3 different hierarchies, which share the last 2 levels inside the dimension table. It's the logic diagram of hierarchies:

    Dimension services
    -Business
    -Sector
    -Type
    -Operator
    -Product
    Partner of dimension
    -Partner
    -Operator
    -Product
    Contractor of dimension
    -Contractor
    -Operator
    -Product

    All columns are in the same table physical source. I tried to create 3 table logic source from the same physical table, everyone with all the columns and create a hierarchy for each dimension table, but it gives me nQSError: 15011.

    Any suggestion? Maybe the physical table alias can help for the creation of tables of different sizes?

    Thanks in advance,
    Concerning

    Hello

    It is a basic rule that you cannot create multiple hierarchies in a single dimension table, so what you do is create three tables of alias and slip into MDB layer in 3 different sizes and on top these tables create 3 different dimension hierarchies.

    Check if useful/correct

    Thank you.

  • Select values from the db1 table and insert into the DB2 table

    Hello

    I have three databases oracle running in three different machines. their ip address is different. among the DB can access databases. (means am able to select values and insert values into tables individually.)

    I need to extract data from the DB1 table (ip say DB1 is 10.10.10.10 and the user is DB1user and the table is DB1user_table) and insert the values into DB2 table (say ip DB2 is 11.11.11.11 and the user is DB2user and table DB2user_table) of DB3 that is to have access to the two IPs DB.

    How do I do this

    Edited by: Aemunathan on February 10, 2010 23:12

    Depending on the amount of data must be moved between DB1 and DB2, and the frequency at which this should happen, you might consider the SQL * COPY more control. I think it's very useful for one-off tasks little, so I can live within its limits of the data type. More http://download.oracle.com/docs/cd/E11882_01/server.112/e10823/apb.htm#i641251.

    Change some parameter of sqlplus session are almost mandatory in order to get decent transfer rates. Tuning ARRAYSIZE and COPYCOMMIT can make a huge difference in flow. LONG change may be necessary, too, depending on your data. The documentation offers these notes on use:

    To activate the copy of data between Oracle and databases non-Oracle, NUMBER of columns is replaced by DECIMAL columns in the destination table. Therefore, if you are copying between Oracle databases, a NUMBER column with no precision will become a DECIMAL column (38). When copying between Oracle databases, you must use SQL commands (CREATE TABLE AS and INSERTION), or you must make sure that your columns have a specified precision.

    SQL * the VALUE LONGER variable limits the length of the LONG column you are copying. If all LONG columns contain data exceeds the value of LONG, COPY truncates the data.

    SQL * Plus performs a validation at the end of each successful COPY. If you set the SQL * variable more COPYCOMMIT DEFINED to a value positive n, SQL * Plus performs a validation after copying all lots n of records. The SQL * Plus ARRAYSIZE variable SET determines the size of a batch.

    Some operating environments require that the service names be placed between double quotes.

    From a SQL * Plus term on DB3, can resemble the command to move all content from my_table in DB1 to the same table in DB2

    COPY from user1/pass1@DB1 to user2/pass2@DB2 -
    INSERT INTO my_table -
    USING select * from my_table
    

    Note the SQL code * more line-continuation character ' - '. It is used to escape the newline character in a SQL * Plus command if you do not have to type all on one line. I use it all the time with this command, but I can't locate the documentation on that right now. Maybe someone else can put their finger on it.

    There are other ways to accomplish what the command copy and it is not without its quirks and limitations, but I find that there is usefulness in an Oracle Toolbox.

  • Select random from the tables

    Another problem of mine, I hope we can clear the air:
    I have 4-5 tables with different products, these products have a price. In another table, I have just a column with a value (my money). What I have to do, he chooses one product from each table and the sum of all should not be greater than my money? A randomization but how?
    If you need to learn more, say please and I'll post an example, I need help thanks

    Hello

    You can create the source of the page as a SQL something like element:

    WITH X AS (
    SELECT ROWNUM RR, DRINKS.NAME || ' ' || DRINKS.PRICE || ' ' || F1.PRODUCT || ' ' || F1.PRICE || ' ' || F2.PRODUCT || ' ' || F2.PRICE || ' ' || DESERT.PRODUCT || ' ' || DESERT.PRICE OUTPUT
    FROM MONEY M
    CROSS JOIN DRINKS
    CROSS JOIN F1
    CROSS JOIN F2
    CROSS JOIN DESERT
    WHERE DRINKS.PRICE + F1.PRICE + F2.PRICE + DESERT.PRICE <= M.MONEY)
    SELECT X.OUTPUT
    FROM X
    WHERE X.RR = TRUNC(DBMS_RANDOM.VALUE(1, (SELECT COUNT(*) FROM X)))
    

    Andy

  • retrieve the records from the oracle sql query

    Hello

    I'm stuck with a requirement where I need to retrieve some recordset based on the conditions. I won't be able to produce the same data and table here, but I can explain the problem with the example statement:

    If col2 contains 'y' to any folder, then select only the records. Where, as if no line contains the value 'y' for col2 then retrieve all records.

    Database version: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64 bit Production

    with temp (col1,col2)
    as
    (select level,decode(mod(level,2),0,'y',1,'n')
    from dual
    connect by level < 10)
    select * from temp;
    
    

    Please help, if possible through sql.

    Thank you

    Vikram

    Something like below... Considered as non-null column col2...

    with the temp (col1, col2)

    as

    (select level, decode (mod(level,2), 0, 'y', 1,' no))

    of the double

    connect by level<>

    Select * from temp

    WHERE col2 = NVL ((SELECT col2 FROM temp OÙ col2 = 'y' ET rownum = 1), col2);

  • How to pass Variables from the Source (SQL) to tab target (JavaBin Shell) in ODI knowledge Modules

    Hi all

    My name is Alessandro and I am new to the community.

    I have a problem with the KM stage custom when I try to pass the variable from the source to the target.

    The ODI version tha I use is the 11.1.1.5.0.

    I created a stage KM following the instructions of the metalink document (Doc ID 728636.1).

    But when I insert the value of the variable in a test table, the value in a table is the name of the variable.

    Where I'm wrong?

    I am doing thi.

    (1) create a step in my goal of shell sql source and javabin KM. In the source tab I get the value of a query, and the name "LAST_UPDATE" column.

    In the target tab, I attribute to the variabile jv_last_update the value of the variable #LAST_UPDATE, with the same name in the selection column.

    source_tab.jpgtarget_tab.jpg

    (2) I created a second stage where I insert into a table of the value of the variable jv_last_update (to debug the value of the variable):

    insert_step.jpg

    (3) when I try to see what I have in the table, the value of any line is the name of the variable "#LAST_UPDATE"; ".

    result_table.jpg

    Thanks in advance


    Alessandro

    Hi Alessandro,.

    Interesting... I have not read the Oracle document you sent yet, but one thing I can guarantee you, is that it doesn't. If Oracle says that it should work, maybe it's a bug, or maybe he has changed on new versions of ODI. I am also on ODI 11.1.1.5 and I tried many different ways to pass SQL results to variables of java with all sorts of different labels, but none of them worked for me as well. But I managed to use it in a different way, so please see below if it matches your needs:

    We are just one step. The second is just to show that it worked:

    In the first step, on the source tab, select Oracle and point to the logical schema that you want to run the query:

    On the target, note the following Java BeanShell code with the SQL that you want to run:

    Now your variable must have the correct value of your SQL. To test it, I just write a comment 'Raise' to Jython in the second step:

    The result is 'X' as expected:

    It will be useful.

    Thank you!

Maybe you are looking for

  • Microsoft Word hangs when recording

    Hello everyone, I have a problem with Microsoft Word on my Mac mini. Whenever I save a document twice in a row, Word crashes. I use the latest update of Microsoft software. I tried step 4 and 5 of this page, but it does not solve the problem https://

  • Problem with USB-232

    OK - this is probably a simple question, but it is at the origin of the questions that I do not know how to solve.  I am running LV 2013 on a 64-bit Windows 8 machine and I can't get the computer to identify a device USB-232 of NOR.  I'm under 4.0 Se

  • HP Laserjet 2100 does not work after upgrade Windows 10

    HP Laserjet 2100 does not work after upgrade to Windows 10. Tried using PCL 5, PCL 6 and also tried the HP Universal print driver. I agree, this is an old printer, but I am disappointed told me "the printer is in error" when I try to print after this

  • HP Pavilion Elite HPE - 500f D: SSD replacement for HP Pavilion Elite HPE-500f to original desktop PC hard drive

    Hi all! I would like to replace the original hard drive came with my desktop HP Pavilion Elite HPE-500f with an SSD, but when I tried, I got the error message that my SSD drive was not big enough. The original hard drive is 1.35 TB. What size an SSD

  • Problems with msvbvm60.dll

    When I open the Control Panel, under appearance and themes, and I click on display in shooters of boredom, I get the following message: "this application has failed to start because msvbvm60.dll was not found." Can someone tell me what I need to plea