Sequence of values..

hi.. i have a querry.. pls help me out..
i have a coulmn which has all unique ids(eg col A)
i also have a column which has time(eg Col B time=23:59:59)
Now for instance, if there are 20 records in column A, i want the count of time to be reduced by 1 sec for every entry in column A
Eg value 1 in col A time=>23:59:59
value 2 in col A time=>23:59:58.... and soo on.....
i want the time to be reduced by one second for every value in col A
I tried using loops but its taking lot of time...
Someone help me out without using loops

Hi,
Please read SQL and PL/SQL FAQ
Please post details or your table. Which data type is the column having time?
Additionally when you put some code or output please enclose it between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
Regards.
Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Sql Developer 1.5.5 bug with large sequence start values.

    We have a small table in our sql server 2005 schema (~700) rows. Its primary key is a bigint. We randomly generate ids for this table (don't ask). We have ids for this table which are larger than 2147483647. (java.lang.Integer.MAX_VALUE). I'm using a Windows 10g instance as the repository:
    SQL> select * from v$version
    2 ;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Capturing this model works fine.
    Converting this model works fine.
    When the converted model is "Generated", Sql Developer stops generating the script before the worksheet window is opened with the generated sql. If run from sqldeveloper/bin, this exception is output to the console:
    java.lang.Exception: java.util.NoSuchElementException
    at oracle.dbtools.migration.workbench.core.ui.AbstractMigrationProgressRunnable.start(AbstractMigrationProgressRunnable.java:141)
    at oracle.dbtools.migration.workbench.core.GenerateInitiator.launch(GenerateInitiator.java:42)
    at oracle.dbtools.raptor.controls.sqldialog.ObjectActionController.handleEvent(ObjectActionController.java:149)
    at oracle.ide.controller.IdeAction.performAction(IdeAction.java:524)
    at oracle.ide.controller.IdeAction.actionPerformedImpl(IdeAction.java:855)
    at oracle.ide.controller.IdeAction.actionPerformed(IdeAction.java:496)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
    at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1225)
    at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1266)
    at java.awt.Component.processMouseEvent(Component.java:6134)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
    at java.awt.Component.processEvent(Component.java:5899)
    at java.awt.Container.processEvent(Container.java:2023)
    at java.awt.Component.dispatchEventImpl(Component.java:4501)
    at java.awt.Container.dispatchEventImpl(Container.java:2081)
    at java.awt.Component.dispatchEvent(Component.java:4331)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4301)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3965)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3895)
    at java.awt.Container.dispatchEventImpl(Container.java:2067)
    at java.awt.Window.dispatchEventImpl(Window.java:2458)
    at java.awt.Component.dispatchEvent(Component.java:4331)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Caused by: java.util.NoSuchElementException
    at oracle.dbtools.metadata.persistence.PersistableObjectIterator.next(PersistableObjectIterator.java:131)
    at oracle.dbtools.migration.generate.GenerateWorker.generateSequences(GenerateWorker.java:862)
    at oracle.dbtools.migration.generate.GenerateWorker.generateIndividualSchema(GenerateWorker.java:456)
    at oracle.dbtools.migration.generate.GenerateWorker.generateSchema(GenerateWorker.java:365)
    at oracle.dbtools.migration.generate.GenerateWorker.runGenerate(GenerateWorker.java:220)
    at oracle.dbtools.migration.workbench.core.ui.GenerateRunner.doWork(GenerateRunner.java:71)
    at oracle.dbtools.migration.workbench.core.ui.AbstractMigrationProgressRunnable.run(AbstractMigrationProgressRunnable.java:161)
    at oracle.dbtools.migration.workbench.core.ui.MigrationProgressBar.run(MigrationProgressBar.java:569)
    at java.lang.Thread.run(Thread.java:619)
    A problem row can be viewed by issuing this query against the repository:
    select * from md_sequences where seq_start > 2147483647;
    We have one row returned. The oracle.dbtools.metadata.persistence.MdSequence class uses a java.lang.Integer value to store the start value for the sequence. The value stored in the repository's MD_SEQUENCE table overflows the Integer type.
    Updating the SEQ_START column in the MD_SEQUENCE table fixed our problem. (Well, I can now generate the schema. I may have other problems with the sequence being off).
    I've written this post to save someone else the day it took me to diagnose this problem with Sql Developer 1.5.5. At the very least Sql Developer should inform the user that it could not generate the script because of the large sequence start value. It basically swallows any error and terminates script generation without any type of feedback.

    Update: I was able to recreate the problem!
    1. Create a new table (I used TEST).
    2. Mark first column af primary key.
    3. Save the table.
    Notice the name of the primary key index created: (TEST_PK in my case)
    4. Edit the table.
    5. Under constraints change the name of the primary key constraint.
    6. Save the table.
    Notice that the index still has its original name.
    7. Edit the table.
    8. Change something.
    9. Attempt to save changes (Fails).
    Conclusion:
    Either SQL Developer should be aware of indexes with different name than a constraint,
    or when SQL Developer changes the name of a constraint with an index, both the constraint and the index should be renamed.

  • Error in SMW01:Allocation of the tax for country RO, sequence 1, value 0 no

    Hi,
    when materials are replicated we found a queue existing in SMQ1 and SMQ2.
    When i have checked in SMW01 for the Log it showed me the error "Allocation of the tax for country RO, sequence 1, value 0 not possible"
    Then i clicked on Show BDoc Message Ext.data It showed around 20 materials.I ahve checked the material in R3 there is no sales view for this material type itself.
    i tried to replicate one of those material manually then it is replicated.
    Can anyone guide me why system showed "Allocation of the tax for country RO, sequence 1, value 0 not possible" this message even there is no problem with material?
    Is there any Trasaction to find the exact material which is creating problem?
    kindly suggest me few points on this how to solve this kind of error in future
    regards
    subbu

    Hello Subbu,
    There is a txn:CRM_TAXCUST_VALIDATE which would help you to figure out any issues with Tax customizing.
    Please exceute this txn and you would come to know the list of erroneous tax customizing.
    Also,
    in CRM table CRMC_TAX_MAP for country RO,check whether any  records have been                
    maintained for Access Sequence (i.e LFDNR) 1.
                                                                                    Please check the following customization in txn:SPRO.                                                                               
    CRM->Basic Functions->Taxes->Basic Settings->Tax Types and Tax Groups->            
    Assign Tax Groups to SAP ECC Tax Classifications (Product).                                                                               
    For example: If there are entries for Country RO for sequence 1 and                
    value 0 there must also be correpsonding  entries in R/3 table MLAN and            
    vice versa.                                                                               
    Also,I kindly advice you to go through the documentaion of                         
    "Assign Tax Groups to SAP ECC Tax Classifications (Product)" in CRM,               
    which is present in the above mentioned SPRO navigation.                                                                               
    Also,                                                                               
    *If you are not sure about the sequence of the taxes, you can check it             
    in SAP ECC, in Customizing for Sales and Distribution (SD), by choosing            
    Basic Functions -> Taxes -> Define Tax Determination Rules.                                                                               
    Hope this helps!
    Best Regards,
    Shanthala Kudva.

  • Initialize sub sequence column values on insert?

    I asked this on stack overflow, but it was recommended that I also ask here.
    http://stackoverflow.com/questions/12982875/initialize-sub-sequence-column-values-on-insert-oracle
    I would like my table to sequence its "order by" column based on it's TEMPLATE_ID. I would like this to happen on insert (via an insert trigger, probably). For example, if I run the following inserts, I should get the following table values.
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (1, 1)
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (2, 1)
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (3, 1)
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (4, 2)
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (5, 2)
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (6, 2)
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (7, 2)
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (8, 3)
    ID TEMPLATE_ID ORDER_BY
    1           1        1
    2           1        2
    3           1        3
    4           2        1
    5           2        2
    6           2        3
    7           2        4
    8           3        1I first tried to create this trigger, but it gives me an error when I insert.
    create or replace
    trigger TEMPLATE_ATTRIBUTES_AF_INS_TRIG
       after insert on TEMPLATE_ATTRIBUTES
       for each row
    begin
        if :NEW.ORDER_BY is null then
           update TEMPLATE_ATTRIBUTES
           set ORDER_BY = (select coalesce(MAX(ta.ORDER_BY), 0) + 1 from TEMPLATE_ATTRIBUTES ta where ta.TEMPLATE_ID = :NEW.TEMPLATE_ID)
           where ID = :NEW.ID;
        end if;
    end;The error it gives me is: "table TEMPLATE_ATTRIBUTES is mutating, trigger/function may not see it"
    So I need a different way to build this trigger. And I also need it to "thread safe" so that if these two inserts occur on different sessions at the same time, then the resulting records will still get different "ORDER_BY" values:
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (1, 1)
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (2, 1)
    Edit:
    I tried the common work around for the "table is mutating, trigger/function may not see it" and the work around "worked" but it was not "thread safe." I tried to add locking but it gave me another error on insert
    create or replace package state_pkg
    as
      type ridArray is table of rowid index by binary_integer;
      newRows ridArray;
      empty   ridArray;
    end;
    create or replace trigger TEMPLATE_ATTRIBUTES_ORDER_BY_TB4
    before insert on TEMPLATE_ATTRIBUTES
    begin
      state_pkg.newRows := state_pkg.empty;
    end;
    create or replace trigger TEMPLATE_ATTRIBUTES_ORDER_BY_TAF1
    after insert on TEMPLATE_ATTRIBUTES for each row
    begin
      if :NEW.ORDER_BY is null then
        state_pkg.newRows( state_pkg.newRows.count+1 ) := :new.rowid;
      end if;
    end;
    create or replace trigger TEMPLATE_ATTRIBUTES_ORDER_BY_TAF2
    after insert on TEMPLATE_ATTRIBUTES
    declare
      v_request     number;
      v_lockhandle varchar2(200);
    begin
      dbms_lock.allocate_unique('TEMPLATE_ATTRIBUTES_ORDER_BY_lock', v_lockhandle);
      while v_request <> 0 loop
        v_request:= dbms_lock.request(v_lockhandle, dbms_lock.x_mode);
      end loop;
      begin
        for i in 1 .. state_pkg.newRows.count loop
          update TEMPLATE_ATTRIBUTES
          set ORDER_BY = (select coalesce(MAX(q.ORDER_BY), 0) + 1 from TEMPLATE_ATTRIBUTES q where q.TEMPLATE_ID = (select q2.TEMPLATE_ID from TEMPLATE_ATTRIBUTES q2 where q2.rowid = state_pkg.newRows(i)))
          where rowid = state_pkg.newRows(i);
        end loop;
        v_request:= dbms_lock.release(v_lockhandle);
      EXCEPTION WHEN OTHERS THEN
        v_request:= dbms_lock.release(v_lockhandle);
        raise;
      end;
    end;This gives me:
    ORA-04092: cannot COMMIT in a trigger ORA-06512: at "SYS.DBMS_LOCK", line 250 ORA-06512: at "TEMPLATE_ATTRIBUTES_ORDER_BY_TAF2", line 5 ORA-04088: error during execution of trigger 'TEMPLATE_ATTRIBUTES_ORDER_BY_TAF2' ORA-06512
    Edit 2: The ORDER_BY column must be an updateable column. ID actually uses a sequence and before insert trigger to set its values. I thought I was simplifying my question when I included it in the insert examples, but that was incorrect. ORDER_BY's initial value is not really related to ID, but rather to what order the records are inserted. But ID is sequenced so you can use that if it helps.

    Check here below:
    create table TEMPLATE_ATTRIBUTES
    ( ID           INTEGER
    , TEMPLATE_ID  INTEGER
    , ORDER_BY     INTEGER
    CREATE OR REPLACE TRIGGER templ_attr_bf_ins_trg
       BEFORE INSERT
       ON template_attributes
       FOR EACH ROW
    BEGIN
       IF :new.order_by IS NULL
       THEN
          SELECT NVL (MAX (ta.order_by), 0) + 1
            INTO :new.order_by
            FROM template_attributes ta
           WHERE ta.template_id = :new.template_id;
       END IF;
    END;
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (1, 1);
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (2, 1);
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (3, 1);
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (4, 2);
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (5, 2);
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (6, 2);
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (7, 2);
    INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (8, 3);
    SELECT * FROM TEMPLATE_ATTRIBUTES;
    Output:
            ID TEMPLATE_ID   ORDER_BY
             1           1          1
             2           1          2
             3           1          3
             4           2          1
             5           2          2
             6           2          3
             7           2          4
             8           3          1
    {code}
    Let me also comment that I don't like this solution. It might conflict with multiuser access.
    If you just need the column to order the table you can use a sequence and then order you table by template_id, order_by (generated by a sequence).
    In this way you will not have a problem with multiuser access. Do you care that order_by column is not starting from 1 for each template_id and it has "holes" in the sequence for that template_id?
    Regards.
    Al
    Edited by: Alberto Faenza on Oct 22, 2012 5:11 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Best way to get sequence.next value in pl-sql/triggers

    Hi,
    I want to know the best practice about to get the sequence.next value in pl-sql procedures / triggers from the below two methods.
    1. SELECT PRINT_BATCH_SEQ.NextVal INTO PSQNO FROM DUAL;
    INSERT INTO TABLE R1TMP VALUES (PSQNO, '12-MAR-06');
    2. INSERT INTO TABLE R1TMP VALUES (PRINT_BATCH_SEQ.NextVal, '12-MAR-06');
    From the above two statements which one is best with respect to performance / parsing /memory usage.
    Kindly give your suggession please.
    Thanks,
    Riaz.

    Hi,
    Thanks for your immediate reply.
    My thought was
    1. when we do like this, at the time of insert the cost of the operation will be more and this will lead some performance issue as bulk insert.
    2. If we get it from dual and send the value as bind variable, then we can avoid the parsing of the sql.
    Please correct me if i am wrong.
    thanks,
    riaz.

  • Sequence next value into a VIEW

    Hi all,
    I am getting this error when i try to include sequence value in aview....
    please suggest where i am doing wrong or if there is any work around...
    CODE
    CREATE OR REPLACE FORCE VIEW XREF_DATA_PRODUCT_V_2
    XREF_COLUMN_NAME,
    VALUE,
    ROWID_1
    AS
    SELECT 'SEBL_01', A.sebl_01, ROWID
    FROM XREF_GOMS_STG A
    UNION
    SELECT CASE
    WHEN C.SOMS_01 = 'Engine Parts' THEN 'GOMS_01'
    ELSE 'SOMS_01'
    END,
    c.goms_01,
    ROWID
    FROM XREF_GOMS_STG C
    union
    select 'COMMON',odipocsrc.xref_data_sequence.nextval,rowid
    from ODIPOCSRC.XREF_GOMS_STG B
    ORDER BY 3;
    Thanks

    Hi,
    Why do you want to use a sequnce there? What are you trying to do? Would numbers generated by the analytic ROW_NUMBER function serve your purpose?
    Assuming you really need a sequence, you can hide the sequence in a user-defined function, and use the function in the view, like this:
    CREATE OR REPLACE FUNCTION     seq_x_nextval
    RETURN     PLS_INTEGER
    IS
         return_val      PLS_INTEGER;
    BEGIN
         SELECT     seq_x.NEXTVAL
         INTO     return_val
         FROM     dual;
         RETURN     return_val;
    END     seq_x_nextval;
    CREATE OR REPLACE VIEW     view_x
    AS
    SELECT     danme
    ,     seq_x_nextval     AS seq_val
    FROM     scott.dept;
    SELECT     *
    FROM     view_x;Output, when running the query above:
    DNAME             SEQ_VAL
    ACCOUNTING             52
    RESEARCH               53
    SALES                  54
    OPERATIONS             55Then, running the same query again:
    DNAME             SEQ_VAL
    ACCOUNTING             56
    RESEARCH               57
    SALES                  58
    OPERATIONS             59Edited by: Frank Kulash on Feb 15, 2010 7:42 PM

  • How to get sequence value?

    hi,
    i'm trying to store sequence's value into a variable... smth like this:
    create or replace function my_funct() as integer
    is
    begin
    return my_sequence.currval;
    end;
    and "return my_sequence.currvalue" doesn't seem to work...
    also i'would like to store that value into a variable, like:
    is
    i integer;
    begin
    i := my_sequence.currval;
    end;
    this also doesn't seem to work
    regards

    Hi,
    You will using this method to store sequence value to variable
    declare
    i number;
    begin
    select sq.currval into i from dual;
    dbms_output.put_line(i);
    end;
    Anbudan,
    Radha.

  • Transaction.getSequenceValue() doesnt gives values in sequence.

    Hi All,
    I am using OADBTransaction getSequenceValue to get the next value of my sequence. This is the only line in my java code where i reffer to the database sequence.
    My sequence creation script is like this
    PROMPT Dropping Synonym apps.xxcust_fd_id_seq;
    DROP SYNONYM apps.xxcust_fd_id_seq;
    PROMPT Dropping SEQUENCE XXCUST.xxcust_fd_id_seq;
    DROP SEQUENCE XXCUST.xxcust_fd_id_seq;
    CREATE SEQUENCE XXCUST.xxcust_fd_id_seq
    INCREMENT BY 1
    START WITH 1
    MAXVALUE 9999999999
    MINVALUE 1
    NOCYCLE;
    PROMPT Creating Synonym apps.xxcust_fd_id_seq;
    CREATE SYNONYM apps.xxcust_fd_id_seq
    FOR xxcust.xxcust_fd_id_seq;
    The sequence gives values like 1,2,3,4,5,6,7,8,9,10,11,12,21,41
    Has anybody faced this issue ?
    If so whats the solution ?
    Thanks in advance,
    Anant Nimbalkar.

    Hi Anant,
    If you complaining about the missing numbers from the sequence that your code returns (or) rather inserts into the table. You might want to have a breakpoint in the code that you've posted, to see when all its called.
    I suspect its called multiple times before the value is being inserted into the table. So thatz the reason why the values are bumped up.

  • Variable value is not getting set in BEx / WAD

    Hi,
    We have a WAD report where we have selection on Comp Code which is restricted to a variable Var1. In the same WAD, a button group is used to execute a Planning Sequence, it has a filter for Comp Code which is restricted to a mandatory variable Var2.
    Idea is unless the user selects a value for Comp Code in WAD selection screen(Var1), the button group to execute the Planning Sequence will not be visible. When this button group is visible and user clicks to execute the Planning Sequence, the value for Var2 is supposed to get the same value as Var1 since in the underlying BEx query of WAD, we have restricted Comp Code InfoObject with Var1 in Default Values region.
    This was working absolutely fine in BW 7.3. But recently we upgraded to BW 7.4 and now the value for Var2 is not getting set if user selects the value for Var1.
    Appreciate any help on this.
    Note: The issue will resolve if we use the same variable in BEx query as well as the Planning Sequence, but this is not feasible in our case.
    Thanks and Regards,
    Shravan Marathe

    Hi Suman,
    As the issue came up with the latest BW 7.4 upgrade, we are looking for a work around may be implementation of Notes instead of going for an alternative.
    Thanks and Regards,
    Shravan Marathe

  • Error while inserting record in Key-Flex Values Set interface

    Guys
    on 11.5.10.2
    Actually the problem is being occurred while inserting value in Job Flex Field Value set, we have created two segment for job key flex filed, No and name, it was working fine, but since we have uploaded bulk data via api "fnd_flex_values_pkg.INSERT_ROW" which was around 100 off record, but after completion this task system is not taking new value by Values set interface, and show message "APPS-FND-01206: You entered duplicate values or sequence of value that must be unique for every record",
    However, we insert the job number through api, it is inserting without error while
    Interface is not taking value and raise duplicate message error,
    which is APPS-FND-01206
    Please Advice.

    Thanks for supporting dunacan
    I have mentioned both of segment detail . please advice,
    1.One is Job No segment
    Segment1 number 10
    Required Check Yes
    Value set Info JOB_NO
    List Type : List of Values
    Security Type : No Security
    Format Validation : select number 7,0 and check on number only (0-9)
    Validation Type Independent
    2.One is Job Name segment
    Segment2 number 20
    Required Check Yes
    Value set Info JOB_NAME
    List Type : List of Values
    Security Type : No Security
    Format Validation : select CHAR 60 Validation Type Independent
    It was strange that how could it possible duplication value without having database,i am unable to find this issued,
    Edited by: oracle0282 on Jan 17, 2011 3:32 AM

  • Daily sequence number

    Hi,
    I need a clean solution for a daily sequence number (starts from 1 everyday). Clean in the sense that upon initial setup, I do not have to do anything and I can get my number everyday by just one jdbc call/query.
    Thank you in advance.

    What is the business justification for this requirement? Normally, you should just use a regular non-resetting sequence. If users want to see a "pretty" sequence number, simply generate something for them when you query the data using the row_number, rank, or dense_rank analytic functions. If users want to see sequences reset, they probably also want to see gap-free sequences, which is not something that you can ever guarantee in a scalable system where multiple users are allowed, though you can present gap-free sequences of values at query time.
    You can have a job that either drops and recreates the sequence every day or that goes through some logic to reset the sequence to 1 by changing the increment. This gets rather hairy, though, because the job will fail (or fail to run) on occasion and requires that no one be processing data at the time.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • HSQL Db Sequences

    We are experiencing a problem using an HSQL db sequence to generate an id for a table.
    kodo.properties has:
    kodo.jdbc.SequenceFactory: nativewhile in the package.jdo we have:
        <class name="ChannelPlan" persistence-capable-superclass="com.ea.albt.domain.model.capacityplanning.FrequencyResource">
          <extension vendor-name="kodo" key="jdbc-sequence-name" value="seq_channel_plans"/>
          <extension vendor-name="kodo" key="jdbc-sequence-factory" value="kodo.jdbc.schema.ClassSequenceFactory(TableName=DUAL,Format=SELECT NEXT VALUE FOR {0} FROM {1})"/>When run it gives this error:
    kodo.util.FatalDataStoreException: Column not found: SEQ_CHANNEL_PLANS.NEXTVAL in statement [select seq_channel_plans.NEXTVAL from DUAL] {select seq_channel_plans.NEXTVAL from DUAL} [code=-28, state=S0022]
    NestedThrowables:
    com.solarmetric.jdbc.ReportingSQLException: Column not found: SEQ_CHANNEL_PLANS.NEXTVAL in statement [select seq_channel_plans.NEXTVAL from DUAL] {select seq_channel_plans.NEXTVAL from DUAL} [code=-28, state=S0022]
    java.sql.SQLException: Column not found: SEQ_CHANNEL_PLANS.NEXTVAL in statement [select seq_channel_plans.NEXTVAL from DUAL]
         at kodo.jdbc.sql.SQLExceptions.getFatalDataStore(SQLExceptions.java:42)The format of the sequence query is wrong for HSQLDB, the supplied format is being ignored.

    Look at
    http://hsqldb.sourceforge.net/web/hsqlDocsFrame.html
    specifically
    http://hsqldb.sourceforge.net/doc/hsqlGuide.html

  • How to populate field on page with Primary Key value from previous page

    I am trying to create a patient tracking system for a group of doctors. There is an add patient form based on the Patient table (which has Patient_Id as its primary key) which branches to a pre-operative assessment form. I would like to populate the pre-op assessment Patient_Id field with the Patient_Id generated by the Add Patient page during processing, which comes from the Patient_seq sequence. How can I do this? I have tried using a computation on the Pre-Op Assessment form, but no matter what I put in, the field remains blank.

    Hi,
    If I understand you correctly, once patient record is created you branching to next page (pre-operative assessment form). First create a static hidden item in patient form *:PX_PATIENT_ID_COPY*.
    Create an On submit after computation and validation process in patient form to get the inserted patient_id from patient table. Here is the code -
    SELECT patient_id into :PX_PATIENT_ID_COPY from patient_table where rownum=1
    order by patient_id descI would not use the sequence to get the current value because if the inserted record been deleted from your patient table, sequence current value would not be valid to find that record in patient table.
    Basically when the record been inserted, the process get the value and put into the hidden item.
    Pass the value from the hidden item to the next page by setting them in page branch. Under the Action section in the page branch, Set this items field type - *:PX_PATIENT_ID* (next page item for patient_id). Type *&PX_PATIENT_ID_COPY.* in the with these values field. Make sure you include dot(.) after *&PX_PATIENT_ID_COPY*.
    Give it a try now. Hope it would helps.
    Regards,
    Tajuddin
    Blog: http://aspblog.whitepagesbd.com
    web: http://tajuddin.whitepagesbd.com

  • Sequence Generator problem in OWB Mapping

    Hi,
    I am using a Sequence Generator in my Dimension mapping. And OWB implements the mapping via an Oracle MERGE statement.
    However when I execute the mapping my sequence number value gets incremented even when there are only updates and no inserts taking place during the execution.
    I am using the sequence number only for inserts and not for updates in the mapping.
    Is there a way to avoid this situation or a work around to this problem? This is very urgent and any help in this area would be greatly appreciated.
    Thanks

    Hi
    I also have the same problem as I loose the seq numbers when there are updates only and I do not want to loose thousands of seq numbers. I tried with bulk size =1 as well as row based only execution but no result.
    The thing which solved this problem is to have outer join with source and target, then use splitter to find out new and updated records (by looking the join key as null on target table side), then use a fuction to generate seq number when the key is not null. But doing all this does not seem to be elegant performance point of you. I do not want to join source and target due to performance issues.
    Could you pl clrify your apprach. Are you using , Source minus target and Source Intersect Target . What you will do if there is no one to one matching between source and the target.
    Thanks

  • Prefixing sequence with schema name in generated sql on oracle

    Hi,
    We use kodo 3.4 with an oracle database in a J2EE environment.
    When we put on the kodo tracing during on of our testcases we see statements being generated like :
    select LOOPBAANPERIODESEQUENCE.NEXTVAL from DUAL
    When we check the rest of the statements we see :
    SELECT * FROM PC52290.EINDELOOPBAAN (EINDELOOPBAAN being a table)
    Is there any way to make kodo generate the following statement ?
    select PC52290.LOOPBAANPERIODESEQUENCE.NEXTVAL from DUAL
    Our kodo.properties we use :
    javax.jdo.PersistenceManagerFactoryClass=kodo.jdbc.runtime.JDBCPersistenceManagerFactory
    javax.jdo.option.Optimistic=true
    javax.jdo.option.RetainValues=true
    javax.jdo.option.NontransactionalRead=true
    kodo.jdbc.DBDictionary=kodo.jdbc.sql.OracleDictionary
    kodo.jdbc.ForeignKeyConstraints=true
    kodo.LicenseKey=<VALID_LICENSE_HERE>
    kodo.Log=DefaultLevel=WARN,SQL=TRACE,Runtime=WARN,Configuration=WARN
    kodo.jdbc.Schemas=PC52290
    kodo.PersistentClasses= ...
    An example of our mapping :
              <class name="LoopbaanPeriode">
                   <extension vendor-name="kodo" key="jdbc-sequence-factory" value="native"/>
                   <extension vendor-name="kodo" key="jdbc-sequence-name" value="LOOPBAANPERIODESEQUENCE"/>
    <extension vendor-name="kodo" key="jdbc-class-ind-value" value="1"/>
    <field name="beginDatum"           persistence-modifier="persistent" />
    <field name="statuut" persistence-modifier="persistent" />
    <field name="loopbaan"                     persistence-modifier="persistent"/>
    </class>
    regards,
    David De Schepper.

    Hi David,
    When faced with a similar problem, I wrote my own subclass of DBDictionary
    (in my case actually a subclass of OracleDictionary), and plugged it into
    kodo using the kodo.jdbc.DBDictionary property. My class overrode the
    following methods:
    public String getFullName(Table, boolean);
    public String getFullName(Index);
    Then at runtime, these methods stuffed in the correct Schema name for
    certain tables and indexes, based on values yoinked from some user
    properties.
    Not sure if this will help or not in your case.
    Cheers!
    .droo.
    On 4/9/06 2:48 PM, in article [email protected], "David De
    Schepper" <David De Schepper> wrote:
    yes that works but that is not an option for us.
    We have an oracle schema for each developer on our team and don't want to
    hardcode it in our mapping file (for obvious reasons)
    FYI : kodo 4.0.1 does it correctly (generates PC52290.LOOPBAANPERIODESEQUENCE)
    but since i have problems doing the upgrade to kodo 4.0 (with as few code
    changes as possible) i'm going to have to advice my company not to do the
    upgrade.
    (In case you are intersted or have some time :
    http://forums.bea.com/bea/thread.jspa?forumID=500000029&threadID=600017073&mes
    sageID=600041994#600041994)

Maybe you are looking for

  • Can Actions Menu of Interactive Reports work with Custom Authentication?

    My testing is leading my to believe that Actions Menu do not work with Custom Authentication (but only work with APEX Authentication) in APEX 3.1.2? If that's true then is there a work around to this? Just to clarify, I've posted/asked this question

  • Wireless Mighty Mouse has stopped selecting, cutting or pasting

    My batteries ran out two days ago. I changed the batteries but since then my wireless Mighty Mouse will not select text, cut or paste. It has other erratic behavior. Any help and advice welcomed.

  • Move my iWeb site from my G5 to my MacBook

    I just got a new MacBook and I want to move my website from my G5 desktop to my MacBook so I can make changes from anywhere. I cant figure out how to get on the MacBook so I can edit it in iweb from my laptop. Thanks for any help you all can give.

  • BW Reporting & Analysis Overview

    Hi folks, I need a high-level presentation on SAP BW Reporting & Analysis. Basically, I'm looking for a condensed presentation of TBW20 or BW305 course. Say 50 pager material with diagrams + summary text. Knowledge Warehouse content is too detailed f

  • Question about overridden method error

    Hello everyone, I have a silly problem which im sure is elementry, but alas still I cannot work it out. I have a test class as below import android.os.Handler; public class Test extends Handler{        @Override        public void handleMessage(Messa