Sequence object

Hi,
I can call Sequence object in application module like this way?
import oracle.jbo.server.SequenceImpl;
String SEQUENCE = "ACCOUNT_SEQ";
//Get the Sequence object
SequenceImpl accSeq = new SequenceImpl(SEQUENCE, getDBTransaction());
//Get the Sequence value
Number accValue = accSeq.getSequenceNumber();
But this didnot work in jsp page? is there a way i can get sequence value in jsp page since I do not want to use trigger by using DBSequence data type?
thanks

ok, here is another way to do it.
In the Java code for your entity look for the create method for your record and add a piece of code like this:
protected void create(AttributeList attributeList)
super.create(attributeList);
//make sure to change the name of the sequance in this line
SequenceImpl s = new SequenceImpl("JCAB_COMPANIES_S", getDBTransaction());
Long next = (Long)s.getData();
//this line will need to use the set method for your primary key column
this.setCompanyId(new Number(next.intValue()));
}

Similar Messages

  • Is there a SEQUENCE object, like in Oracle?

    I want to create a table and I have 2 fields, user name and user e-mail. The user e-mail would be the key, but, for performance issues, I think it's advisable to create a 3rd field, simply to assign an ID to each row - a numerical field.
    So as to every time a record is inserted in the table, this 3rd ID row is assigned a value automatically, with the next number in the sequence for the current record being added - if there are 11 records in the table and a 12th is being added, then the ID would be automatically set to 12 during the insertion of this 12th record.
    I would do this in Oracle through a SEQUENCE object.
    There's something equivalent I could use in SAP ?
    Thanks,
    Avraham

    In SAP we have 'number ranges' which serves the same purpose.
    http://help.sap.com/erp2005_ehp_03/helpdata/EN/08/51415d43b511d182b30000e829fbfe/frameset.htm
    The above link would give you fair amount of knowledge to create your own number range
    Cheers,
    KD

  • How to Use Sequence Object Inside User-defined Function In SQL Server

    I'm trying to call sequence object inside SQL Server user-defined function. I used 
    Next Value for dbo.mySequence  to call the next value for my sequence created. But I'm getting an error like below.
    "NEXT VALUE FOR function is not allowed in check constraints, default objects, computed columns, views, user-defined functions, user-defined aggregates, user-defined table types, sub-queries, common table expressions, or derived tables."
    Is there any standard way to call sequence inside a function?
    I would really appreciate your response.
    Thanks!

    The NEXT
    VALUE FOR function cannot be used for User Defined function. It's one of the limitation.
    https://msdn.microsoft.com/en-us/library/ff878370.aspx
    What are you trying to do? Can you give us an example and required output?
    --Prashanth

  • Can I reference a sequence object by a local variabl?

    Hi,
    I create ten sequences in database. In my form, I get a sequence number from different sequence object according to different situations.
    So can I choose one of the seuqences by refering it using a local variable ? such as :
    declare
    first_sequence varchar2(100);
    new_po number(10);
    begin
    first_sequence:='po_number';
    select first_sequence.nextval
    into new_po
    from dual;
    end;
    Thanks
    Stephen

    I cannot see this working as it will complain at compile time. The compiler will look for the envVar as an object on the DB. I believe what you need is something like DBMS_SQL or EXECUTE IMMEDIATE to do what you want.

  • SEQUENCE Object for Small Tables Only?

    QUOTE from a recent thread: "Long term solution should be to use SEQUENCE with NO CACHE for small tables instead of identity and benefit from performance improvement for large tables."
    Thread:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/cf63d145-7084-4371-bde0-eb3b917c7163/identity-big-jump-100010000-a-feature?forum=transactsql
    How about using SEQUENCE objects for large tables? Thanks.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

    Well Erland, either you calm down your manager (with a martini?) or use NO CACHE.
    QUOTE: "This could cause a sequence to run out of numbers much more quickly than an IDENTITY value. It could also cause managers to become upset that values are missing, in which case they’ll need to simply get over it and accept that
    there will be numbers missing.
    If you need SQL Server to use every possible value, configure a cache setting of NO CACHE. This will cause the sequence to work much like the IDENTITY property. However, it will impact the sequence performance due to the additional metadata writes."
    LINK: Microsoft SQL Server: The Sequencing Solution
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Want to use sequence object of oracle when loading data in sql loader

    Hi,
    I want to use sequence when loading data in sqll loader, but the problem is i could not use sequence object of oracle to load the data by sql loader, i can use sequence of sql loader.
    I want to use sequence object because in later entries this sequence object will be used.If i use sequence of sql loader how can i use oracle sequence object
    Is there any other option

    I have a simillar problem, I also want to use a sequence when loading data by the SQL Loader.
    My control file is:
    load data
    infile '0testdata.txt'
    into table robertl.tbltest
    fields terminated by X'09'
    trailing nullcols
    (redbrojunos,
    broj,
    dolazak,
    odlazak nullif odlazak=blanks,
    komentar nullif komentar=blanks)
    And the datafile is:
    robertl.brojilo.nextval     1368     17.06.2003 08:02:46     17.06.2003 16:17:18     
    robertl.brojilo.nextval     2363     17.06.2003 08:18:18     17.06.2003 16:21:52     
    robertl.brojilo.nextval     7821     17.06.2003 08:29:22     17.06.2003 16:21:59     
    robertl.brojilo.nextval     0408     17.06.2003 11:20:27     17.06.2003 18:33:00     ispit
    robertl.brojilo.nextval     1111     17.06.2003 11:30:58     17.06.2003 16:09:34     Odlazak na ispit
    robertl.brojilo.nextval     6129     17.06.2003 14:02:42     17.06.2003 16:23:23     seminar
    But all records were rejected by the Loader, for every record I get the error:
    Record 1: Rejected - Error on table ROBERTL.TBLTEST, column REDBROJUNOS.
    ORA-01722: invalid number

  • Getting Sequence object from pre-step substep of Sequence Call based step type

    How to obtain reference to Sequence object from within pre-step substep of Sequence Call based custom step type?
    Given: new custom step type which based on NI Sequence Call step type. There is Pre-Step substep exist for this step type.
    How to get reference to Sequence object representing Sequence which will run?
    Although there is possible to examine SequenceAdapter and SequenceCallModule properties, it seems redundant since module (Sequence) is already loaded by TestStand ("NI TestStand Reference Manual. Table 3-4. Order of Actions that a Step Performs"   Action #6, while my code is running as Action #13).
    Thanks.
    Misha

    Could you explain what you want to do ?
    Why do you want to get the sequence object within a pre-step substep ?
    I give you some informations but I don't know if it's the better way to do what you want (because I don't know what you want to do with the sequence object).
    If the substep uses the ActiveX adapter :
    You can get the sequence object but you should save the object reference in a StationGlobals variable.
    And you should release the object reference within your sequence when you don't need it any more.
    If the substep uses another module adapter: 
    Get the step module, then the sequence name (module property).
    Then get the sequence object by the sequence name from the sequence file.
    Here are the paths to use for both methods :
    Sequence Name property path : Step.Module.SeqName
    Sequence Object path : RunState.SequenceFile.GetSequenceByName (seqname)

  • SEQUENCE Object generation

    How to create Sequence Object using TopLink ....
    Ex..,below is the Sequence object for which i am looking to create using TopLink
    PL/SQL :
    create sequence SEQ_NM minvalue 1 maxvalue 999999999999999999999999999 start with 1636
    increment by 1
    cache 20;

    You'll need to define NativeSequence named "SEQ_MN" in TopLink.
    You can do it either in MappingWorkbench or directly in the code (before login the session).
    Create a Sequence
      Sequence mnSequence = new NativeSequence("SEQ_MN", 1, 1636);If you use only one sequence in your project:
      session.getLogin().setDefaultSequence(mnSequence);otherwise:
      session.getLogin().addSequence(mnSequence);To create sequence object(s) in the database, login the session and call
      (new SchemaManager(session)).createSequences();The above call will created all the sequences that are used by the session (that means used by at least one descriptor).
    Note that TopLink 10.1.3 will ignore the initial value (1636) and will issue:
    create sequence SEQ_NMIt's fixed in TopLink 11 preview:
    create sequence SEQ_NM start with 1636

  • Sequence object in Oracle

    Hello experts, I am using oracle 11g.I have a sequence to generate some ids.If I want that my sequence has been reset like i will start from starting again.It is possible to re initiate a sequence object in Oracle.If it is my client's requirement. Thank You regards aaditya

    You could always use ALTER SEQUENCE
    or simply re-create your sequence. However this may invalidate database objects.
    cheers

  • Change Sequencing Policy for individual objects? V9.0.4.9

    Our TOPLink projects us using by default the sequence table model for its sequencing policy.
    There are a few individual tables where native sequencing is being used, and I need to map these tables and be able to insert into them.
    Can I change the sequencing policy for these few tables only in version v9.0.4.9? I believe this may be possible via a Descriptor Amendment, but cannot find the method(s) that allow me to change this...
    Thanks in advance..
    Greg

    Our TOPLink projects us using by default the sequence
    table model for its sequencing policy.
    There are a few individual tables where native
    sequencing is being used, and I need to map these
    tables and be able to insert into them.
    Can I change the sequencing policy for these few
    tables only in version v9.0.4.9? I believe this may
    be possible via a Descriptor Amendment, but cannot
    find the method(s) that allow me to change this...
    Thanks in advance..
    GregIn 9.0.4.* you can do this in a descriptor amendment method by invoking the following API -
    descriptor.setSequenceNumberName(String name). For Oracle native sequencing this needs to be the name of the Oracle sequence object.

  • CREATE SEQUENCE from a stored procedure

    Hello,
    Is it possible, to create a sequence object from an own written stored procedure? Can I reinitialize the actual value of a sequence object without recreating it from a stored procedure?
    Thank you for recommendations,
    Matthias Schoelzel
    EDV Studio ALINA GmbH
    Bad Oeynhausen

    maybe this example might be of some help.
    SQL> create or replace procedure dy_sequence (pSeqName varchar2,
      2                                           pStart number,
      3                                           pIncrement number) as
      4    vCnt     number := 0;
      5  begin
      6    select count(*) into vCnt
      7      from all_sequences
      8     where sequence_name = upper(pSeqName);
      9 
    10    if vCnt = 0 then
    11      execute immediate 'create sequence '||pSeqName||
    12                        ' start with '||to_char(pStart)||
    13                        ' increment by '||to_char(pIncrement);
    14    else
    15      execute immediate 'alter sequence '||pSeqName||' increment by '||to_char(pIncrement);
    16    end if;
    17  end;
    18  /
    Procedure created.
    SQL> -- create the sequence by calling the dy_sequence procedure
    SQL> execute dy_sequence ('test_sequence',1,1);
    PL/SQL procedure successfully completed.
    SQL> select test_sequence.nextval from dual;
       NEXTVAL
             1
    SQL> -- alter the sequence to increment by 2
    SQL> execute dy_sequence ('test_sequence',0,2);
    PL/SQL procedure successfully completed.
    SQL> select test_sequence.nextval from dual;
       NEXTVAL
             3
    SQL>

  • Oracle Payables - APXIIMPT  - Invalid Sequence rejections

    Hello Guys:
    My Business users are complaining that they are getting lot of rejections while running APXIIMPT ( Payable Open Interface Report for Invoices) due to invalid sequence error. We logged a TAR with oracle and I am not getting any where after this. The support tech expects me to work with her as a functional consultant but I am not. I am pasting the response from the Support tech.
    Can any one give me more details on How to check this? I would really appreciate it.
    We are using Standard Invoice - STDINV
    The first statement says we need to check the document category code, but she never explains how to check this. I looked at the Oracle payables guide and it is completely text no diagrams.
    Regards,
    Bala
    UPDATE
    =======
    I gave you step by step on how to check the document catergory code that you are using for the invoice above.
    The rejection you are receiving is usually because you have not setup the document catergory code correctly
    Just replace the create with the name of the sequence you already have set up and
    check to see if it is setup as the above.
    For example:
    1. Application>Document>Define (query on sequence you are using for the invoice)
    A sequence can be Manual or Automatic.
    If it is Automatic an Oracle Sequence Object will be created starting
    at the designated beginning number and that sequence will be used to
    generate the document numbers. After a record in this form is
    saved, and type = Automatic, a Concurrent Process is submitted to create
    the Oracle Sequence.
    2. Examine Document Categories
    Application>Document> query on Categories assigned to sequence above
    There are numerous document categories already defined for Oracle Payables.
    The default category used in creating Voucher numbers for Payables Invoices
    in the Invoice Workbench is STD INV.
    If the Payables "Option Allow Document Category Override" in the
    Invoice region is checked, the Document Category can be changed to any category
    that has a Table Name of AP_INVOICES_ALL.
    3. Assign Document Sequence to a Category.
    Application>Document>query on Assign
    In the Documents Region, indicate the application, the document category,
    the set of books, and the method of entering the sequence number.
    The method is Automatic, Manual, or Null.
    THIS IS THE MOST COMMON SOURCE OF ERROR.
    The method is used to tell the system how the record is being created:
    a. Manual means that the record is being created by a form such
    as the Invoice Workbench.
    b. Automatic means the record is being created by a Concurrent
    Process such as Invoice Import.
    Setting the assignment as Automatic, will result in an error when
    trying to enter an invoice using the Invoice Workbench.

    For whatever it is worth....
    This is resolved by ledger set up--> Accounting Setups and adding the balancing segments for which the accounts relate to.

  • Using Sequence in FORALL Statement

    I'm using a package to get the nextval in a sequence object. Basically, it is a function that returns select user_seq.nextval from dual.
    But I get 'column not allowed here' error. PL/SQL: ORA-00984: column not allowed here
    OPEN users_ins ;
                 LOOP
                    FETCH         naf_users_ins
                    BULK COLLECT
                    INTO           arr_person_key
                                 , arr_person_id
                                 , arr_first_name
                                 , arr_middle_name
                                 , arr_last_name
                                 , arr_username
                                 , arr_user_status_seq
                                 , arr_creation_date
                                 , arr_comments
                   LIMIT         100 ;
    FORALL idx IN 1 ..  arr_person_key.COUNT
                     SAVE EXCEPTIONS
                       INSERT INTO users
                        (   user_seq
                          , person_key
                          , person_id
                          , first_name
                          , middle_name
                          , last_name
                          , username
                          , user_status_seq
                          , creation_date
                          , comments
                        VALUES  (   *pkg_admin.get_nextval*
                                  , arr_person_key(idx)
                                  , arr_person_id(idx)
                                  , arr_first_name(idx)
                                  , arr_middle_name(idx)
                                  , arr_last_name(idx)
                                  , arr_username(idx)
                                  , arr_user_status_seq(idx)
                                  , arr_creation_date(idx)
                                  , arr_comments(idx)
    EXIT WHEN users_ins%NOTFOUND ;
                 END LOOP ;
                 CLOSE users_ins;
    c/code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    I've recently completed a similar task, but I declared a collection with the rowtype of the table. I also added the sequence in the query of my cursor. Take a look at the following example.
    CREATE OR REPLACE PROCEDURE Insert_OR_ExternalService
    IS
    TYPE externalService_tbl IS TABLE OF OR_ExternalService%ROWTYPE;
    externalService externalService_tbl;
    CURSOR OR_ExternalServiceCursor
    IS
    select
    SEQ_ID.NEXTVAL as "Id",
    column as "ExternalId",
    column as "ExternalSystem",
    from table1
    where ...;
    BEGIN
    OPEN OR_ExternalServiceCursor;
    LOOP
    FETCH OR_ExternalServiceCursor BULK COLLECT INTO externalService LIMIT 1000;
    FORALL i IN 1 .. externalService.count
    INSERT INTO OR_ExternalService values externalService(i);
    COMMIT;
    EXIT WHEN OR_ExternalServiceCursor%NOTFOUND;
    END LOOP;
    CLOSE OR_ExternalServiceCursor;
    END;

  • Sequencing and Trigger on Oracle 9i lite database

    We created a schema (TESTSCHEMA) on Oracle 8.1.7 Enterprise edition and have a created a trigger which will use the sequence object to generate primary key for the table (TEST_TABLE)
    Sequence creation:
    CREATE SEQUENCE TESTSCHEMA.TEST_TABLE_SEQUENCE START WITH 6000 INCREMENT BY 1 MINVALUE 6000 MAXVALUE 6999 NOCACHE NOCYCLE NOORDER ;
    Trigger creation:
    CREATE OR REPLACE TRIGGER TEST_TABLE INSERT BEFORE INSERT ON TEST_TABLE FOR EACH ROW
    DECLARE
    pkValue NUMBER;
    BEGIN
    pkValue := 0;
    Select TEST_TABLE_SEQUENCE.NextVal into pkValue from dual;
    :NEW.TEST_KEY := pkValue;
    END TEST_TABLE_INSERT;
    We have created a snapshot of the schema on mobile server, synchronized the data with the client (Win32 for testing purpose).
    The trigger works fine on the server, but when I run the same query on the lite database with msql it gives me an error:
    [POL-3221] null key in primary index
    I was wondering if Sequence generation and Triggers are supported on Oracle 9i lite database ? Or am I missing out something ??
    Any information/ help is appreaciated
    Thanks
    Neeraj

    You can't use SAVEPOINT / ROLLBACK TO SAVEPOINT statements in the database trigger:
    ORA-04092: cannot SET SAVEPOINT in a trigger
    ORA-04092: cannot ROLLBACK in a trigger
    I am not sure what you need exactly, but you can try this:
    Simulating ROLLBACK TO SAVEPOINT Behavior in a Database Trigger
    http://www.quest-pipelines.com/pipelines/plsql/tips02.htm#JUNE
    Regards,
    Zlatko Sirotic

  • Can't get Sequencing working (table or view does not exist...)

    Hello,
    I'm running JDeveloper 10.1.2 on a Oracle 9i database.
    All my mappings are correct, i mean, i can query the database using the Toplink API and list all the objects on teh database. What it's not working is inserting new objects due to this sequencing problem.
    This is what i'm doing:
    myClass newObject = (myClass) uow.newInstance(myClass.class);
    uow.assignSequenceNumber(newObject);
    But this is generating this Exception:
    Local Exception Stack: Exception [TOPLINK-4002] (OracleAS TopLink - 10g (9.0.4.5) (Build 040930)): oracle.toplink.exceptions.DatabaseExceptionException Description: java.sql.SQLException: ORA-00942: table or view does not exist
    Internal Exception: java.sql.SQLException: ORA-00942: table or view does not exist
    Error Code: 942
    I figured this could be a problem with the sequencing configuration and all that stuff (I don't have a sequence table). So i checked my configurations...
    'Toplink Mappings' is setup to 'Use Native Sequencing', as per Notes on http://www.boku.ac.at/oradoc/ias/10g(9.0.4)/web.904/b10313/dataaccs.htm. This page also states this:
    "When using native sequencing with Oracle, specify the name of the sequence object (the object that generates the sequence numbers) for each descriptor. The sequence preallocation size must also match the increment on the sequence object" (...) "Use preallocation and native sequencing for Oracle databases.
    And this is exactly what i'm doing. On myClass mappings, the 'Use Sequencing' checkbox is checked, the correct sequence name is typed correctly, once this is the same sequence i've been using for years prior to Toplink, the selected table is the correct one, just as the id field on the table.
    Another thing is that the 'Preallocation Size' on Toplink Mappings match the increment value on the database sequence.
    I must be missing something...
    Can anybody shed some light on this?
    Thanks a lot to all.

    Hello
    The method accessing check box tells TopLink to use the get/set methods on your object to set its attributes - If it is unselected, TopLink will set the attribute directly. Great if you have business logic in your get/set methods that you don't want TopLink to hit each time it creates an object after a read from the database (or registers, etc).
    The problem you are encountering seems like you have sequencing set to "Use Default Sequencing Table". This option is on the "TopLink Mappings" page on the "Database info" tab just below where you would have set which connection to use. You will need to ensure you have the "use Native sequencing" selected. If you set this information instead through code, be sure you do it on the database login before you login to the session.
    If this doesn't help, try turning on TopLink logging to see the SQL statement that causes the problem. The knowing the table name and SQL being used might help figure out where it is being set.
    Best Regards,
    Chris

Maybe you are looking for

  • Hp aio remote app on iPhone won't scan to my hp photosmart 7515

    hp aio remote app "there was a problem during scanning. check scanner and try again" when using hp photosmart 7515 however this is a new issue the app scanning worked before. Also I can no longer print or scan unless at home and connected to my netwo

  • Is there any type of automated shadow effect for text?

    Hi, I've got a 30-second sequence of white text on black background, consisting of about 40-50 individual clips where the text is moving randomly in each clip. Some clips have the text moving left to right some right to left, some diagonally, zooming

  • Suddenly archived messages reappear in inbox after I get a new msg in that thread. How can I prevent this?

    This is a new problem. I didn't change any account settings that I'm aware of; I can't recall if I installed any updates before it started. It took me a few days to figure out exactly what was going on. At first it just seemed that old, archived mess

  • Passing a resultset to a method

    Hi all, I want to pass a resultset object that is scrollable and updateable to a method. THe problem is that, the resultset object in the other method is not scrollable or updateable anymore. Eg. Statement stat = null; ResultSet rs = null; stat = con

  • Air application in vista

    i created an air application use flash as3 .but i face one problem in windows xp the application run fastly in the case of vista the application very slow.some time hanging the system.so please give me a solution