Using sequence in adf

hi i have a sequence in my database how can i use that sequence in my application. i have a createInsert button, i what to insert the id using the sequnce in my database
Edited by: ADFnewbie on 2012/01/11 11:04 PM

hi am trying to do my test in my application module am having this errror my expression is (new oracle.jbo.server.SequenceImpl("SMS_CAT_SEQ",adf.object.getDBTransaction())).getSequenceNumber()
oracle.jbo.KeyNotPopulatedException: JBO-25078: Key attribute Id for SmsUsers not populated
     at oracle.jbo.server.OracleSQLBuilderImpl.buildWhereClause(OracleSQLBuilderImpl.java:2357)
     at oracle.jbo.server.EntityImpl.buildWhereClause(EntityImpl.java:10718)
     at oracle.jbo.server.OracleSQLBuilderImpl.doEntitySelectForAltKey(OracleSQLBuilderImpl.java:747)
     at oracle.jbo.server.BaseSQLBuilderImpl.doEntitySelect(BaseSQLBuilderImpl.java:552)
     at oracle.jbo.server.EntityImpl.doSelect(EntityImpl.java:8287)
     at oracle.jbo.server.EntityImpl.populate(EntityImpl.java:6951)
     at oracle.jbo.server.EntityImpl.getAttributeInternal(EntityImpl.java:3516)
     at oracle.jbo.server.AttributeDefImpl.get(AttributeDefImpl.java:3141)
     at oracle.jbo.server.AttributeDefImpl.resolveGet(AttributeDefImpl.java:3369)
     at oracle.jbo.server.EntityImpl.getAttrInvokeAccessor(EntityImpl.java:1674)
     at oracle.jbo.server.EntityImpl.getAttribute(EntityImpl.java:1639)
     at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1773)
     at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:1962)
     at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:824)
     at oracle.jbo.server.ViewRowImpl.getKey(ViewRowImpl.java:635)
     at oracle.jbo.server.EntityImpl$ViewRowRef.<init>(EntityImpl.java:13229)
     at oracle.jbo.server.EntityImpl.registerExprValueSupplierOverride(EntityImpl.java:659)
     at oracle.jbo.server.ViewRowStorage.registerExprValueSupplierOverride(ViewRowStorage.java:1259)
     at oracle.jbo.server.ViewRowCache.addWithCheck(ViewRowCache.java:370)
     at oracle.jbo.server.ViewRowCache.add(ViewRowCache.java:410)
     at oracle.jbo.server.QueryCollection.addRowToColl(QueryCollection.java:3415)
     at oracle.jbo.server.QueryCollection.fetch(QueryCollection.java:3490)
     at oracle.jbo.server.QueryCollection.get(QueryCollection.java:2184)
     at oracle.jbo.server.ViewRowSetImpl.getRow(ViewRowSetImpl.java:5125)
     at oracle.jbo.server.ViewRowSetIteratorImpl.doFetch(ViewRowSetIteratorImpl.java:2936)
     at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2792)
     at oracle.jbo.server.ViewRowSetIteratorImpl.refresh(ViewRowSetIteratorImpl.java:3033)
     at oracle.jbo.server.ViewRowSetImpl.notifyRefresh(ViewRowSetImpl.java:2797)
     at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:1255)
     at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:1078)
     at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2775)
     at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2752)
     at oracle.jbo.server.ViewRowSetIteratorImpl.first(ViewRowSetIteratorImpl.java:1581)
     at oracle.jbo.server.ViewRowSetImpl.first(ViewRowSetImpl.java:3556)
     at oracle.jbo.server.ViewObjectImpl.first(ViewObjectImpl.java:10196)
     at oracle.adf.model.binding.DCIteratorBinding.setupRSIstate(DCIteratorBinding.java:808)
     at oracle.adf.model.binding.DCIteratorBinding.refreshControlAndNotifyDCE(DCIteratorBinding.java:707)
     at oracle.adf.model.binding.DCIteratorBinding.refreshControl(DCIteratorBinding.java:676)
     at oracle.jbo.uicli.binding.JUIteratorBinding.refreshControl(JUIteratorBinding.java:485)
     at oracle.adf.model.binding.DCIteratorBinding.refresh(DCIteratorBinding.java:4555)
     at oracle.adf.model.binding.DCExecutableBinding.refreshIfNeeded(DCExecutableBinding.java:347)
     at oracle.adf.model.binding.DCIteratorBinding.getRowSetIterator(DCIteratorBinding.java:1634)
     at oracle.jbo.jbotester.panel.BindingPanel.setBindingContext(BindingPanel.java:131)
     at oracle.jbo.jbotester.panel.BindingPanel.<init>(BindingPanel.java:101)
     at oracle.jbo.jbotester.panel.BindingPanel.<init>(BindingPanel.java:75)
     at oracle.jbo.jbotester.form.BindingForm.createMasterPanel(BindingForm.java:65)
     at oracle.jbo.jbotester.form.BindingForm.init(BindingForm.java:126)
     at oracle.jbo.jbotester.form.JTForm.<init>(JTForm.java:72)
     at oracle.jbo.jbotester.form.BindingForm.<init>(BindingForm.java:52)
     at oracle.jbo.jbotester.form.FormType$1.createForm(FormType.java:63)
     at oracle.jbo.jbotester.form.FormType.createForm(FormType.java:199)
     at oracle.jbo.jbotester.form.FormType.createTab(FormType.java:270)
     at oracle.jbo.jbotester.form.FormType.showForm(FormType.java:248)
     at oracle.jbo.jbotester.form.FormType.showForm(FormType.java:207)
     at oracle.jbo.jbotester.form.FormType.showForm(FormType.java:203)
     at oracle.jbo.jbotester.tree.ObjTreeNode.showForm(ObjTreeNode.java:135)
     at oracle.jbo.jbotester.tree.ObjTreeNode.showForm(ObjTreeNode.java:118)
     at oracle.jbo.jbotester.tree.Tree.processTreeMouseClicked(Tree.java:734)
     at oracle.jbo.jbotester.tree.Tree.access$100(Tree.java:96)
     at oracle.jbo.jbotester.tree.Tree$TreeMouseListener.mouseClicked(Tree.java:145)
     at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
     at java.awt.Component.processMouseEvent(Component.java:6292)
     at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
     at java.awt.Component.processEvent(Component.java:6054)
     at java.awt.Container.processEvent(Container.java:2041)
     at java.awt.Component.dispatchEventImpl(Component.java:4652)
     at java.awt.Container.dispatchEventImpl(Container.java:2099)
     at java.awt.Component.dispatchEvent(Component.java:4482)
     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4247)
     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
     at java.awt.Container.dispatchEventImpl(Container.java:2085)
     at java.awt.Window.dispatchEventImpl(Window.java:2478)
     at java.awt.Component.dispatchEvent(Component.java:4482)
     at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
     at java.awt.EventQueue.access$000(EventQueue.java:85)
     at java.awt.EventQueue$1.run(EventQueue.java:603)
     at java.awt.EventQueue$1.run(EventQueue.java:601)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
     at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
     at java.awt.EventQueue$2.run(EventQueue.java:617)
     at java.awt.EventQueue$2.run(EventQueue.java:615)
     at java.security.AccessController.doPrivileged(Native Method)
     at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
     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)
Edited by: ADFnewbie on 2012/01/12 1:44 AM

Similar Messages

  • Using sequences in ADF-UIX

    Hi
    I am trying to add a record to a table using the create action from the data control.
    The underlying table has a sequence defined on it. Is there a way to get the next sequence number to show when the user clicks the Create button?
    thanks

    Assuming the field the sequence is pushed to is called Id, and the sequence name is ID_SEQ, override the EO's create method with the following code:
    protected void create(AttributeList attributeList) {
      super.create(attributeList);
      oracle.jbo.server.SequenceImpl idSeq = new SequenceImpl("ID_SEQ", getDBTransaction());
      setId(idSeq.getSequenceNumber());
    }Now when you create a record in UIX, you'll see the sequence number prepopulated in the associated Id field. You can set the field's properties to readOnly as the user no longer has to populate it.
    Hope this helps.
    CM.

  • MAX(SummaryNum) +1 bad idea, but how to use sequence part composite column

    Hi,
    My relational mode is as follows
    Policy (policynum PK) has 1:M with Summary (policynum FK, SummaryNum part of PK, other columns part of PK)
    Basically for each policy users can enter notes with SummaryNum 1, 2, 3, 4.... These numbers are shown to the user for tracking purpose. I need to make sure summary notes for EACH policy start with 1 (cannot really use sequence in the table in the strictest sense) and are incremented by 1. The current Oracle form basically creates the next highest possible value of SummaryNum by adding one to the currently available highest value. In brief, it is like a sequence number for summaries of a particular policy in the summary table.
    PRE-INSERT
    SELECT MAX(SummaryNum ) + 1
    FROM Summary
    I am trying to replicate this in ADF BC (using 11g) and know that not using sequencing and adding one to get the next number is a very bad idea due to concurrency challenges (transactional ACID properties). The reasons are as follows.
    •     Using MAX(policy_memo_seq_num) + 1 is not scalable,
    •     It will lead to duplicates in a multi-user environment, whether ADF BC, Oracle Forms, or any other technology
    I also know how to use create a sequence in db, a related trigger, and then set the attribute in EO properties as DBSequence. My challenge is that since SummaryNum is not a primary key, and instead is part of a composite key in my case, how do I make sure that summary notes for EACH policy start with 1 in the Summary Table.
    I appears that i cannot really use sequence in the table in the strictest sense as this will mean that for policies the summaryNum will start from the next available sequence number, but what i really want is to have it start by one for all policies.*
    I would appreciate any help.
    Thanks,

    Not sure if there is a better way, but here is one way. Let's say your table was like this:
        SQL> desc versioned_item
         Name         Null?    Type
         ID           NOT NULL NUMBER
         VERSION      NOT NULL NUMBER
         DESCRIPTION           VARCHAR2(20)and lets say your data looked like this:
        SQL> select * from versioned_item order by id, version
                ID    VERSION DESCRIPTION
              1001          1 Item 1001
              1001          2 Item 1001
              1001          3 Item 1001
              1002          1 Item 1002
              1002          2 Item 1002
              1003          1 Item 1003To select only the rows for the max-version-id, you could do this:
        select id, version,description
        from versioned_item
        where (id,version) in (select id,max(version) from versioned_item group by id)
        order by id
                ID    VERSION DESCRIPTION
              1001          3 Item 1001
              1002          2 Item 1002
              1003          1 Item 1003To capture this as a view object, you'd only just need to paste in the WHERE clause above into the Where clause box of the view object. No need to use expert-mode since you're not changing the select list or from clause.

  • What are the UI components used in oracle adf?

    what are the UI components used in oracle adf?

    Web.:
    - ADF Faces and Trinidad JSF components
    http://docs.oracle.com/cd/E28280_01/apirefs.1111/e12419/toc.htm
    Desktop:
    - MS Excel
    http://www.oracle.com/technetwork/developer-tools/adf/overview/index-085534.html
    Mobile
    - AMX UI Components for Android and iOS
    Frank

  • How to use Sequence in Forms

    Hi,
    I have an Empno Column, At the time of Opening a Form The Empno Will be displayed by using Sequence.
    If the User doesn't save the Form Then the Empno Generated number will be changed.
    How to write the code to get sequence numbers at Empno columns by using Sequence?
    Thanks & Regards,
    Hari Babu

    Ok, I understand now your question. Since the oracle sequence is commited in a separate transaction, it is not possible to get the no-gap sequence, considering your example. In the other hand, if you don't commit immediately, than two concurrently opened forms could use the same sequence number, so you'll get the duplicate key!
    If you're sure that this couldn't happen, you can manage your own sequencing, storing them in another table. Let's say you reached seq 999: entering the form, you'll read from your sequence table 1000, increment to 1001, and assign it to empno, but without commiting. Next time, you'll get the same number, until you commit form, and at the same time, change in seq table. So another will get 1001.
    Downside of this approach are, as mentioned before, concurrent sessions, which will get the same sequence.

  • Comenting code - style - how to keep coments where you want them - without using sequences

    Silly question maybe about style of commenting.
    Basically i like to use sequence boxes to keep comments on my diagram beside the bits of code that they refere to - otherwise when you use diagram cleanup (which i'm afraid i use all the time) they go anywhere.  This is good - except that i found especially when doing FPGA programming the sequence boxes reduce the amount of parralelism that can go on - since the 'box' needs to finish before any of the outputs can be used.  Is there some other method i should be using instead of sequence boxes to keep text beside elements - without enforcing that a set of elements are fixed in one place?
    Solved!
    Go to Solution.

    I usually use labels of structures (loops, cases, etc) and labels of diagram constants, etc. for comments. In newer versions, we also have wire labels.
    (see also)
    What is your LabVIEW version? Also the LabVIEW 2011 cleanup does a better job keeping diagram comments together with the related code compared to earlier version.
    LabVIEW Champion . Do more with less code and in less time .

  • Using Facelets with ADF

    Hi,
    I am trying to use Facelets with ADF but unable to get the desired output i.e. the Facelet regions are not working as desired.
    My Jdeveloper version is:
    10.1.3.0.4(SU4)
    Please help me out as early as possible.
    Thank You.

    https://facelets.dev.java.net/nonav/docs/dev/docbook.html#taglib-available-adf

  • Using Sessions in ADF

    How can I use sessions in ADF? Is it same as using in JSF or is there any other specific way in ADF?
    Ravi

    Hi,
    It is same as JSF
    Samples:
    From bean;
                FacesContext context = FacesContext.getCurrentInstance();
                HttpSession session = (HttpSession)context.getExternalContext().getSession(true);From jspx
                #{sessionScope.variable_name}Sireesha

  • Error Using Sequence in Weblogic

    I tried to use Sequence object in weblogic to generate auto-imcremental integers
    for my db insert keys. I first create a mydbsequece in oracle database. Then,
    I built a class in which I obtain a dataSource using jndi to look for my dataSource.
    And then use the ds to getConnection. After I had the connection, I do the following:
    Sequence sequence = new Sequence(con, "mydbsequence");
    int i = sequence.nextValue();
    When I call sequence.nextValue() method, I got the following error message: NullPointerException
    at Weblogic.jdbc.rmi.SerialConnection.createStatement(SerialConnection.java:65).
    Does anyone know what causes this error? and How do I fix it? Please advise me
    on this. Thank you very much.
    Qin

    Qin Ding wrote:
    >
    I tried to use Sequence object in weblogic to generate auto-imcremental integers
    for my db insert keys. I first create a mydbsequece in oracle database. Then,
    I built a class in which I obtain a dataSource using jndi to look for my dataSource.
    And then use the ds to getConnection. After I had the connection, I do the following:
    Sequence sequence = new Sequence(con, "mydbsequence");
    int i = sequence.nextValue();
    When I call sequence.nextValue() method, I got the following error message: NullPointerException
    at Weblogic.jdbc.rmi.SerialConnection.createStatement(SerialConnection.java:65).
    Does anyone know what causes this error? and How do I fix it? Please advise me
    on this. Thank you very much.
    QinSequence is a non-standard JDBC object. It is an Oracle-specific class, which presumably
    takes a standard java.sql.Connection in it's constructor. Oracle has repeatedly created
    such new classes with methods claiming to take java.sql.* arguments, but in fact they
    require an Oracle-specific class. In this case, however, we might succeed anyway if
    we dig some. Can you show me the entire stacktrace of the exception?
    Please take the attached jar file, and put it in front of all the weblogic stuff
    in the server's classpath, and repeat the problem and show me the new exception.
    From the line, I am assuming you're on the 6.1 version of WebLogic. If not, forget the
    jar, and let me know.
    Joe
    [61rmicon.jar]

  • Using sequence  in view

    hi gurus
    SQL> create view v1 as select s1.nextval from dual;
    create view v1 as select s1.nextval from dual
    *+
    ERROR at line 1:
    ORA-02287: sequence number not allowed here
    Are there only workaround?
    Thank you!

    There are some restrictions on using sequences you will want to know about
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14231/views.htm#sthref3092

  • USING SEQUENCE IN PACKAGE SPEC

    I Want to Use Sequence.NEXTVAL & Sequence.CURRVAL throughout the package. How can i declare the global sequence variable and make them available for all the stored procedures inside the package ?
    Any help highly appreciated..
    Thank you all in advance

    Data Boy wrote:
    No i know that but using directly SEQUENCE.CURRVAL inside the Insert statement is not a good practice.
    We need to declare inside the procedure a variable and then fetch the SEQUENCE.CURRVAL into that variable
    and use that variable inside the insert statement. But we that variable scope will be available only inside that procedure.
    if i want the same CURRVAL in another stored procedure. How can i get it ..that is my Question.What exactly are you trying to achieve?
    If it's a case of needing to know the value of the sequence number assigned to an inserted record you would typically use the RETURNING clause on the insert statement...
    SQL> create table temp (id number, val varchar2(20));
    Table created.
    SQL> create sequence temp_seq;
    Sequence created.
    SQL> ed
    Wrote file afiedt.buf
      1  create trigger trg_temp before insert on temp
      2  for each row
      3  begin
      4    select temp_seq.nextval into :new.id from dual;
      5* end;
    SQL> /
    Trigger created.
    SQL> set serverout on
    SQL> declare
      2    v_num number;
      3  begin
      4    insert into temp (val) values ('Fred') returning id into v_num;
      5    dbms_output.put_line('ID inserted was: '||to_char(v_num));
      6  end;
      7  /
    ID inserted was: 1
    PL/SQL procedure successfully completed.
    SQL> select * from temp;
            ID VAL
             1 Fred
    SQL>

  • Using Sequence in ODI

    Hi I am very new to this tool can anyone tell me how to use sequence and populate Primary key in my Oracle target table. I am doing File to Oracle Mapping.
    I am using ODI sequence but i am getting errors like:
    933 : 42000 : java.sql.SQLException: ORA-00933: SQL command not properly ended
    and also delete previous check sum in Session Control
    Need ur reply asap

    Thnx Madha!
    I have change my KM to IKM SQL Control Append but the problem still persists.
    I am getting the same error message in the control workflow (~Operator Window).
    1] Control-<TGT_SECURITYSEGMENT_DIMENSION>-Create Check Table and also
    2] Control-< TGT_SECURITYSEGMENT_DIMENSION>-delete previous check sum
    The Description of the same is:
    create table Exception getObjectNameDefaultPSchema("L", "SNP_CHECK_TAB", "W") :
    CATALOG_NAME VARCHAR2(100 CHAR) NULL ,
    SCHEMA_NAME VARCHAR2(100 CHAR) NULL ,
    RESOURCE_NAME VARCHAR2(100 CHAR) NULL,
    FULL_RES_NAME VARCHAR2(100 CHAR) NULL,
    ERR_TYPE VARCHAR2(1 CHAR) NULL,
    ERR_MESS VARCHAR2(250 CHAR) NULL ,
    CHECK_DATE DATE NULL,
    ORIGIN VARCHAR2(100 CHAR) NULL,
    CONS_NAME VARCHAR2(35 CHAR) NULL,
    CONS_TYPE VARCHAR2(2 CHAR) NULL,
    ERR_COUNT NUMBER(10) NULL
    and error is :
    922 : 42000 : java.sql.SQLException: ORA-00922: missing or invalid option
    [Note: The above create table script is generated by CKM Oracle Knowledge Module].
    I am using CKM Oracle KM for the Primary key constraint in My target Oracle Table. I think the Problem is somewhere else.
    Please Help.

  • Using sequence in sqlldr

    hi
    can we use already existing db sequence in sqlldr control file
    regards
    kedar
    attached is control file but i want to use nextkey_seq to populate client_id
    LOAD DATA
    INFILE 'COMM.csv'
    APPEND
    INTO TABLE COMMUNITY_REGISTER
    FIELDS TERMINATED BY '~' OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    (CLIENT_ID,
    SURNAME,
    DATE_OF_BIRTH DATE "YYYYMMDD" ,
    SEX,
    DATE_LAST_UPDATED DATE "YYYYMMDD" ,
    CURRENT_STATUS,
    DATE_OF_CURRENT_STATUS DATE "YYYYMMDD" ,
    INITIAL_STATUS,
    DATE_OF_INITIAL_STATUS DATE "YYYYMMDD" ,
    GP,
    GPTYPE,
    LEAD_HCP,
    STAFF_TYPE,
    NHS_NUMBER,
    COMMUNITY_ID,
    MOTHERS_ID,
    PREVIOUS_SURNAME,
    FORENAME,
    TITLE,
    ALIAS,
    STREET_NO,
    STREET,
    LOCALITY,
    TOWN,
    COUNTY,
    POSTCODE,
    HEALTH_AUTHORITY,
    PHONE_NUMBER,
    INITIAL_SECTOR,
    CURRENT_SECTOR,
    REG_DISTRICT,
    OPCS_BIRTH,
    OPCS_RESIDENCE,
    ETHNIC_ORIGIN,
    CHANGED_BY_ID,
    CHILD_HEALTH_EXISTS,
    DIAGNOSES_EXISTS,
    TEXT_EXISTS,
    SPECIAL_NEEDS_EXISTS,
    ADMISSION_EXISTS,
    CHILD_PROTECTION_EXISTS,
    NEXT_OF_KIN_ID,
    NOK_RELATIONSHIP,
    NHS_TRACE_RESULT,
    PAS_NUMBER,
    REGISTRATION_ORIGIN,
    NBH_STATUS,
    SECTOR,
    MOBILE_NO,
    AUDIT_TIMESTAMP DATE "YYYYMMDD" ,
    AUDIT_ID,
    AUDIT_ORIGIN,
    TRANSFER_CHECKED,
    LAST_ACTION,
    RECORD_STATUS,
    TRACE_RESULT_DATE DATE "YYYYMMDD"
    )

    Kedar,
    You sure can use sequence nextkey_seq.nextval in your control file (don't remember the exact syntax, but you can find it in Utilities manual for SQL*Loader

  • How to use sequence in MS sql server?

    In Oracle DB we use sequence like that:
    SequenceImpl s = new SequenceImpl("customer_seq", getDBTransaction());
    Integer next = (Integer)s.getData();
    setId(new Number(next.intValue()));
    But there is no sequence in sql server ,how can I do?
    Thank you~~

    MS SQLServer have a IDENTITY column property and UNIQUEIDENTIFIER data type that is somewhat similar to Oracle's sequence. I don't know whether your table contain either of these, or you just want to set sequential number to a column.
    Below is some info about IDENTITY and UNIQUEIDENTIFIER you may already know since they are in SQLServer Book.
    IDENTITY property: You can define IDENTITY property on a numeric column. You can set the seed and increment on this column property very much like Oracle's sequence. The only thing I think it does not have is the "nextval". You can use IDENT_CURRENT function or @@IDENTITY after an INSERT or SELECT INTO to get the last value generated. Of course you can use this value and add the increment to get the next
    value but it not the same as seqname.nextval which keep incrementing each time you call it. Getting the current identity value and adding the increment your self will not work for multiple sessions with pending
    insert. Another thing about column with IDENTITY property is that you cannot insert value into this column (i.e, omit it in your insert statement values) unless IDENTITY_INSERT is on, but only one table in a
    session can have IDENTITY_INSERT to be turned on.
    If you don't need to know the next seq value, then IDENTITY work similar to Oracle sequence. Execute select after postchanges or commit will have system generated values. If you need to get next value before insert, Sung suggest using SEQ_TABLE and managing the next value (write a database function to mimic Oracle'
    s nextval).
    UNIQUEIDENTIFIER datatype: UNIQUEIDENTIFIER is a 16-byte hexadecimal number indicating a globally unique identifier (GUID). The GUID is useful when a row must be unique among many other rows. You could use NEWID() to create a value of type uniqueidentifier or calling some API function that returns a GUID. The advantage of using uniqueidentifier is that the values generated by NEWID function or application GUID are guaranteed to be unique throughout the world. The disadvantage of using uniqueidetifier is that it is long and obscure, random, difficult for user to remember or type correctly. It is 16 byte, which is large compare to other datatype such as 4-byte integer.
    Thanks,
    Yvonne

  • How to Use Sequence in Oracle Views

    Hi ,
    I have created a view which gives the information about the access rights which a Resource has got. for ex -
    Res1 - GYM access - member
    Res1 - Swimingpool Access - member
    I need to identify a Primary Key for this data set. So i thought that i'll use a Sequence to generate an extra column in this view.
    But when i'm using the Sequence i'm getting the following error - "ORA-02287".

    you can use sequence within view it doesnot returned error;
    create sequence t1_seq MAXVALUE 150
    START WITH 39 INCREMENT BY 1;
    SQL> insert into t1_view values(t1_seq.nextval,'dd');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t1;
    ID NA
    10 aa
    20 bb
    30 cc
    40 dd
    4 rows selected.
    SQL> insert into t1_view values(t1_seq.nextval,'ee');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from t1;
    ID NA
    10 aa
    20 bb
    30 cc
    40 dd
    41 ee
    5 rows selected.

Maybe you are looking for