Top 5 queries  - One of them is sequence.nextval from dual !!!!!

Hi All,
I am using ORACLE DATABASE 11g and Oracle Linux 5.
My intentions are to get the top resource consuming or time consuming queries from database in the particular time frame. I formed the below query to get the same :-
select a.SQL_FULLTEXT,
             s.module,
             s.cpu_time_total / 1000000,
             s.iowait_total / 1000000,
             s.fetches_total,
             s.sorts_total,
             s.executions_total,
             s.loads_total,
             s.disk_reads_total /
             DECODE(s.executions_total, 0, 1, s.executions_total) reads_per_execution,
             s.disk_reads_total,
             s.direct_writes_total / 1024,
             s.buffer_gets_total / 1204,
             s.rows_processed_total,
             s.elapsed_time_total / 1000000,
             s.apwait_total / 1000000,
             s.ccwait_total / 1000000,
             s.plsexec_time_total / 1000000,
             s.javexec_time_total / 1000000
        from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT h, v$sqlarea a
       where s.parsing_schema_name = 'ST'
         and s.executions_total != 0
         and s.snap_id = h.snap_id
         and a.SQL_ID = s.sql_id
         and h.begin_interval_time > '03-NOV-11 09.30.00.000 AM'
         and h.end_interval_time < ''03-NOV-11 12.30.59.999 PM'
         and rownum <= 5
       order by 15 desc;I assume that above query will give me top 5 sql or pl/sql queries which are consuming most resource or time. Please correct me if am wrong with the query.
The surprising fact is that I got the below query as the top most resource consuming query :-
SELECT REF_SEQ.NEXTVAL AS VAL FROM DUALI searched for all the code in the database and I was not able to find this line in any code. The fact is that this query should not take more than 1 second as we know that sequence nextval from dual table is very fast so, how can i get this as resource consuming query.
The output is as follows :- ( I have modified the output to show all the facts in detail. Here you can see that it shows the execution time as 10.002467 Seconds. In real this will get execute in less than a second.)
MODULE NAME := Banking
TOTAL CPU TIME := 8.299744 Seconds.
TOTAL IO WAIT TIME := .915287 Seconds.
TOTAL RECORDS FETCHED := 41128 Rows.
SORT OPERATION(S) := 0
TOTAL NO. OF EXECUTION(s) := 41128 Times.
TOTAL NO. OF TIME(S) OBJECT/QUERY LOADED/RELOADED := 5
DATA READ PER EXECUTION := .002139661544446605718731764248200739155806 KB.
TOTAL DISK READS := 88 KB.
TOTAL DISK WRITES := 0 KB.
TOTAL BUFFER READS := 4.92441860465116279069767441860465116279 KB.
TOTAL NO. OF ROW(S) PROCESSED := 41128
TOTAL EXECUTION TIME FOR ONE TRANSACTION := 10.002467 Seconds.
APPLICATION WAIT TIME := 0 Seconds.
CONCURRENCY WAIT TIME := .344575 Seconds.
PL/SQL EXECUTION TIME := 0 Seconds.
JAVA EXECUTION TIME := 0 Seconds.Please guide me for this method. How to understand the presence of this sequence.nextval query here.
The base requirement is I want a query which will give me top 5 resource/time consuming queries. I have took the help of AWR views in my logic. If you have any better idea let me know.
Thanks in advance.

Try this
select *
from
select a.SQL_FULLTEXT,
             s.module,
             s.cpu_time_total / 1000000,
             s.iowait_total / 1000000,
             s.fetches_total,
             s.sorts_total,
             s.executions_total,
             s.loads_total,
             s.disk_reads_total /
             DECODE(s.executions_total, 0, 1, s.executions_total) reads_per_execution,
             s.disk_reads_total,
             s.direct_writes_total / 1024,
             s.buffer_gets_total / 1204,
             s.rows_processed_total,
             s.elapsed_time_total / 1000000,
             s.apwait_total / 1000000,
             s.ccwait_total / 1000000,
             s.plsexec_time_total / 1000000,
             s.javexec_time_total / 1000000
        from DBA_HIST_SQLSTAT S, DBA_HIST_SNAPSHOT h, v$sqlarea a
       where s.parsing_schema_name = 'ST'
         and s.executions_total != 0
         and s.snap_id = h.snap_id
         and a.SQL_ID = s.sql_id
         and h.begin_interval_time > '03-NOV-11 09.30.00.000 AM'
         and h.end_interval_time < '03-NOV-11 12.30.59.999 PM'
         order by 15 desc
)where rownum <= 5

Similar Messages

  • Please Help me with long time oracle  select sequence.nextval from dual

    Hi
    I'm in a real problem.In fact i have a J2EE5(JPA,Hibernate 3,EJB 3.0) project deployed at websphere 6 application server and i'm using Oracle 10 g R2.
    Well i have a batch job that inserts into some table called AVERAGEBALANCE.
    the problem is that when i have activated hibernate log i discoverd that the select from dual is the longest sql (it takes some times over second !!)
    here is the log
    11/07/2011 08:49:40,406 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - insert into AVERAGEBALANCE (CDATE_, CUSER_, AVERAGEBALANCE_, AVERAGECREDITORBALANCE_, AVERAGEDEBITORBALANCE_, BEGINDATE_, CALCULATIONDATE_, CASHSUBACCOUNTCODE_, CASHSUBACCOUNTPK_, CODE_, ENDDATE_, NBCREDITORDAYS_, NBDEBITORDAYS_, TEDABCALCULATIONPERIODICITYPK_, VERSIONNUM_, PK_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
    11/07/2011 08:49:40,468 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - select this_.PK_ as PK1_465_0_, this_.CDATE_ as CDATE2_465_0_, this_.CUSER_ as CUSER3_465_0_, this_.UUSER_ as UUSER4_465_0_, this_.BALANCE_ as BALANCE5_465_0_, this_.BALANCETYPE_ as BALANCET6_465_0_, this_.CASHSUBACCOUNTPK_ as CASHSUBA8_465_0_, this_.CASHSUBACCOUNTCODE_ as CASHSUBA7_465_0_, this_.CODE_ as CODE9_465_0_, this_.CURRENCYPK_ as CURRENCYPK11_465_0_, this_.CURRENCYCODE_ as CURRENC10_465_0_, this_.ENDDATE_ as ENDDATE12_465_0_, this_.EXCHANGERATE_ as EXCHANG13_465_0_, this_.ORIGINBALANCEPK_ as ORIGINB15_465_0_, this_.ORIGINBALANCECODE_ as ORIGINB14_465_0_, this_.POSITIONDATE_ as POSITIO16_465_0_, this_.REVALUATIONDATE_ as REVALUA17_465_0_, this_.SUMOFCREDITS_ as SUMOFCR18_465_0_, this_.SUMOFDEBITS_ as SUMOFDE19_465_0_, this_.UDATE_ as UDATE20_465_0_, this_.VERSIONNUM_ as VERSIONNUM21_465_0_ from CASHAB this_ where this_.CASHSUBACCOUNTCODE_=? and this_.BALANCETYPE_=? and this_.POSITIONDATE_<? and this_.ENDDATE_>=? and this_.BALANCE_<>?
    11/07/2011 08:49:40,468 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - select AVERAGEBALANCE_.nextval from dual
    11/07/2011 08:49:41,484 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-2 - insert into AVERAGEBALANCE (CDATE_, CUSER_, AVERAGEBALANCE_, AVERAGECREDITORBALANCE_, AVERAGEDEBITORBALANCE_, BEGINDATE_, CALCULATIONDATE_, CASHSUBACCOUNTCODE_, CASHSUBACCOUNTPK_, CODE_, ENDDATE_, NBCREDITORDAYS_, NBDEBITORDAYS_, TEDABCALCULATIONPERIODICITYPK_, VERSIONNUM_, PK_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)well i have increased the sequence cache in fact here is the creation code of the sequence.
    CREATE SEQUENCE  "COMPTAPERF5"."AVERAGEBALANCE_"  MINVALUE 1 MAXVALUE 999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 400 NOORDER  NOCYCLE   ;i think that there is some oracle parameter to tune
    Thanks in advance
    Edited by: B.Mansour Nizar on 11 juil. 2011 01:04
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:33
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:34
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:34
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:35
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:35
    Edited by: B.Mansour Nizar on 11 juil. 2011 06:36
    Edited by: B.Mansour Nizar on 15 juil. 2011 07:42

    I found it.
    It's not due to oracle but it's a hibernate issue.In fact if setting FlushMode to Manual.It wil flush the in memory entities after that it will fire the insert statement.
    Here's the log.
    15/07/2011 15:32:47,984 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - select CASHAB_.nextval from dual
    15/07/2011 15:32:47,984 TRACE AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - preparing statement
    15/07/2011 15:32:47,984 DEBUG SequenceGenerator:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Sequence identifier generated: 20441
    15/07/2011 15:32:47,984 DEBUG AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    15/07/2011 15:32:47,984 TRACE AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - closing statement
    15/07/2011 15:32:47,984 DEBUG ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - aggressively releasing JDBC connection
    15/07/2011 15:32:47,984 DEBUG ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    15/07/2011 15:32:47,984 DEBUG AbstractSaveEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - generated identifier: 20441, using strategy: org.hibernate.id.SequenceHiLoGenerator
    15/07/2011 15:32:47,984 TRACE AbstractSaveEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - saving [com.bfi.cpt.bal.cas.CashAccountingBalance#20441]
    15/07/2011 15:32:47,984 TRACE Versioning:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - using initial version: 0
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - flushing session
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing flush-time cascades
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.cht.cas.CashSubAccount
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - done processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.cht.cas.CashSubAccount
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.ref.cur.Currency
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - done processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.ref.cur.Currency
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.bal.cas.CashAccountingBalance
    15/07/2011 15:32:47,984 TRACE Cascade:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - done processing cascade ACTION_PERSIST_ON_FLUSH for: com.bfi.cpt.bal.cas.CashAccountingBalance
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - dirty checking collections
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Flushing entities and processing referenced collections
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Processing unreferenced collections
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Scheduling collection removes/(re)creates/updates
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Flushed: 1 insertions, 0 updates, 0 deletions to 3 objects
    15/07/2011 15:32:47,984 DEBUG AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - listing entities:
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - com.bfi.ref.cur.Currency{translatedName=null, certain=false, iso3166=788, quotity=1, identifier=TND, creationUser=admin, internalCode=null, name=Dinars Tunisien, creationDate=2011-07-11 14:43:06, code=TND, versionNum=0, decimal=3, updateUser=null, updateDate=null, pk=136, decimalName=millimes}
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - com.bfi.cpt.bal.cas.CashAccountingBalance{cashSubAccount=com.bfi.cpt.cht.cas.CashSubAccount#400201, originBalanceCode=null, exchangeRate=null, sumOfDebits=0.0, endDate=31 décembre 9999, creationUser=bna, currencyPk=136, creationDate=2011-07-15 15:32:47, cashSubAccountCode=BNA/PCI_BNA/82-TND, code=2010-07-30/BNA/PCI_BNA/82-TND/AccountingDateBalance/TND, versionNum=0, originBalancePk=null, currency=com.bfi.ref.cur.Currency#136, updateUser=null, originBalance=null, balanceType=AccountingDateBalance, updateDate=null, positionDate=30 juillet 2010, sumOfCredits=10.0, pk=20441, cashSubAccountPk=400201, revaluationDate=null, balance=-10.0, currencyCode=TND}
    15/07/2011 15:32:47,984 DEBUG Printer:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - com.bfi.cpt.cht.cas.CashSubAccount{name2=null, accountPk=81, name=null, versionNum=0, currency=com.bfi.ref.cur.Currency#136, updateDate=null, chartByEntity=com.bfi.cpt.cht.std.ChartByEntity#2, refAccount=null, currencyCode=TND, chartByEntityCode=BNA/PCI_BNA, refAccountCode=null, creationDate=2011-07-15 15:25:45, account=com.bfi.cpt.cht.cas.StandardAccount#81, freeKey10=null, freeKey11=null, chartByEntityPk=2, freeKey12=null, updateUser=null, refAccountPk=null, freeKey13=null, freeKey14=null, freeKey15=null, freeKey16=null, freeKey17=null, accountCode=PCI_BNA/81, freeKey18=null, freeKey19=null, freeKey0=null, freeKey1=null, freeKey2=null, freeKey3=null, freeKey4=null, freeKey5=null, freeKey6=null, freeKey7=null, freeKey8=null, freeKey9=null, number=82-TND, creationUser=bna, freeKey20=null, freeKey21=null, freeKey22=null, freeKey23=null, freeKey24=null, freeKey25=null, freeKey26=null, freeKey27=null, freeKey28=null, freeKey29=null, currencyPk=136, code=BNA/PCI_BNA/82-TND, freeKey30=null, freeKey31=null, freeKey32=null, pk=400201}
    15/07/2011 15:32:47,984 TRACE AbstractFlushingEventListener:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - executing flush
    15/07/2011 15:32:47,984 TRACE ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - registering flush begin
    15/07/2011 15:32:47,984 DEBUG UpdateTimestampsCache:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Pre-invalidating space [CASHAB]
    15/07/2011 15:32:47,984 TRACE AbstractEntityPersister:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Inserting entity: [com.bfi.cpt.bal.cas.CashAccountingBalance#20441]
    15/07/2011 15:32:47,984 TRACE AbstractEntityPersister:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - Version: 0
    15/07/2011 15:32:47,984 DEBUG AbstractBatcher:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    15/07/2011 15:32:47,984 DEBUG ConnectionManager:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - opening JDBC connection
    15/07/2011 15:32:47,984 DEBUG SQL:DefaultQuartzScheduler-SimpleThreadPoolWorker-4 - insert into CASHAB (CDATE_, CUSER_, BALANCE_, BALANCETYPE_, CASHSUBACCOUNTCODE_, CASHSUBACCOUNTPK_, CODE_, CURRENCYCODE_, CURRENCYPK_, ENDDATE_, POSITIONDATE_, SUMOFCREDITS_, SUMOFDEBITS_, VERSIONNUM_, PK_) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)Edited by: B.Mansour Nizar on 15 juil. 2011 07:38
    Edited by: B.Mansour Nizar on 15 juil. 2011 07:39
    Edited by: B.Mansour Nizar on 15 juil. 2011 07:43

  • Sequence.nextval from user_sequences

    Hello All,
    I have a query,
    When i do <sequence_name>.nextval from user_sequences it is giving me 151 records...why is it giving me 151 records?
    Example:
    Step1: Created sequence test_val_seq
    CREATE SEQUENCE test_val_seq
    START WITH 1
    MAXVALUE 999999999999999999999999999
    MINVALUE 1
    NOCYCLE
    CACHE 20
    NOORDER;
    Step2: used the query Select test_val_seq.nextval from user_sequences where sequence_name='TEST_VAL_SEQ';
    and o/p is
    nextval
    1     
    2     
    3     
    4     
    5     
    6     
    7     
    8     
    9     
    10     
    11     
    12     
    13     
    14     
    15     
    16     
    17     
    18     
    19     
    20     
    21     
    22     
    23     
    24     
    25     
    26     
    27     
    28     
    29     
    30     
    31     
    32     
    33     
    34     
    35     
    36     
    37     
    38     
    39     
    40     
    41     
    42     
    43     
    44     
    45     
    46     
    47     
    48     
    49     
    50     
    51     
    52     
    53     
    54     
    55     
    56     
    57     
    58     
    59     
    60     
    61     
    62     
    63     
    64     
    65     
    66     
    67     
    68     
    69     
    70     
    71     
    72     
    73     
    74     
    75     
    76     
    77     
    78     
    79     
    80     
    81     
    82     
    83     
    84     
    85     
    86     
    87     
    88     
    89     
    90     
    91     
    92     
    93     
    94     
    95     
    96     
    97     
    98     
    99     
    100     
    101     
    102     
    103     
    104     
    105     
    106     
    107     
    108     
    109     
    110     
    111     
    112     
    113     
    114     
    115     
    116     
    117     
    118     
    119     
    120     
    121     
    122     
    123     
    124     
    125     
    126     
    127     
    128     
    129     
    130     
    131     
    132     
    133     
    134     
    135     
    136     
    137     
    138     
    139     
    140     
    141     
    142     
    143     
    144     
    145     
    146     
    147     
    148     
    149     
    150     
    151     
    Again..The question is why am i getting 151 records?

    Hi All,
    Thanks for responding..
    1. I knew that sequence_name.nextval from dual will give me the next value but to want know why seq.nextval from user_sequence gives that many rows..that is the reason why i posted this query.
    2. Yes (select sequence_name.nextval from user_sequences where sequence_name='xyz') gives the nextvalues based on number of records in the user_sequences....(tested it). Thanks bunch.

  • To access a sequence.nextval from Infobus applet

    Hi
    I have Infobus Dataform applet which displays the columns of the
    table - timesheets which has a column "line_item" which has to
    get it's value from a database sequence.
    So I followed the approach followed in the Acme - sample
    application ViewMembers.java.
    Which the row added event of the RowsetInfo -
    The following code was added with my Rowset and sequence used.
    void ACME_MEMBERSIter_rowAdded(RowChangeEvent e) throws
    java.sql.SQLException,
    javax.infobus.DuplicateColumnException,
    javax.infobus.ColumnNotFoundException,
    javax.infobus.InvalidDataException
    RowsetAccess rsa = e.getDataItem();
    DbAccess dba = rsa.getDb();
    RowsetAccess seq = null;
    seq = (RowsetAccess)dba.executeRetrieval(
    "select acme_member_id_seq.nextval as
    \"new_id\" from dual",
    "infobus:/oracle/sessionInfo1/new_id",
    null);
    ImmediateAccess nv = null;
    ImmediateAccess column_id = null;
    nv = (ImmediateAccess)seq.getColumnItem("new_id");
    column_id = (ImmediateAccess)rsa.getColumnItem
    ("MEMBER_ID");
    column_id.setValue(nv.getValueAsString());
    This does not work when I run it from Jdeveloper I have debugged
    it an umpteen times and still no clue.
    The statement
    (RowsetAccess)dba.executeRetrieval(
    "select acme_member_id_seq.nextval as
    \"new_id\" from dual",
    "infobus:/oracle/sessionInfo1/new_id",
    null);
    JUST DOES NOT WORK.
    Please help.
    Regards
    Rajs
    null

    Hi Shachar,
    When SEQUENCE_SETUP/RESETUP is called, I need to modify the arbitrary data.
    Arbitrary data can be accessed in 2 ways (as per my knowledge)
    1. GetNewStreamValue() & SetStreamValue() (for this I need AEGP_EffectRef which will be NULL for the new effect when it comes to SEQUENCE_SETUP/RESETUP).
    2. If PF_ParamDef* params is not NULL then,
         PF_Handle                arbH        = params[PARAM_ID]->u.arb_d.value;
        CG_ArbData                *arbP;
        arbP    = reinterpret_cast<CG_ArbData*>(PF_LOCK_HANDLE(arbH));
    In the first way, when SEQUENCE_SETUP/RESETUP is called AEGP_EffectRef is NULL, so I cannot use it.
    In the second way, when SEQUENCE_SETUP/RESETUP is called  PF_ParamDef* params is NULL, so I cannot use it.
    Any ideas?

  • Oracle native sequencing: nextVal executed two times.

    We are migrating from Weblogic 6.1 sp 5 & TopLink 3.6.3 to Weblogic 8.1 sp 2 & TopLink 9.0.4 and we are having this issue:
    It seems that when assigning the sequence to new objets TopLink execs the nextVal for the sequence twice. In fact we probably wouldn't notticed it if it was just that, the problem is that TopLink seems to register the object into the cache with an oid and assigning the next one to the object stored in the database so we are getting NoSuchObjectException each time we try to access them.
    Here is a dump of TopLink's log showing the problem:
    [TopLink]: ServerSession(22807116)--Connection(0)--client acquired
    [TopLink]: ClientSession(25858791)--Connection(0)--acquire unit of work: 10772417
    [TopLink]: UnitOfWork(10772417)--Connection(0)--JTS register
    [TopLink]: ServerSession(22807116)--Connection(17740413)--SELECT SEQ_BOOK.NEXTVAL FROM DUAL
    [TopLink]: ServerSession(22807116)--Connection(17558511)--SELECT SEQ_PAGE.NEXTVAL FROM DUAL
    [TopLink]: UnitOfWork(10772417)--Connection(0)--Before JTS Completion
    [TopLink]: UnitOfWork(10772417)--Connection(25919386)--Begin batch statements
    [TopLink]: UnitOfWork(10772417)--Connection(25919386)--INSERT INTO AUTHOR (NAME, OCA, OID) VALUES (?, ?, ?)
    [TopLink]: UnitOfWork(10772417)--Connection(0)-- bind => [Roger Penrose, 2004-05-11 18:54:01.917, 442803]
    [TopLink]: UnitOfWork(10772417)--Connection(25919386)--End Batch Statements
    [TopLink]: ClientSession(25858791)--Connection(25919386)--Begin batch statements
    [TopLink]: ClientSession(25858791)--Connection(25919386)--INSERT INTO BOOK (NAME, OCA, OID, OID_AUTHOR) VALUES (?, ?, ?, ?)
    [TopLink]: ClientSession(25858791)--Connection(0)-- bind => [The Emperor's New Mind, 2004-05-11 18:54:01.92, 347404, 442803]
    [TopLink]: ClientSession(25858791)--Connection(0)-- bind => [Shadows of the Mind, 2004-05-11 18:54:01.943, 347405, 442803]
    [TopLink]: ClientSession(25858791)--Connection(25919386)--End Batch Statements
    [TopLink]: UnitOfWork(10772417)--Connection(0)--After JTS Completion
    [TopLink]: UnitOfWork(10772417)--Connection(0)--release unit of work
    [TopLink]: ClientSession(25858791)--Connection(0)--client released
    [TopLink]: ServerSession(22807116)--Connection(0)--client acquired
    [TopLink]: ClientSession(116689)--Connection(0)--acquire unit of work: 32580168
    [TopLink]: UnitOfWork(32580168)--Connection(0)--JTS register
    [TopLink]: UnitOfWork(32580168)--Connection(0)--Before JTS Completion
    [TopLink]: UnitOfWork(32580168)--Connection(17129104)--Begin batch statements
    [TopLink]: UnitOfWork(32580168)--Connection(17129104)--INSERT INTO AUTHOR (NAME, OCA, OID) VALUES (?, ?, ?)
    [TopLink]: UnitOfWork(32580168)--Connection(0)-- bind => [Benoit Mandelbrot, 2004-05-11 18:54:49.264, 442805]
    [TopLink]: UnitOfWork(32580168)--Connection(17129104)--End Batch Statements
    [TopLink]: ClientSession(116689)--Connection(17129104)--Begin batch statements
    [TopLink]: ClientSession(116689)--Connection(17129104)--INSERT INTO BOOK (NAME, OCA, OID, OID_AUTHOR) VALUES (?, ?, ?, ?)
    [TopLink]: ClientSession(116689)--Connection(0)-- bind => [Les objets fractals, forme, hasard et dimension, 2004-05-11 18:54:49.266, 347409, 442805]
    [TopLink]: ClientSession(116689)--Connection(0)-- bind => [The Fractal Geometry of Nature, 2004-05-11 18:54:49.282, 347408, 442805]
    [TopLink]: ClientSession(116689)--Connection(17129104)--End Batch Statements
    [TopLink]: UnitOfWork(32580168)--Connection(0)--After JTS Completion
    [TopLink]: UnitOfWork(32580168)--Connection(0)--release unit of work
    [TopLink]: ClientSession(116689)--Connection(0)--client released
    the test is about creating two objects (well, we are actually creating 6 objects in this sample as we are creating two "master" objects and adding two related (in a one to many relationship) objects to each one.)
    The thing I would like you to notice is this:
    The first AUTHOR object gets assigned the OID 442803 wether the next AUTHOR object gets the OID 442805 although we expected it to be 442804.
    The same occurs with the objects in the "many" side of the relation. They get sibiling OIDs but with a gap of two OIDs when creating the last two.
    I have been searching for simmilar problems in this forums and I found two posts:
    Both where related to a bug of an older version of TopLink (9.0.3 I think) when using something different than a number for the sequence field of an object. I expect it to be fixed in 9.0.4 version as it seemed to be fixed even for the 9.0.3 version. May it be a regression bug?
    Anyway, we are using BigDecimal on entity bean's sequence number and IIRC NUMBER(18) in Oracle tables.
    Currently our TopLink version is: 9.0.4 (031126)
    Our native sequence has an allocation size of 200 and it matches with SEQUENCEs defined in Oracle.
    As we are migratting from TopLink 3.6.3 and we have not changed the sequence prealocation size (we have not touched the database at all) we don't expect the problem to be on sequence prealocation.
    I must say we have changed the "default" JDBC driver that TopLink uses when doing the issuing the loging phase (which I think is a SUN driver) to an oracle.jdbc.driver.OracleDriver as we were having problems with timestamp locking.
    Any idea?
    Thanks in advance.
    Ignacio.

    Solved!
    It was my fault. I was doing a really nasty thing to the entity beans.
    I must publicly thank my work mate (which is a pretty smart girl, I must say) in tracking down this issue.
    Here is what (we think) was happening:
    As I told in previous post in this post we are in the process of moving from TopLink 3.6.3 (EJB 1.1) to TopLink 9.0.4 (EJB 2.0). We do have a "super class" in our application where we had some common things of our entity beans, i.e. entityContext, oid and oca attributes. We have also some methods that retrieve and set values from and to the entity beans via value objects (in order to avoid the heavy RMI operations when doing it through "standard" getters and setters) well, it happened that the current implementation of the "batch setting" method used the getDeclaringMethods to update in both UPDATE and INSERT opperations entity attributes with the data of the value object.
    When switching to EJB 2.0 we had to push down both the oid and oca attributes (in order of being able do deploy them) to each final entity bean and now they where being included in the setting process!
    You can imagine an scenario like this:
    1. ejbCreate() // TopLink issues the SELECT SEQ_XXX NEXT VAL FROM DUAL and sets the oid of the EJB
    2. setAttributes() // transfer info from the value object to the newly created EJB: including a setOid(null)!
    3. commit() (Before Completion)
    4. TopLink detects that the damm object surprisingly DOES NOT have the oid attribute setted so it performs another SELECT SEQ_XXX NEXT VAL FROM DUAL in order to "fix" this big problem.
    5. commit() (After Completion) // the object is written to the database with the second value from the sequence whereas the first value is used to identify the entity bean into the identity cache.
    Well it may not be "exactly" what is happening but I'm sure we are not so far from reality with our assumptions.
    Andrei Ilitchev, thanks for your interest, sorry I could not post this sooner.

  • Sequence.nextval doubles the returned value with Execute Statement (F9)

    There appears to be a quirk with sequences in Raptor.
    Has anyone noticed that depending on how you execute this sql (SELECT MYSEQ.NEXTVAL FROM DUAL;) the value returned is either the correct nextval or double what you expected?
    For example, MYSEQ is a simple sequence which increments by 1. If you Execute Statement (F9) then the value returned jumps by 2 instead of 1. If you Run Script (F5) then the value returns jumps by 1, as expected.
    If MYSEQ is changed to increment by 2. The when you Execute Statement (F9) then the value returned jumps by 4 instead of 2. If you Run Script (F5) then the value returns jumps by 2, as expected. No matter what you put for the increment by Execute Statement (F9) always doubles it.
    It always seems to be double. Executing the same scenario in TOAD always returns the correct value (i.e. properly increments).
    Is the query being executed multiple times with Execute Statement? Why is this happening?

    While there is no guarantee from Oracle that sequences produce sequential numbers, this is obviously a case where SQL Developer is running the select statement twice.
    The issue is that queries can actually change information, rather than just retrieve data from the database.
    The following package is a test case:
    create or replace package test_query is
    function get_next_count return number;
    end;
    create or replace package body test_query is
    cnt number := 0;
    function get_next_count return number is
    begin
    cnt := cnt + 1;
    return cnt;
    end;
    end;
    select test_query.get_next_count from dual;
    This query, which should return 1, 2, 3, 4, etc actually returns 2, 4, 6, 8, etc, because SQL Developer is running the select twice.

  • How to get the sequence value from the database

    Hi
    I created one sequence in the database.
    Then I want to take the current value or nextvalue of the sequence in a java program.
    How can i do this?
    can anybody please explain me?
    Thank you so much.

    Here you go ...
    Connection conn = null;
    PreparedStatement prepStmt = null;
    ResultSet rs  = null;
    int seqNo = 0;
    try {
         conn = dbConn.getConnection(); //manage your connection here
         String strSQL = "SELECT SEQ_NAME.NEXTVAL FROM DUAL";
         prepStmt = conn.prepareStatement(strSQL);
         rs = prepStmt.executeQuery();
         if(rs.next())
              seqNo = rs.getInt(1);
    catch (SQLException e)
    ...-Rohit

  • Nextval from trigger without using DUAL

    Hi everyone,
    It is possible to obtain the nextval of a sequence from a trigger without using DUAL?
    I have a table (TABLE1) with column ID NUMBER(10).
    I have a sequence (SEQ1)
    I need a trigger on before insert TABLE1 and I need obtain the nexval of the sequence BUT I CAN NOT use DUAL (it is forbbiden in my project. Don't ask :((( )
    can you help me?
    thanx a lot!

    "So of course using select seq.nextval from dual is
    most of the time unnecessary thing and should be
    banned as much as possible, but I think that simple
    prohibition is quite stupid."
    why do you think using dual ist most of the time
    unnecessary?Because in most scenarious you won't need dual.
    What are the reasons for using dual?
    1) because you need the value later in some other computations. The most elegant, simple and performant solution is just use returning clause of the insert statement.
    2) because the value is not provided. As I'm usually using more or less logic in DB or at least some business logic API (as pl/sql packages/procs) I'm always inserting new rows using sequence.nextval in the very insert statement so absolutely no need for before insert trigger supplying id value.
    If you think that select sysdate/sequence.nextval and similar things are very cheap then it is not true :)
    I've seen some batch procedures processing many rows and for each row:
    1) get sequence.nextval into variable from dual
    2) insert row using variable in id
    And select seq.nextval from dual took more tha 10% of overall time.
    Ok just a simple test case on 9i
    declare
    val number;
    begin
      for i in 1..10000 loop
        select seq1.nextval into val from dual;
        insert into seq2 values (val);
      end loop;
    end;dbms_profiler shows that total time for select into was ~982 msec but insert just took 722 msec. So actual insert took less than select from dual! The overall time was 1.922 secs.
    OK now let's see how it is with following script:
    declare
    val number;
    begin
      for i in 1..10000 loop
        insert into seq2 values (seq1.nextval) returning a into val;
      end loop;
    end;insert row took 931 msec and overall time was 1.094 secs.
    So this is for batch. For OLTP like app the only difference is that resource waste is spread out for many transactions but the overall net result is the same - you are inefficiently wasting resources.
    Ok in 10g results will be better with fast dual, but select anything from dual is very bad habit especially if used extensively.
    Gints Plivna
    http://www.gplivna.eu

  • I use Yahoo Calendar on my IPhone.  For whatever reason when I go into my calendar I will see at the top of the screen that 5 or 6 "calendars" are being used and one of them is the one I called Dana_Gardner and is legitimate, the others are randomly named

    I use Yahoo Calendar on my IPhone.  For whatever reason when I go into my calendar I will see at the top of the screen that 5 or 6 "calendars" are being used and one of them is the one I called Dana_Gardner and is legitimate, the others are randomly named with letters and numbers. Why is the IPhone creating additional "calendars"? I only asked for one to be set-up. I don't understand, I have to go into the calendar settings daily and uncheck these un-asked for calendars. Help!

    Mine is doing the same thing.  I deleted the whole account from the mail settings and it got rid of most of the extra calendars.  But there are still 2 gibberish ones left.

  • On my dashboard I have an icon with this @ on top.  One is for facebook and one is for Pinterest.  Can I rename them?

    On my dashboard, I have two icons with this @ on top.  One is for facebook and one is for Pinterest.  I would like to rename them or put the FB symbol something so they are easier to identify.  Is this possible?

    Tap the rectangle over the 2 lines and make sure it no longer shows up in red. At this point, you should have only the month view, no daily appointments below. Now press on a specific day, and this will either:
    1. Take you into the daily view with the hourly breakdown. If this is the case, tap the three horizontal lines at the top to get the list.
    2. Take you directly to the list view

  • This is a tough one!  Problem with sequence settings....

    OK...where to begin!
    Here is some background (I have posted many questions about these issues and have resolved most of them, except this project)
    1.Recently upgraded to 6.0.1
    2. 'lost' my scratch disc (ok, I accidently deleted it)
    3. All projects are OK to do without, except this one!
    4. The footage for this project was from 2 cameras: one is DV and one is HD. The HD footage was downgraded to DV during capture from camera for the original project. Now, with 6.0.1, I bring it in HD and mix the footage on the same timeline with the DV (which is so cool and so much easier for me!) But I wanted to make sure and do the same thing I did for the original clips on this project, so when I just batch captured all the clips, I brought the HD in as DV. Both were shot wide screen.
    This one sequence is 6 minutes long and I COULD recreate it, but it is very detailed and has a lot of filters, edits, etc. Here is the problem:
    I did a batch capture on all the clips and successfully got all the clips back and the timeline plays, but the two different "cameras" footage looks different in the canvas: (the sequence settings are frame size: ntsc dv 3:2, pixel aspect ratio ntsc-ccir601/dv and anormorphic is checked)
    The HD footage, downgraded to DV, looks fine
    The DV footage is stretched, and has a bar on the top and bottom.
    I have played around with the sequence settings and these are the best results i can get.
    Now I made a new sequence with same settings as above and i dragged a couple different clips from the browser into the timeline and they are fine... (these clips are the same ones in the problem sequence that look stretched)
    Any ideas??
    Thanks in advance!!

    I understood that the sequence looked at the first stuff dropped into it for behavior. If you dropped the problem material from the first sequence into the second sequence you created prior to dropping any thing else in then it will behave as you would expect. if you dropped footage that wasn't formatted the same as your sequence settings you get the "...would you like to ..." and the sequence settings get changed. I avoid this because some of the changes applied don't allow my Kona to playout.

  • Why does mountain lion "bunch up" all my microsoft office documents that I have open when I hit f3? When I had snow leopard for example, if i had 4 or 5 different microsoft office documents open at the same time I could hit f3 and easily pick one of them

    Why does mountain lion "bunch up" all my microsoft office documents that I have open when I hit f3? When I had snow leopard for example, if i had 4 or 5 different microsoft office documents open at the same time I could hit f3 and easily pick one of them.
    Notice how in the photo, I can't identify which MS office document I would like to switch too. Perhaps since the Dashboard and Desktop windows are at the top of my screen now Apple doesn't let you have all the applications take up the full screen and be sized individually so that you can have a better idea on what to pick.
    I like the idea of grouping to an extent... If you have a bunch of random things it was hard for me to decifer between what was safari, chrome, or word. But now that they grouped them like this, if you have multiple pages of one program running, you can't switch between those pages easily like before.

    If I wanted to open any of my Applework documents I had to open them one at a time and resave them with pages. This could take weeks.I have 1000s of apple work documents.
    You don't have to open and re-save every AppleWorks document you have right now. Just wait till you need one, then do it. The documents aren't going anywhere.
    Am I dealing with Microsoft? This was a BIG surprise to me that Apple would release an OS without testing all programs.
    Frankly, it is not Apple's responsibility to ensure compatibiltiy with every piece of software available for OS X. That is the responsibility of the software vendor. Lion has been available to developers for several months before it's release, so Microtek had plenty of time to update their software. Yet they did not. How is that Apple's fault? I think Apple was very generous to give you a refund for Lion.
    I'm not trying to belittle your frustration but I do think your ire is misplaced.

  • I can't print my playlist properly. The words are coming out on top of one another

    I can't print my playlist properly all of a sudden. The words come out on top of one anther.

    We can't access a saved screenshot that is on your computer.<br />
    You need to upload the image to attach it.
    If you have increased the minimum font size then try the default setting "none" as a high value can cause such issues.
    *Firefox > Preferences > Content : Fonts & Colors > Advanced > Minimum Font Size (none)
    Make sure that you allow websites to choose their fonts.
    *Firefox > Preferences > Content : Fonts & Colors > Advanced > [X] "Allow pages to choose their own fonts, instead of my selections above"
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode
    Create a new profile as a test to check if your current profile is causing the problems.
    See "Basic Troubleshooting: Make a new profile":
    *https://support.mozilla.com/kb/Basic+Troubleshooting#w_8-make-a-new-profile
    If that new profile works then you can transfer some files from the old profile to that new profile, but be careful not to copy corrupted files.
    See:
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • Sequence, nextval

    Hello,
    i'm writing an application, that has to have process unique index. I think of db-sequences for to create them. So i use jdbc and sql to retrieve the next value from the sequence.
    i do that by sequenceName.nextVal
    I wonder how to form the valid sql statement to retrieve the netx index of the sequence. Things like 'SELECT SQ_JOBNOS.nextval' caause oracle exceptions.
    do i have to create a temporary table?
    thanks a lot,
    best regards,
    nigoooh

    SELECT SQ_JOBNOS.nextval FROM dual

  • I have 2 accessible certificates (2 bank account holders) How to choose one of them?

    The same computer is used for access to accounts for two different holders but in the same bank. Each has an own certificate. After choise of one of them it is not possible to switch to the other without restart Mozilla.
    == This happened ==
    Every time Firefox opened

    Try Tools > Options > Advanced > Encryption: Certificates : "When a web site requires a certificate": "Ask me every time"
    You can also try top clear the "Active logins" in the Tools > [[Clear Recent History]]

Maybe you are looking for

  • Itunes stops working after itunes match runs.

    After I open Itunes and it does the Itunes Match it stops working. I have the most recent version, I have ran all the diagnostics I can on my end. Any clues? Extremely frustrated right now.

  • I need a code to be able to save my form to excel with a save button????

    This is the codes very simple right now but i can not get a code or understanding of what to put for the import part or Dim file path. The excel sheet i have saved in C:\connecttoexcel\ but do have the exact code needed. Public Class Mesquite     Pri

  • What's the printing difference in Acrobats 8 and 9 Pro?

    I have a PDF, actually I have seen quite a number, that when sent to one of our Canon printers--4080i or 2550--from Acrobat 8 Pro will not print. Nothing comes out. (Actually 1 the printer shows that it received one page--the document had more than o

  • Change of Device Category of a Device

    Hi Can anyone help me about the convenient process so that device category of device can be changed. Actually, my requirement is as follows: 1. User creates a device E1 (External number range) under device category D1. Equipment and serial number are

  • Exception during event processing

    I have an application which has an "exception catcher" at the bottom that performs some "exit work" that I need done when the program terminates abnormally. In certain places of the program, I automatically have the program quit and exit by dividing