Nested statements using count(*)

Hi!
I have a problem when trying to select rows in one table which occur more than once in another table.
Like this:
Test1
CARTID ------ CUSTOMER
1-----------------Stan
2-----------------Jenny
3-----------------Robert
4-----------------Allen
5-----------------Sara
Test2
CARTID ------ GOODS
1-----------------Sugar
1-----------------Salt
3-----------------Wheat
4-----------------Pepper
4-----------------Pepper
So, I want to select the Customers who have the same goods more than once in their cart. And also add a count of how many instances of the specific goods that are lying in the cart.
CUSTOMER-----------COUNT
4444----------------------2
I have tried something like this without successful result.
SELECT CUSTOMER FROM Test1
WHERE CARTID IN (SELECT CARTID, COUNT(*) TotalCount
FROM Test2
WHERE GOODSID = 'Pepper'
GROUP BY CARTID
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC)
Solution, anyone? =)
/Björn

Something like this?
SQL> with test1 as
  2  (
  3  select 1 cart_id, 'Stan' customer from dual
  4  union all
  5  select 2 cart_id, 'Jenny' customer from dual
  6  union all
  7  select 3 cart_id, 'Robert' customer from dual
  8  union all
  9  select 4 cart_id, 'Allen' customer from dual
10  union all
11  select 5 cart_id, 'Sara' customer from dual
12  )
13  , test2 as
14  (
15  select 1 cart_id, 'Sugar' goods from dual
16  union all
17  select 1 cart_id, 'Salt' goods from dual
18  union all
19  select 3 cart_id, 'Wheat' goods from dual
20  union all
21  select 4 cart_id, 'Pepper' goods from dual
22  union all
23  select 4 cart_id, 'Pepper' goods from dual
24  )
25  , test_join as
26  (select test2.cart_id cart_id,
27          test1.customer customer,
28          test2.goods goods,
29          row_number() over (partition by test2.cart_id,
30                                          test2.goods
31                             order by test2.goods) rn,
32          count(test2.goods) over (partition by test2.cart_id,
33                                                test2.goods) cnt
34  from test1,
35       test2
36  where test1.cart_id = test2.cart_id
37  )
38  select cart_id, customer, goods, cnt
39  from test_join
40  where rn = 1
41  /
   CART_ID CUSTOM GOODS         CNT
         1 Stan   Salt            1
         1 Stan   Sugar           1
         3 Robert Wheat           1
         4 Allen  Pepper          2
SQL> Cheers
sarma.

Similar Messages

  • Possible bug using count in sort statement

    I think there may be a bug in using count as the means to sort nodes. Below is an example of what I am describing. It appears that when the sort is performed the number of nodes is accurately calculated for each item. I printed the values out and hand counted the elements in the xml to ensure this to be the case. What appears to happen is the count value is treated as a string and not an integer, so the comparison is lexical string compare and not integer compare as would be expected. So 2 ends up being greater then 10. Has anyone else come across this?
    <xsl:template name="Sort" >
    <xsl:apply-templates select="//item">
              <xsl:sort order="descending" select="count(.//Skill[contains(@name,$SKILLS/@name)])"/>
    </xsl:apply-templates>
    </xsl:template>

    Never mind. I am a total tard and forgot to set the data-type to number

  • How to use Count with Date Parameters

    Hello,
    I am having issues using the Count() function in conjunction with date parameters.
    This is a Siebel report and in my report I have 2 date parameters(From Date, To Date). In a nutshell I am basically trying to count Opportunities that has a start date within the given date period. However I don't see a reasonable way to put my date parameters within the Count() function. The reason being is that I need to have a huge chunk of code to convert the dates into a common format that can be compared, and it won't even fit within the code block in my rtf template. I am not even sure how to put multiple conditional statements inside a Count() function since all the examples I have seen are very simple.
    Anyone have a suggestion on how to use Count() with date parameters?
    Thanks.

    Any chance you can get the date formats in the correct format from siebel?
    I don't know Siebel - so I can't help you with that. If you get the correct format it is just
    <?count(row[(FromDate>=date) and  (date<=ToDate))?>
    Otherwise the approach would probably need to use string function to get year/monthd/day from the date
    and store it into a varialbe and compare later the same way
    <?variable@incontext:from; ....?>
    <?variable@incontext:to; ...?>
    <?count(row[($from>=date) and  (date<=$to))?>
    Potentially you can use the date functions such as xdofx:to_date to do the conversion
    [http://download.oracle.com/docs/cd/E12844_01/doc/bip.1013/e12187/T421739T481158.htm]
    But I am not sure if they are available in your siebel implementation.
    Hope that helps

  • How to write nested queries using DB Adapter?

    I want to write following nested query using DB Adapter can any one help...
    SELECT INVOICE_ID,FILE_NAME FROM  BILLING_INVOICE_PDF_V where FILE_ID =(
    (SELECT MAX(FILE_ID) FROM  BILLING_INVOICE_PDF_V WHERE  (INVOICE_ID = ‘12345’)));
    Thanks,
    Ram.

    Hi Ram,
    Most likely it is the semicolon at the end of the SQL statement that's causing the db adapter to throw the error; just enter the custom sql statement without a semicolon at the end.
    SELECT INVOICE_ID,FILE_NAME FROM  BILLING_INVOICE_PDF_V where FILE_ID = (SELECT MAX(FILE_ID) FROM  BILLING_INVOICE_PDF_V WHERE INVOICE_ID = '12345')

  • Java.sql exception for rs.nesxt() ( nested statements)

    I have a problem with java.sql.I am getting an Invalid handle exception for nested result sets ...
    example:-
    //Conn is the common connection
    Statement s1 = conn.createStatement();
    rs1 = s1.executeQuery(query1);
    while (rs.next){
    Statement s2 = conn.createStatement();
    rs2= s2.executeQuery(query2)
    while (rs2.next){
    The rs2 resultset works fine,but when it gets back into the outer while loop the exception is thrown.
    I know that the problem is becuase the nested statements are usign the same connection.
    I know of two ways to work around this
    (1) use different connections
    (2) remove nesting (save the result rs1,and then retrieve rs2)
    But I wnated to know if anyone knows of any other way to work around this problem.
    let me know.
    Thanks.

    Each connection has a single storage area for iteration, metadata, etc. Obviously you are aware that outer loop is unable to proceed because iteration data is of a different format from the inner sql query. It is not a good idea to do more than a single, or small set of queries on a single connection object. Would you consider a connection pool? They are not for the timid programmer, but they do take advantage of using connection objects much like pointers, with the ability to pop them into and out of a collection, ready to roll once the connection object is setup and ready for action much like a pointer that is properly assigned can be passed and always ready for action. The entire connection object (and metadata) is stored in the collection data structure. My advice is to keep it simple! It is easy to get too carried away with connection pools.

  • Object use count is negative when two users access ViewObject at same time

    I need help!
    In my application, if two users execute the same view object at the same time, the users will see a combination of the two record sets: One user will receive their requested result set plus part of the other user's set and the other will receieve only a partial result set.
    Here is what I get in the BC4J log:
    [1397] Diagnostic Properties: Timing:false Functions:false Linecount:true Threshold:6
    [1398] Connected to Oracle JBO Server - Version: 9.0.5.16.0
    [1399] mPCollUsePMgr is false
    [1400] ViewObjectImpl.mDefaultMaxRowsPerNode is 70
    [1401] ViewObjectImpl.mDefaultMaxActiveNodes is 30
    [1402] Default locking mode changed to: optimistic
    [1403] Created root application module: 'net.tetra.w2ms.Manager.model.w2ms_mgr_AppModule'
    [1404] Locale is: 'en_US'
    [1405] Oracle SQLBuilder: Registered driver: oracle.jdbc.driver.OracleDriver
    [1406] Creating a new pool resource
    [1407] Trying connection/2: url='jdbc:oracle:thin:@tetusdb01.tetra.net:1521:TETDW' info='{user=tetw2ms, password=wireless2}' ...
    [1408] Successfully logged in
    [1409] JDBCDriverVersion: 9.0.1.5.0
    [1410] DatabaseProductName: Oracle
    [1411] DatabaseProductVersion: Oracle9i Enterprise Edition Release 9.2.0.3.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.3.0 - Production
    [1412] Column count: 39
    [1413] ViewObject: ImBininventoryView close prepared statements...
    [1414] ViewObject: ImBininventoryView Created new QUERY statement
    [1415] SELECT ImBininventory.ITEMNUMBER, ImBininventory.STATUS, ImBininventory.LOCATION, ImBininventory.PALLETNUMBER, ImBininventory.LOTNUMBER, ImBininventory.STATUS1, ImBininventory.ITEM1, ImBininventory.LOCATION1, ImBininventory.PALLET1, ImBininventory.LOT1, ImBininventory.LOCATION2, ImBininventory.ITEM2, ImBininventory.STATUS2, ImBininventory.PALLET2, ImBininventory.LOT2, ImBininventory.PALLET3, ImBininventory.LOT4, ImBininventory.LOCATION5, ImBininventory.STATUS5, ImBininventory.PALLET5, ImBininventory.LOT5, ImBininventory.ITEM5, ImBininventory.ITEM6, ImBininventory.STATUS6, ImBininventory.EXPIRATIONDATE6, ImBininventory.RECEIVEDATE6, ImBininventory.LOCATION6, ImBininventory.PALLET6, ImBininventory.LOT6, ImBininventory.QTYONHANDNEG7, ImBininventory.QTYONHAND, ImBininventory.QTYALLOCATED, ImBininventory.QTYBACKORDERED, ImBininventory.QTYONORDER, ImBininventory.PONUMBER, ImBininventory.FREEZEQTYONHAND, ImBininventory.STOPSHIPDATE, ImBininventory.DATELASTCOUNTED, ImBininventory.FILLER FROM IM_BININVENTORY ImBininventory WHERE (location2 = '#RCV' and qtyonhand > 0)
    [1416] Bind params for ViewObject: ImBininventoryView
    [1417] Column count: 8
    [1418] ViewObject: VReplenishmentView close prepared statements...
    [1419] ViewObject: VReplenishmentView Created new QUERY statement
    [1420] SELECT VReplenishment.ITEMNUMBER, VReplenishment.BIN, VReplenishment.QTYONHAND, VReplenishment.DEMAND, VReplenishment.QTY_TO_PICK, VReplenishment.ENABLED, VReplenishment.UNITSPERPALLET, VReplenishment.PALLETCAPACITY FROM V_REPLENISHMENT VReplenishment WHERE (1=1)
    [1421] Bind params for ViewObject: VReplenishmentView
    [1422] Column count: 8
    [1423] ViewObject: VReplenishmentView Reusing defined prepared Statement
    [1424] Bind params for ViewObject: VReplenishmentView
    [1425] $$added root$$ id=-2
    [1426] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:647)
         at net.tetra.w2ms.Manager.model.VReplenishmentViewRowImpl.getItemnumber(VReplenishmentViewRowImpl.java:41)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2169)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1427] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:647)
         at net.tetra.w2ms.Manager.model.VReplenishmentViewRowImpl.getBin(VReplenishmentViewRowImpl.java:57)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2169)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1428] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:647)
         at net.tetra.w2ms.Manager.model.VReplenishmentViewRowImpl.getQtyonhand(VReplenishmentViewRowImpl.java:73)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2169)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1429] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:647)
         at net.tetra.w2ms.Manager.model.VReplenishmentViewRowImpl.getBin(VReplenishmentViewRowImpl.java:57)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2169)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.validate(ViewRowImpl.java:615)
         at oracle.jbo.server.ViewRowSetIteratorImpl.validateCurrentRow(ViewRowSetIteratorImpl.java:3090)
         at oracle.jbo.server.ViewRowSetIteratorImpl.next(ViewRowSetIteratorImpl.java:1545)
         at oracle.jbo.server.ViewRowSetImpl.next(ViewRowSetImpl.java:2606)
         at oracle.jbo.server.ViewObjectImpl.next(ViewObjectImpl.java:5006)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2140)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1431] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:647)
         at net.tetra.w2ms.Manager.model.VReplenishmentViewRowImpl.getQtyonhand(VReplenishmentViewRowImpl.java:73)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2169)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1432] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:647)
         at net.tetra.w2ms.Manager.model.VReplenishmentViewRowImpl.getItemnumber(VReplenishmentViewRowImpl.java:41)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2169)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1432] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.validate(ViewRowImpl.java:615)
         at oracle.jbo.server.ViewRowSetIteratorImpl.validateCurrentRow(ViewRowSetIteratorImpl.java:3090)
         at oracle.jbo.server.ViewRowSetIteratorImpl.next(ViewRowSetIteratorImpl.java:1545)
         at oracle.jbo.server.ViewRowSetImpl.next(ViewRowSetImpl.java:2606)
         at oracle.jbo.server.ViewObjectImpl.next(ViewObjectImpl.java:5006)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2140)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1434] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:647)
         at net.tetra.w2ms.Manager.model.VReplenishmentViewRowImpl.getBin(VReplenishmentViewRowImpl.java:57)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2169)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1435] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:647)
         at net.tetra.w2ms.Manager.model.VReplenishmentViewRowImpl.getQtyonhand(VReplenishmentViewRowImpl.java:73)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2169)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1436] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:647)
         at net.tetra.w2ms.Manager.model.VReplenishmentViewRowImpl.getItemnumber(VReplenishmentViewRowImpl.java:41)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2169)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1437] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:647)
         at net.tetra.w2ms.Manager.model.VReplenishmentViewRowImpl.getBin(VReplenishmentViewRowImpl.java:57)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2169)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1438] oracle.jbo.common.JboAssert: (Assertion Failed) Object use count is negative on VR of VO VReplenishmentView
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:303)
         at oracle.jbo.common.Diagnostic.ASSERT(Diagnostic.java:326)
         at oracle.jbo.server.ViewRowStorage.releaseUse(ViewRowStorage.java:134)
         at oracle.jbo.server.ViewRowImpl.releaseInner(ViewRowImpl.java:238)
         at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:647)
         at net.tetra.w2ms.Manager.model.VReplenishmentViewRowImpl.getQtyonhand(VReplenishmentViewRowImpl.java:73)
         at net.tetra.w2ms.Wavelink.BCBroker.getReplenishments(BCBroker.java:2169)
         at net.tetra.w2ms.Wavelink.events.tasks_OnLoad.process(tasks_OnLoad.java:39)
         at com.wavelink.edge.events.PostData.ZzW(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.vw(Unknown Source)
         at com.wavelink.edge.events.ApplicationContext.handleEvent(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.yZW(Unknown Source)
         at com.wavelink.studio.server.SessionServlet.doPost(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:208)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:125)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    [1439] Column count: 8
    [1440] ViewObject: VReplenishmentView Reusing defined prepared Statement
    [1441] Bind params for ViewObject: VReplenishmentView
    [1442] $$added root$$ id=-2
    Does anyone have any ideas? This is a very frustrating problem!

    A little more detail...
    Deployment is to iAS 10g (9.0.4)
    App written with jdev 9.0.5.2
    Code where problem occurs:
    public String[] getReplenishments() throws Exception {
    String[] replenishmentLists = new String[2];
    boolean firstTime = true;
    try {
    if (w2msAM == null) {
    w2msAM = Configuration.createRootApplicationModule(amDef, config);
    ViewObject vo = w2msAM.findViewObject("VReplenishmentView");
    vo.setWhereClause("1=1");
    vo.executeQuery();
    logger.debug("VReplenishmentView returned " + vo.getRowCount() +
    " rows");
    StringBuffer rlDisplay = new StringBuffer();
    StringBuffer rlFile = new StringBuffer();
    while (vo.hasNext()) {
    if (!firstTime) {
    rlFile.append("\n");
    rlDisplay.append(",");
    firstTime = false;
    VReplenishmentViewRowImpl row = (VReplenishmentViewRowImpl) vo.next();
    rlFile.append(row.getItemnumber());
    rlDisplay.append(" " +
    (StringHelper.padRight(row.getItemnumber(), 14) +
    StringHelper.padRight(row.getBin(), 11) +
    StringHelper.padLeft(String.valueOf(
    row.getQtyonhand().longValue()).toString(), 4)));
    if (rlFile != null) {
    replenishmentLists[0] = rlFile.toString();
    rlFile = null;
    replenishmentLists[1] = rlDisplay.toString();
    rlDisplay = null;
    } else {
    replenishmentLists[0] = "";
    replenishmentLists[1] = "";
    vo.closeRowSet();
    vo.setWhereClause("1=1");
    return replenishmentLists;
    } catch (Exception e) {
    logger.error("getReplenishments:" + e.toString());
    e.printStackTrace();
    throw e;
    Thanks for any help...
    Dirk.

  • Statement using 25% CPU

    Hi
    the following statement is taking 25% CPU to run. Although the statement completes in around 30 seconds, I have been advised that the CPU usage needs to be reduced as we can have over 4 instances of the same process running at any one time. Please can anyone make any suggestions to reduce the amount of CPU used?
    The statement is:
        INSERT /*+APPEND */ INTO LINE_CALL_OVER_20P
        (ID,RUN_DATA,BILL_DATA,TEL_LINE_ID,CALL_DETS_TOTS,LINE_CALL_CHGS,LINE_TYPE,EXP_SEQ1,DESCR_CODE,AMT,DESCR_TEXT,DUR_MINS,DUR_SECS,TOTAL_AMT)
        (SELECT                      1,                                                                        -- ID
                                     U1.SITE_ID || U1.PROCESS_CTRL,                                            -- RUN DATA
                                     U1.ACCT_NUM || U1.STMT_CODE,                                              -- BILL DATA
                                     O1.SRV_ACCT_NUM||U1.CAT_CODE||U1.SRV_OCCUR,                               -- TEL LINE ID
                                     U1.ACCT_NUM || U1.SEQ_1,                                                  -- CALL DETS TOTALS
                                     1,                                                                        -- LINE CALL CHGS
                                     u1.line_type,                                                             -- LINE TYPE
                                     u1.seq_1,                                                                 -- SEQ 1
                                     u1.descr_code,                                                            -- DESCR CODE
                                     (CASE
                                      WHEN REGEXP_LIKE(SUM(u1.usage_amt), '^[0-9]+$') AND REGEXP_LIKE(SUM(u11.usage_amt), '^[0-9]+$') THEN
                                         SUM(SUBSTR(u1.usage_amt,1,LENGTH(u1.usage_amt)- 4) ||'.'|| SUBSTR(u1.usage_amt,LENGTH(u1.usage_amt)-(4+1)))
                                         - SUM(SUBSTR(u11.usage_amt,1,LENGTH(u11.usage_amt)- 4) ||'.'|| SUBSTR(u11.usage_amt,LENGTH(u11.usage_amt)-(4+1)))
                                      WHEN REGEXP_LIKE(SUM(u1.usage_amt), '^[0-9]+$') AND NOT REGEXP_LIKE(SUM(u11.usage_amt), '^[0-9]+$') THEN
                                         SUM(SUBSTR(u1.usage_amt,1,LENGTH(u1.usage_amt)- 4) ||'.'|| SUBSTR(u1.usage_amt,LENGTH(u1.usage_amt)-(4+1)))
                                         - SUM('-'||TRANSLATE(SUBSTR(u11.usage_amt,1,LENGTH(u11.usage_amt)- 4) ||'.'|| SUBSTR(u11.usage_amt,LENGTH(u11.usage_amt)- (4 + 1)),'},J,K,L,M,N,O,P,Q,R','0,1,2,3,4,5,6,7,8,9'))
                                      WHEN NOT REGEXP_LIKE(SUM(u1.usage_amt), '^[0-9]+$') AND REGEXP_LIKE(SUM(u11.usage_amt), '^[0-9]+$') THEN
                                         SUM('-'||TRANSLATE(SUBSTR(u1.usage_amt,1,LENGTH(u1.usage_amt)- 4) ||'.'|| SUBSTR(u1.usage_amt,LENGTH(u1.usage_amt)- (4 + 1)),'},J,K,L,M,N,O,P,Q,R','0,1,2,3,4,5,6,7,8,9'))
                                         - SUM(SUBSTR(u11.usage_amt,1,LENGTH(u11.usage_amt)- 4) ||'.'|| SUBSTR(u11.usage_amt,LENGTH(u11.usage_amt)-(4+1)))
                                      ELSE
                                         SUM('-'||TRANSLATE(SUBSTR(u1.usage_amt,1,LENGTH(u1.usage_amt)- 4) ||'.'|| SUBSTR(u1.usage_amt,LENGTH(u1.usage_amt)- (4 + 1)),'},J,K,L,M,N,O,P,Q,R','0,1,2,3,4,5,6,7,8,9'))
                                         - SUM('-'||TRANSLATE(SUBSTR(u11.usage_amt,1,LENGTH(u11.usage_amt)- 4) ||'.'|| SUBSTR(u11.usage_amt,LENGTH(u11.usage_amt)- (4 + 1)),'},J,K,L,M,N,O,P,Q,R','0,1,2,3,4,5,6,7,8,9'))
                                     END),
                                     h2.descr,                                                                 -- descr_text
                                     SUM(u2.USAGE_MINUTES),
                                     SUM(u2.USAGE_SECONDS),
                                     COUNT(u2.USAGE_AMT)
                                FROM stmtu1p u1,
                                     stmtu1p u11,
                                     stmtu1p u2,
                                     stmto1p o1,
                                     stmth2p h2
                               WHERE (u1.descr_code = h2.descr_code(+))
                                 AND u1.acct_num          = u11.acct_num
                                 AND u1.stmt_code         = u11.stmt_code
                                 AND u1.srv_acct_num      = u11.srv_acct_num
                                 AND u1.srv_occur         = u11.srv_occur
                                 AND u1.acct_num          = u2.acct_num
                                 AND u1.stmt_code         = u2.stmt_code
                                 AND u1.srv_acct_num      = u2.srv_acct_num
                                 AND u1.srv_occur         = u2.srv_occur
                                 AND u1.acct_num          = o1.acct_num
                                 AND u1.srv_acct_num      = o1.srv_acct_num
                                 AND u1.stmt_code         = o1.stmt_code
                                 AND u1.srv_occur         = o1.srv_occur
                                 AND u1.line_type         = 'OS'
                                 AND u1.seq_1             = 330
                                 AND u11.line_type        = 'DZ'
                                 AND u2.line_type         = 'DU'
                            GROUP BY u1.site_id,
                                     u1.process_ctrl,
                                     u1.acct_num,
                                     u1.stmt_code,
                                     O1.SRV_ACCT_NUM,
                                     o1.area_code,
                                     o1.exch_id,
                                     o1.phone_num,
                                     u1.seq_1,
                                     u1.line_type,
                                     u1.descr_code,
                                     u1.cat_code,
                                     u1.srv_occur,
                                     h2.descr)The execution plan for the statement is:
    PLAN_TABLE_OUTPUT
    Plan hash value: 3269235626
    | Id  | Operation               | Name               | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | INSERT STATEMENT        |                    |    88 | 15312 |       | 19465   (5)| 00:03:54 |
    |   1 |  LOAD AS SELECT         | LINE_CALL_OVER_20P |       |       |       |            |          |
    |   2 |   HASH GROUP BY         |                    |    88 | 15312 |       | 19465   (5)| 00:03:54 |
    |*  3 |    HASH JOIN OUTER      |                    |    88 | 15312 |       | 19464   (5)| 00:03:54 |
    |*  4 |     HASH JOIN           |                    |    88 | 14344 |       | 19382   (5)| 00:03:53 |
    |*  5 |      HASH JOIN          |                    |   126 | 15246 |       | 13050   (5)| 00:02:37 |
    |*  6 |       HASH JOIN         |                    |  2390 |   207K|  2160K| 12816   (5)| 00:02:34 |
    |*  7 |        TABLE ACCESS FULL| STMTU1P            | 47050 |  1608K|       |  6262   (5)| 00:01:16 |
    |*  8 |        TABLE ACCESS FULL| STMTU1P            | 57060 |  3009K|       |  6265   (5)| 00:01:16 |
    |   9 |       TABLE ACCESS FULL | STMTO1P            | 59033 |  1844K|       |   232   (7)| 00:00:03 |
    |* 10 |      TABLE ACCESS FULL  | STMTU1P            |   790K|    31M|       |  6309   (6)| 00:01:16 |
    |  11 |     TABLE ACCESS FULL   | STMTH2P            | 39680 |   426K|       |    80   (7)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - access("U1"."DESCR_CODE"="H2"."DESCR_CODE"(+))
       4 - access("U1"."ACCT_NUM"="U2"."ACCT_NUM" AND "U1"."STMT_CODE"="U2"."STMT_CODE" AND
                  "U1"."SRV_ACCT_NUM"="U2"."SRV_ACCT_NUM" AND "U1"."SRV_OCCUR"="U2"."SRV_OCCUR")
       5 - access("U1"."ACCT_NUM"="O1"."ACCT_NUM" AND "U1"."SRV_ACCT_NUM"="O1"."SRV_ACCT_NUM" AND
                  "U1"."STMT_CODE"="O1"."STMT_CODE" AND "U1"."SRV_OCCUR"="O1"."SRV_OCCUR")
       6 - access("U1"."ACCT_NUM"="U11"."ACCT_NUM" AND "U1"."STMT_CODE"="U11"."STMT_CODE" AND
                  "U1"."SRV_ACCT_NUM"="U11"."SRV_ACCT_NUM" AND "U1"."SRV_OCCUR"="U11"."SRV_OCCUR")
       7 - filter("U11"."LINE_TYPE"='DZ')
       8 - filter("U1"."LINE_TYPE"='OS' AND "U1"."SEQ_1"=330)
      10 - filter("U2"."LINE_TYPE"='DU')The tkprof file for the statement is:
    TKPROF: Release 10.2.0.1.0 - Production on Sun Feb 17 11:29:08 2008
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Trace file: /u01/app/oracle/admin/ORATEST/udump/oratest_ora_1396968.trc
    Sort options: default
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    alter session set sql_trace=true
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        1      0.00       0.00          0          0          0           0
    Misses in library cache during parse: 0
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 85  (PREPROC1)
        INSERT /*+APPEND */ INTO LINE_CALL_OVER_20P
        (ID,RUN_DATA,BILL_DATA,TEL_LINE_ID,CALL_DETS_TOTS,LINE_CALL_CHGS,LINE_TYPE,EXP_SEQ1,DESCR_CODE,AMT,DESCR_TEXT,DUR_MINS,DUR_SECS,TOTAL_AMT)
        (SELECT                      1,                                                                        -- ID
                                     U1.SITE_ID || U1.PROCESS_CTRL,                                            -- RUN DATA
                                     U1.ACCT_NUM || U1.STMT_CODE,                                              -- BILL DATA
                                     O1.SRV_ACCT_NUM||U1.CAT_CODE||U1.SRV_OCCUR,                               -- TEL LINE ID
                                     U1.ACCT_NUM || U1.SEQ_1,                                                  -- CALL DETS TOTALS
                                     1,                                                                        -- LINE CALL CHGS
                                     u1.line_type,                                                             -- LINE TYPE
                                     u1.seq_1,                                                                 -- SEQ 1
                                     u1.descr_code,                                                            -- DESCR CODE
                                     (CASE
                                      WHEN REGEXP_LIKE(SUM(u1.usage_amt), '^[0-9]+$') AND REGEXP_LIKE(SUM(u11.usage_amt), '^[0-9]+$') THEN
                                         SUM(SUBSTR(u1.usage_amt,1,LENGTH(u1.usage_amt)- 4) ||'.'|| SUBSTR(u1.usage_amt,LENGTH(u1.usage_amt)-(4+1)))
                                         - SUM(SUBSTR(u11.usage_amt,1,LENGTH(u11.usage_amt)- 4) ||'.'|| SUBSTR(u11.usage_amt,LENGTH(u11.usage_amt)-(4+1)))
                                      WHEN REGEXP_LIKE(SUM(u1.usage_amt), '^[0-9]+$') AND NOT REGEXP_LIKE(SUM(u11.usage_amt), '^[0-9]+$') THEN
                                         SUM(SUBSTR(u1.usage_amt,1,LENGTH(u1.usage_amt)- 4) ||'.'|| SUBSTR(u1.usage_amt,LENGTH(u1.usage_amt)-(4+1)))
                                         - SUM('-'||TRANSLATE(SUBSTR(u11.usage_amt,1,LENGTH(u11.usage_amt)- 4) ||'.'|| SUBSTR(u11.usage_amt,LENGTH(u11.usage_amt)- (4 + 1)),'},J,K,L,M,N,O,P,Q,R','0,1,2,3,4,5,6,7,8,9'))
                                      WHEN NOT REGEXP_LIKE(SUM(u1.usage_amt), '^[0-9]+$') AND REGEXP_LIKE(SUM(u11.usage_amt), '^[0-9]+$') THEN
                                         SUM('-'||TRANSLATE(SUBSTR(u1.usage_amt,1,LENGTH(u1.usage_amt)- 4) ||'.'|| SUBSTR(u1.usage_amt,LENGTH(u1.usage_amt)- (4 + 1)),'},J,K,L,M,N,O,P,Q,R','0,1,2,3,4,5,6,7,8,9'))
                                         - SUM(SUBSTR(u11.usage_amt,1,LENGTH(u11.usage_amt)- 4) ||'.'|| SUBSTR(u11.usage_amt,LENGTH(u11.usage_amt)-(4+1)))
                                      ELSE
                                         SUM('-'||TRANSLATE(SUBSTR(u1.usage_amt,1,LENGTH(u1.usage_amt)- 4) ||'.'|| SUBSTR(u1.usage_amt,LENGTH(u1.usage_amt)- (4 + 1)),'},J,K,L,M,N,O,P,Q,R','0,1,2,3,4,5,6,7,8,9'))
                                         - SUM('-'||TRANSLATE(SUBSTR(u11.usage_amt,1,LENGTH(u11.usage_amt)- 4) ||'.'|| SUBSTR(u11.usage_amt,LENGTH(u11.usage_amt)- (4 + 1)),'},J,K,L,M,N,O,P,Q,R','0,1,2,3,4,5,6,7,8,9'))
                                     END),
                                     h2.descr,                                                                 -- descr_text
                                     SUM(u2.USAGE_MINUTES),
                                     SUM(u2.USAGE_SECONDS),
                                     COUNT(u2.USAGE_AMT)
                                FROM stmtu1p u1,
                                     stmtu1p u11,
                                     stmtu1p u2,
                                     stmto1p o1,
                                     stmth2p h2
                               WHERE (u1.descr_code = h2.descr_code(+))
                                 AND u1.acct_num          = u11.acct_num
                                 AND u1.stmt_code         = u11.stmt_code
                                 AND u1.srv_acct_num      = u11.srv_acct_num
                                 AND u1.srv_occur         = u11.srv_occur
                                 AND u1.acct_num          = u2.acct_num
                                 AND u1.stmt_code         = u2.stmt_code
                                 AND u1.srv_acct_num      = u2.srv_acct_num
                                 AND u1.srv_occur         = u2.srv_occur
                                 AND u1.acct_num          = o1.acct_num
                                 AND u1.srv_acct_num      = o1.srv_acct_num
                                 AND u1.stmt_code         = o1.stmt_code
                                 AND u1.srv_occur         = o1.srv_occur
                                 AND u1.line_type         = 'OS'
                                 AND u1.seq_1             = 330
                                 AND u11.line_type        = 'DZ'
                                 AND u2.line_type         = 'DU'
                            GROUP BY u1.site_id,
                                     u1.process_ctrl,
                                     u1.acct_num,
                                     u1.stmt_code,
                                     O1.SRV_ACCT_NUM,
                                     o1.area_code,
                                     o1.exch_id,
                                     o1.phone_num,
                                     u1.seq_1,
                                     u1.line_type,
                                     u1.descr_code,
                                     u1.cat_code,
                                     u1.srv_occur,
                                     h2.descr)
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.03       0.04          0          0          0           0
    Execute      1     12.95      18.41      28872      94074        608       39018
    Fetch        0      0.00       0.00          0          0          0           0
    total        2     12.98      18.46      28872      94074        608       39018
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 85  (PREPROC1)
    Rows     Row Source Operation
          1  LOAD AS SELECT  (cr=94126 pr=28872 pw=1727 time=18450373 us)
      39018   HASH GROUP BY (cr=94061 pr=28872 pw=1245 time=17322258 us)
    258728    HASH JOIN OUTER (cr=94061 pr=27627 pw=0 time=12275770 us)
    258728     HASH JOIN  (cr=93694 pr=27627 pw=0 time=12974313 us)
      46380      HASH JOIN  (cr=62830 pr=23324 pw=0 time=6837995 us)
      46380       HASH JOIN  (cr=61729 pr=23324 pw=0 time=9986105 us)
      46381        TABLE ACCESS FULL STMTU1P (cr=30865 pr=17444 pw=0 time=4545326 us)
      57603        TABLE ACCESS FULL STMTU1P (cr=30864 pr=5880 pw=0 time=2073762 us)
      59033       TABLE ACCESS FULL STMTO1P (cr=1101 pr=0 pw=0 time=77 us)
    789379      TABLE ACCESS FULL STMTU1P (cr=30864 pr=4303 pw=0 time=793734 us)
      39954     TABLE ACCESS FULL STMTH2P (cr=367 pr=0 pw=0 time=105 us)
    Rows     Execution Plan
          0  INSERT STATEMENT   MODE: ALL_ROWS
          1   LOAD AS SELECT OF 'LINE_CALL_OVER_20P'
      39018    HASH (GROUP BY)
    258728     HASH JOIN (OUTER)
    258728      HASH JOIN
      46380       HASH JOIN
      46380        HASH JOIN
      46381         TABLE ACCESS   MODE: ANALYZED (FULL) OF 'STMTU1P'
                        (TABLE)
      57603         TABLE ACCESS   MODE: ANALYZED (FULL) OF 'STMTU1P'
                        (TABLE)
      59033        TABLE ACCESS   MODE: ANALYZED (FULL) OF 'STMTO1P'
                       (TABLE)
    789379       TABLE ACCESS   MODE: ANALYZED (FULL) OF 'STMTU1P' (TABLE)
      39954      TABLE ACCESS   MODE: ANALYZED (FULL) OF 'STMTH2P' (TABLE)
    select file#
    from
    file$ where ts#=:1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        4      0.00       0.00          0          0          1           0
    Execute      4      0.01       0.00          0          0          0           0
    Fetch       12      0.00       0.00          0         20          0           8
    total       20      0.01       0.01          0         20          1           8
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    Rows     Row Source Operation
          2  TABLE ACCESS FULL FILE$ (cr=5 pr=0 pw=0 time=67 us)
    update tsq$ set blocks=:3,maxblocks=:4,grantor#=:5,priv1=:6,priv2=:7,priv3=:8
    where
    ts#=:1 and user#=:2
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        4      0.00       0.00          0          0          2           0
    Execute      4      0.01       0.00          0         12          4           4
    Fetch        0      0.00       0.00          0          0          0           0
    total        8      0.01       0.01          0         12          6           4
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    Rows     Row Source Operation
          0  UPDATE  TSQ$ (cr=3 pr=0 pw=0 time=267 us)
          1   TABLE ACCESS CLUSTER TSQ$ (cr=3 pr=0 pw=0 time=83 us)
          1    INDEX UNIQUE SCAN I_USER# (cr=1 pr=0 pw=0 time=27 us)(object id 11)
    update seg$ set type#=:4,blocks=:5,extents=:6,minexts=:7,maxexts=:8,extsize=
      :9,extpct=:10,user#=:11,iniexts=:12,lists=decode(:13, 65535, NULL, :13),
      groups=decode(:14, 65535, NULL, :14), cachehint=:15, hwmincr=:16, spare1=
      DECODE(:17,0,NULL,:17),scanhint=:18
    where
    ts#=:1 and file#=:2 and block#=:3
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        4      0.00       0.00          0          0          0           0
    Execute      4      0.01       0.00          0         20          4           4
    Fetch        0      0.00       0.00          0          0          0           0
    total        8      0.01       0.01          0         20          4           4
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    Rows     Row Source Operation
          0  UPDATE  SEG$ (cr=5 pr=0 pw=0 time=338 us)
          1   TABLE ACCESS CLUSTER SEG$ (cr=5 pr=0 pw=0 time=162 us)
          1    INDEX UNIQUE SCAN I_FILE#_BLOCK# (cr=2 pr=0 pw=0 time=24 us)(object id 9)
    commit
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          2         35           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.00       0.00          0          2         35           0
    Misses in library cache during parse: 0
    Parsing user id: 85  (PREPROC1)
    alter session set sql_trace=false
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.00       0.00          0          0          0           0
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 85  (PREPROC1)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        3      0.03       0.04          0          0          0           0
    Execute      4     12.95      18.42      28872      94076        643       39018
    Fetch        0      0.00       0.00          0          0          0           0
    total        7     12.98      18.47      28872      94076        643       39018
    Misses in library cache during parse: 2
    Misses in library cache during execute: 1
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse       12      0.00       0.01          0          0          3           0
    Execute     12      0.03       0.01          0         32          8           8
    Fetch       12      0.00       0.00          0         20          0           8
    total       36      0.03       0.03          0         52         11          16
    Misses in library cache during parse: 3
    Misses in library cache during execute: 3
        4  user  SQL statements in session.
       12  internal SQL statements in session.
       16  SQL statements in session.
        1  statement EXPLAINed in this session.
    Trace file: /u01/app/oracle/admin/ORATEST/udump/oratest_ora_1396968.trc
    Trace file compatibility: 10.01.00
    Sort options: default
           1  session in tracefile.
           4  user  SQL statements in trace file.
          12  internal SQL statements in trace file.
          16  SQL statements in trace file.
           7  unique SQL statements in trace file.
           1  SQL statements EXPLAINed using schema:
               PREPROC1.prof$plan_table
                 Default table was used.
                 Table was created.
                 Table was dropped.
         232  lines in trace file.
          50  elapsed seconds in trace file.Many thanks

    Absolutely spot on Rob. Yours is better than mine.
    I was looking at something like this. Below ones will be the inner query.
    select 1,                                                                        -- ID
           U1.SITE_ID || U1.PROCESS_CTRL,                                            -- RUN DATA
           U1.ACCT_NUM || U1.STMT_CODE,                                              -- BILL DATA
           O1.SRV_ACCT_NUM||U1.CAT_CODE||U1.SRV_OCCUR,                               -- TEL LINE ID
           U1.ACCT_NUM || U1.SEQ_1,                                                  -- CALL DETS TOTALS
           1,                                                                        -- LINE CALL CHGS
           u1.line_type,                                                             -- LINE TYPE
           u1.seq_1,                                                                 -- SEQ 1
           u1.descr_code,                                                            -- DESCR CODE
           sum(case when u1.line_type = 'OS'
           and u1.seq_1 = 330 then
           usage_amt
                     else 0
                end) u1_sum_usage_amt
          ,sum(decode(u1.line_type, 'DZ', usage_amt, 0)) u11_sum_usage_amt
          ,sum(decode(u1.line_type, 'DU', usa_minutes, 0)) u2_sum_minutes
          ,sum(decode(u1.line_type, 'DU', usa_seconds, 0)) u2_sum_seconds
          ,sum(decode(u1.line_type, 'DU', usage_amt, 0)) u2_sum_usage_amt
    from stmtu1p u1,
         stmto1p o1,
         stmth2p h2
    WHERE u1.descr_code = h2.descr_code(+)
    AND u1.acct_num          = o1.acct_num
    AND u1.srv_acct_num      = o1.srv_acct_num
    AND u1.stmt_code         = o1.stmt_code
    AND u1.srv_occur         = o1.srv_occur
    AND u1.line_type         = 'OS'
    AND u1.seq_1             = 330
    AND u11.line_type        = 'DZ'
    AND u2.line_type         = 'DU'
    GROUP BY u1.site_id,
             u1.process_ctrl,
             u1.acct_num,
             u1.stmt_code,
             O1.SRV_ACCT_NUM,
             o1.area_code,
             o1.exch_id,
             o1.phone_num,
             u1.seq_1,
             u1.line_type,
             u1.descr_code,
             u1.cat_code,
             u1.srv_occur,
             h2.descrAnd then in the outer query he can have something like this.
    case when REGEXP_LIKE(u1_sum_usage_amt, '^[0-9]+$') ...He should be able to change the query and gain considerable performance advantage with your start-up.
    Cheers
    Sarma.

  • DML on nested tables using SQL

    Hello. Can anyone tell me what's wrong??
    SQL> create type mytype as table of varchar2(20);
    Type created
    real: 78
    SQL> declare
    2 c mytype;
    3 begin
    4 select table_name bulk collect into c from user_tables;
    5 delete from table(cast(c as mytype));
    6 end;
    7 /
    declare
    ERROR at line 1:
    ORA-06550: line 5, column 13:
    PL/SQL: ORA-00903: invalid table name
    ORA-06550: line 5, column 1:
    PL/SQL: SQL Statement ignored
    real: 31

    we cannot use variables in regular SQL. It has to be
    dynamic, viz
    begin
    for r in ( select table_name from user_tables )
    loop
    execute immediate ' delete from '||r.table_name;
    d loop;
    end;
    /Cheers, APCyes, but user_tables was only a example. I want to load some data into nested table using BULK COLLECT and then perform some operation on this pl/sql table.
    For example:
    SELECT col BULK COLLECT INTO c FROM a_table;
    SELECT * BULK COLLECT INTO d FROM TABLE(CAST (c AS sql_type));
    --After that c and d contain the same data
    --but for example
    UPDATE TABLE(CAST(c AS sql_type)) Set c.col=...;
    generates invalid table name.
    Why SELECT INTO works, and UPDATE doesn't (all of this was in PL/SQL context, not SQL).

  • How to use Counter?

    i have a character Order Number
    Now in report for some set of data i have to show, Number of orders
    i think i need to use Counter in order to do that? yes/no
    how to use that
    lets say for month of January, user want to see the total # of orders for State- California...
    how to do that?
    thnking u

    Hello
    Put your date characteristics in the row, same with the state (unless you want to filter a specific value then, just filter on it without adding it).
    In the column, create a structure (Right-mouse click --> "New Structure")
    Right-mouse click on the "Structure" just added and select "New Formula"
    Use the value "1" as the calculation of this formula and then select the tab "Aggregation", pick the "Counter for All Detailed Values" and as a reference characteristics, pick your "Order Document" characteristics.
    Simple as that.
    Regards,
    John

  • Last 10 records of a table with out using count

    How can i get last 10 records of a table with out using count() method? if there is some page size(eg 10) , and if we want last page. is it posible without ount()? if posible how?
    Message was edited by:
    user480375

    "is there any other way without nesting?"
    Not correctly, no. What is your problem with nesting? Nested queries are not inherently slower than unnested queries. In some cases, such as this, they are the only correct way to do the query. Even an analytic version of the Top N needs to be nested because:
    SQL> SELECT object_name
      2  FROM t
      3  WHERE ROW_NUMBER() OVER (ORDER BY object_name DESC) < 11
      4  /
    WHERE ROW_NUMBER() OVER (ORDER BY object_name DESC) < 11
    ERROR at line 3:
    ORA-30483: window  functions are not allowed hereTTFN
    John

  • Case statements to count Contact numbers

    Hi,
    I'm trying to use CASE IF or WHEN statements to count simple Contact numbers by owner or region. I need to count the following in separate fields of course:
    Number of contact type = Customers
    Number of Contact types = Propects
    Number of Contacts at each seniority level (6 levels)
    Number of contact validated (tick box)
    I presume I need to write a CASE statement that I can then use to Sum for each column but I'm struggling with CASE statements to apply an CASE IF Column equals 'Customer' then count 1 for example. Never done these before so any help or advice greatly appreciated.
    Contact type field is Contact."Contact Type"
    Contact Seniority is Contact.PICK_3
    Thanks,
    Chris

    here is an example:
    sum (case when contact type = 'Customers' then 1 else 0 end)
    Do the same for the second and forth in your list as above ;
    include the Contact.PICK_3 and # of contact fields in step 1;
    add region, owner, # of Customers, # of Prospects and # of validated in row section of your pivot view;
    add Contact.PICK_3 to column section;
    add # of contact to the measurement section.

  • I have to use count function  in "if-else" condition in rtf tempelate

    I have a nedd to use count fucntion in my rtf fucntion in IF-ELSE condition like this :
    if
    (count INVOICE_LEVEL from xml where (INVOICE_LEVEL=SM_SUMMARY_LEVEL)) =  (count coloumn_A from xml ) --- if the count matches
    THEN print "NO DATA FOUND"
    else --- if not
    end if ;
    --------XML------
    <COMP123>
       <SM_SUMMARY_LEVEL>2</SM_SUMMARY_LEVEL>
      <SM_CHARGE_HEAD>2</SM_CHARGE_HEAD>
      <INVOICE_LEVEL>2</INVOICE_LEVEL>
      <RCVR_ADDRS3_PART1>SG</RCVR_ADDRS3_PART1>
      <RCVR_ADDRS3_PART2>ASIA ,</RCVR_ADDRS3_PART2>
      <TXN_CSTMR_REF>ABC-DEF</TXN_CSTMR_REF>
      <TAX_ID>PCT-ID</TAX_ID>
      </COMP123>
    <COMP123>
       <SM_SUMMARY_LEVEL>2</SM_SUMMARY_LEVEL>
      <SM_CHARGE_HEAD>2</SM_CHARGE_HEAD>
      <INVOICE_LEVEL>2</INVOICE_LEVEL>
      <RCVR_ADDRS3_PART1>SG</RCVR_ADDRS3_PART1>
      <RCVR_ADDRS3_PART2>ASIA ,</RCVR_ADDRS3_PART2>
      <TXN_CSTMR_REF>ABC-DEF</TXN_CSTMR_REF>
      <TAX_ID>PCT-ID</TAX_ID>
      </COMP123>
    can any one help me to write the correct syntax and logic for this .
    THANKS!

    I am using the below way but it is not working as desired it is always printing the derived value.
    <?xdofx:if (xdofx:round((to_number(to_char(SYSDATE,'JSSSSS'))-to_number(to_char(to_date(DOB_DATE, 'YYYY-MM-DD'),'JSSSSS'))) div 100000)) <= 30 then '(1-30)' else '(1-100)' end if?>
    Let me know if i missed anything..
    Thanks,
    Jana

  • How do I use count for this query?

    How do I display all the addresses in a table that have more than one (or >1) account number? I wasn't sure how or if I should use count along with group by and having to get the expected results.

    select address from tablename
    group by address having count(1) > 1;

  • Can I buy final pro using a Mac in one State and then install it in other State using another Mac?

    Can I buy final cut pro x , using  my mac and then install it in other State using another Mac?

    Yes, as long as both Macs meet the system requirements for it.
    (112783)

  • Write an UPdate statement using the logic used in PL/SQL block (oracle 10g)

    Hi All,
    I have written the following PL/SQL block. I want to write an UPDATE statement using the logic used in the following PL/SQL block. can any one please help me out in this regards.
    DECLARE
       v_hoov_fag   gor_gold_post.hoov_flg%TYPE;
       v_b49n          gor_gold_post.b49n%TYPE;
       CURSOR c
       IS
          SELECT bs_id, loyalty_date, loyalty_period, contract_date
            FROM gor_gold_post
           WHERE tariff_code IN (169, 135, 136);
    BEGIN
       FOR rec IN c
       LOOP
          IF    (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                        - SYSDATE) < 304
             OR (    TRUNC (  ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                            - SYSDATE
                           ) IS NULL
                 AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2
          THEN
             v_hoov_flg := 1;
          ELSE
             v_hoover_flag := 99;
          END IF;
          IF    (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                        - SYSDATE) < 121.6
             OR (    TRUNC (  ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
                            - SYSDATE
                           ) IS NULL
                 AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2
          THEN
             v_b49n := 1;
          ELSE
             v_b49n := 99;
          END IF;
          UPDATE gor_gold_post
             SET hoov_flg = v_hoov_flg,
                 b49n = v_b49n
           WHERE bs_id = rec.bs_id AND tariff_code IN (169, 135, 136);
          COMMIT;
       END LOOP;
    END;Thank you,

    Using case statement.
    UPDATE gor_gold_post
       SET hoov_flag = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 304
                                   OR
                                   (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
                                AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
                           THEN 1
                           ELSE 99
                         END,
           b49n      = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 121.6
                             OR
                             (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
                                AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
                           THEN 1
                           ELSE 99
                         END
    WHERE tariff_code IN (169, 135, 136);Note: Code not tested.

Maybe you are looking for

  • I keep getting the endless blue circle when trying to watch netflix on my macbook pro, despite completely uninstalling/reinstalling silverlight?

    I'm putting this question in the Macbook Pro category because I'm not having this problem on a similar age Macbook Air, both of which are running Lion, so I'm wondering if its not something to do with the graphics card or something else specific to t

  • FileAdapter to JaxRpc web service, all or nothing

    I've managed to use the File Adapter to read batch files (both positional and delimited) and for each record invoke a synchronous Web Service exposed by my J2EE app to update that application with my data. Now I would like to do the same thing, but h

  • How to block ads in Mail?

    Hi guys, I seldom use Mail, but every once in a a while, it can come in handy when Thunderbird, my default client, refuses to work properly. I always create the same accounts in both apps, but there's one thing (among others) that Thunderbird has, an

  • Software Simulation Issue

    Got a weird one on a  colleague's system. When she records a software simulation or a video demo, the file saves as a single slide. The settings are as seen below for recording: All other settings are at the default parameters. Any ideas as to why sh

  • How do I setup a Guest Account on a TC that is connected to a BT Homehub?

    I am trying to create a guest account to allow friends and family to access the wifi network through my TC that is connected to a BT Homehub.   However when i try to update the setting on the TC Utilities I either keep getting a conflict with the DHC