Generate the primary key  automatically while records are saved

Hi experts,
I need to generate the primary key of a custom table automatically when a new record is saved. Pleas help asap. Urgent.

Hi Rob and vikas,
   Thanks for your answers . Both of the solutions you mentioned were syntactically correct and activated but they are not populating the numbers.In case of Rob's soultion  I guess I am not able to catch the return number. I am giving the code below. So Please look into it,
FORM gen_manu_siteid .
data : number type zsiteid value 155.
CALL FUNCTION 'NUMBER_GET_NEXT'
  EXPORTING
    NR_RANGE_NR                   = '02'
    OBJECT                        = 'zmanusite'
    QUANTITY                      = '1'
  SUBOBJECT                     = ' '
  TOYEAR                        = '0000'
  IGNORE_BUFFER                 = ' '
  IMPORTING
    NUMBER                        = number
  QUANTITY                      =
  RETURNCODE                    =
EXCEPTIONS
  INTERVAL_NOT_FOUND            = 1
  NUMBER_RANGE_NOT_INTERN       = 2
  OBJECT_NOT_FOUND              = 3
  QUANTITY_IS_0                 = 4
  QUANTITY_IS_NOT_1             = 5
  INTERVAL_OVERFLOW             = 6
  BUFFER_OVERFLOW               = 7
  OTHERS                        = 8
*IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
ztblqm_sqm-zsiteid = number .
ENDFORM.                    " gen_manu_siteid
When this did not work. i tried Vikas's soution and the code i used for this is
FORM gen_manu_siteid .
data : w_count like ztblqm_sqm-zsiteid,
       e_wa like ztblqm_sqm occurs 0 with header line.
select max( zsiteid ) from ztblqm_sqm into w_count .
w_count = w_count + 1.
e_wa-zsiteid = w_count.
modify ztblqm_sqm  from e_wa.
ENDFORM.                    " gen_manu_siteid
Please look into this and give me a solution.
NB: I have tried them at the event 01 include.

Similar Messages

  • How to generate the primary key item automatically in form region?.

    Hi,
    The primary key item is generated automatically in report region.I already give the pl/sql function for generating of primary key.but I want to generate the primary key value automatically in form region only?.how to do this?.Pls help me..
    Thanks and Regards.

    One of the guidelines when selecting column for a primary key is:
    Choose a column whose data values are never changed. A primary key value is only used to identify a row in the table, and its data should never be used for any other purpose. Therefore, primary key values should rarely or never be changed.
    Cheers!

  • Problem in generating the Primary Key

    Hi All ,
    I am trying to persist an object and also generating the primary key using a default sequence . But the problem is that the Primary key is getting incremented by 2 instead of 1 . My code looks like this :
    import java.util.HashMap;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.EntityTransaction;
    import javax.persistence.Persistence;
    import javax.persistence.PersistenceContext;
    import javax.persistence.PersistenceContextType;
    import javax.persistence.PersistenceUnit;
    public class entityCaller {
    //     @PersistenceContext(unitName="testApp" ,type=PersistenceContextType.EXTENDED)
         EntityManager em;
    //     @PersistenceUnit(unitName="testApp")
         EntityManagerFactory emf ;
         public void persistEntity( String Name , int Age ) {
              EntityManagerFactory emf =
              Persistence.createEntityManagerFactory("testApp", new HashMap());
              em = emf.createEntityManager();
              EntityTransaction entityTransaction = em.getTransaction();
         Tab1 oBJTab1 = new Tab1();
    //      oBJTab1.setId(Age);
         oBJTab1.setVal(Name);
              try{
                   System.out.println("Making object");
                   em.persist(oBJTab1);
                   System.out.println("Done");
                   System.out.println("Making object2");
                   System.out.println("Entered the Values");
              }catch (Exception e) {
                   e.printStackTrace();
              }finally{
              em.close();
         public static void main(String[] args) {
              entityCaller caller = new entityCaller();
              caller.persistEntity("DoAgain7",2);
    My persistence.xml looks like this :
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    <persistence-unit name="testApp">
    <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
    <class>Tab1</class>
    <!-- <jta-data-source>java:/XAOracleDS</jta-data-source>     -->
    <properties>
    <!-- Provider-specific connection properties -->
    <property name="toplink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="toplink.jdbc.url" value="jdbc:oracle:thin:@127.0.0.1:1521:XE"/>
    <property name="toplink.jdbc.user" value="system"/>
    <property name="toplink.jdbc.password" value="jlkklkj"/>
    <!-- Provider-specific settings -->
    <!-- other values are: drop-and-create-tables|none -->
    </properties>
    </persistence-unit>
    </persistence>
    Please provide me with some pointer as to know where the things are going wrong.

    If you generated your original schema using toplink.ddl-generation, then later dropped it and created it then you should keep in mind the sequence table does not get dropped. This can lead to an initially 'empty' database with a PK sequence starting at '2' if you have one persistence unit and one entity. Can you steadily duplicate this or did you just notice that your persist started with an key of '2'? Just a thought.

  • If I have an EntityBean that mappes to two tables within one database, when I create that EJB, whoes reponsibilty to generate the primary key in database table? The RDBMS or EJB?

    If I have an EntityBean that mappes to two tables within one database, when I create
    that EJB, whoes reponsibilty to generate the primary key in database table? The
    RDBMS or EJB?
    Thanks,
    JW

    Refer to http://e-docs.bea.com/wls/docs81/faq/ejb.html/#257430
    "Jingwei Zhang" <[email protected]> wrote:
    >
    If I have an EntityBean that mappes to two tables within one database,
    when I create
    that EJB, whoes reponsibilty to generate the primary key in database
    table? The
    RDBMS or EJB?
    Thanks,
    JW

  • Auto generate the primary key value for eah valid insertion

    i have a table EMP having emp_id, name and age.
    EMP;
    E1 John 23
    E2 Mary 25
    created a form/report page on the table. the report page displays all the columns. while creating new entry, the emp_is hidden and the name , age are displayed. on successful insertion the emp_id is populated with 1 rather then E3.
    1 Rick 22
    E1 John 23
    E2 Mary 25
    how do i ensure that the new row inserted has a value E3 and the subsequent entries, emp_id is incremented by next sequence.

    If your emp_id is not numeric and needs to be 'E' + sequence then you need to delete the existing trigger and create a new one like this:
    CREATE OR REPLACE TRIGGER emp_bi_trg
       BEFORE INSERT
       ON emp
       FOR EACH ROW
    BEGIN
       IF :NEW.emp_id IS NULL
       THEN
          SELECT 'E' || emp_seq.NEXTVAL
            INTO :NEW.emp_id
            FROM DUAL;
       END IF;
    END;
    /Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    ------------------------------------------------------------------------------

  • Insert record and return the primary key

    Okay, I need to insert a record into a MSSQL database and return the primary key of that record. Im using the following code which is obviously wrong as I'm getting either 'NULL' or 'com.microsoft.jdbc.base.BaseResultSet@1d520c4' returned depending on the ways I've tried. The primary key is an int value called clientID which is incremented by one each time a new record is added.
    // set the prepared statement
                String sql="INSERT INTO Client(username, country, clientIP, browser, os) VALUES(?,?,?,?,?)";
                PreparedStatement pstmt = conn.prepareStatement(sql);
                pstmt.setString(1, inUserName);
                pstmt.setString(2, inCountry);
                pstmt.setString(3, inClientIP);
                pstmt.setString(4, inBrowser);
                pstmt.setString(5, inOS);
                // Insert the row
                pstmt.executeUpdate();
                Statement stmt = conn.createStatement();
                ResultSet rs = stmt.executeQuery("SELECT SCOPE_IDENTITY()");
                System.out.println("Result "+rs);The primary key value is needed so that it can be used as a foregin key in another table. Am I going about this the correct way? Any help, pointers or code fixing would be appreciated.....

    Yes. I tried this way but I only ever get the answer
    of 0 when i print our the result! Not really sure
    whats happening.That's because you don't print a ResultSet like that. In order to get the key out, you have to do this:
    int key = 0;
    while (rs.next())
        key = rs.getInt(1);What were you thinking with your code?
    You might want to do this in a transaction. If the INSERT fails, you'll want to roll back.
    The "select @@identity" is correct for M$ Access, SQL Server, and Sybase. I believe it's also correct for MySQL, but I'm not 100% certain of that.
    %

  • Error while creating the Unique Index of the Primary Key of an Item

    Hi all,
    I have deployed a new item (CO_CONTRACTUNIT_PRODUCT) in my publication. The deploy appears to be successfull as the item can be seen in the repository through the Mobile Manager.
    The problem occurs when i sync my local DB to get the item offline. While synchronizing, the following error appears, both in the sync window and the log file ol_sync.log.
    "ERROR",POL-5130,"11/09/2010 11:43:52","table or view %s.%s not found:CO_CONTRACTUNIT_PRODUCT,CO_CONTRACTID,OD_PRODUCTID,CO_CONTRACTUNITID","DB_ROSHNI"
    However, the debug file gives this other error regarding this table.
    ALL_INDEX:CREATE UNIQUE INDEX "TPCO_CONTRACTUNIT_PRODUCT_PK" ON CO_CONTRACTUNIT_PRODUCT (CO_CONTRACTID,OD_PRODUCTID,CO_CONTRACTUNITID) -5130Error at C:\ADE\omeprod_ol103021\olite\db\build\win\ocapi\..\..\..\src\ocapi\allindexes.cpp line:329 rc:-5130
    Build date Mar 29 2010
    okErr=(table or view %s.%s not found)
    mess=(CO_CONTRACTUNIT_PRODUCT,CO_CONTRACTID,OD_PRODUCTID,CO_CONTRACTUNITID)
    AddLog(-5130 "ERROR",POL-5130,"11/09/2010 11:43:52","table or view %s.%s not found:CO_CONTRACTUNIT_PRODUCT,CO_CONTRACTID,OD_PRODUCTID,CO_CONTRACTUNITID","DB_ROSHNI")
    But the index that is being created and is giving the error is the index created automatically with the Primary Key of the table, and so nothing has been modified in that.
    The primary key of the table is created with the three columns that are part of the index that is returning the error.
    As I could not solve the error, I tried to drop and re-create the item in the repository, but no luck. As a last option, i tried to remove the item from the repository to be able to sync properly again (just like before creating the item), but the error still happens.
    Another weird point is that i have tried creating the item in another publication of another database (but with almost equal items), and the item could was downloaded to my local DB without any problem, which makes this problem still more bizarre.
    What can it be?
    Any help would be great!
    Roshni

    have you tried unistalling the client and reinstalling it?
    schema evolution changes are not always handled correctly please check thread:
    Modification of publication item into Mobile Server
    i quote from rekounas instructions:
    If you are just adding a field, you should only have to run the alter publication item API call.
    Here is an old note on schema evolution on different scenarios. The names for the APIs that they use are now deprecated. Use the ConsolidatorManager class and call the method alterPublicationItem("PUBLICATION_ITEM_NAME", "SELECT STMT") :
    A) Add column
    1. Upload all client data. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Change the Oracle8i/9i database schema (add column)
    4. Create a Java program to call the Consolidator Admin API AlterPublicationItem()
    5. Start Mobile Server
    6. Execute a sync from the client
    7. The new column should be seen on the client. Use MSQL to check snapshot definitions.
    B) Drop column
    1. Upload all client data. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Delete column of the base table in the Oracle database schema
    4. Create a Java program to call the Consolidator Admin API DropPublicationItem()
    5. Create a Java program to call the Consolidator Admin API CreatePublicationItem() and AddPublicationItem().
    6. Start Mobile Server
    7. Execute a sync from the client
    8. The new column should be seen on the cliet. Use MSQL to check snapshot definitions.
    C) Change column datatype
    Changing datatypes in a repliatated system is not an easy task. You have to follow certain procedures in order to make it to work. Use DropPublicationItem, CreatePublicationItem and AddPublicationItem methods from the Consolidator Admin API. You must stop/start Mobile Server listener to refresh the cache.
    1. Client syncs. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Drop/create column (do not use conversion procudures) at the base table
    4. Call DropPublicationItem(). Check if the ErrorQueue and InQueue no longer exist.
    5. Call CreatePublicationItem() and AddPublicationItem(). Check if the ErrorQueue and InQueue reflect the new column datatype
    6. Start Mobile Server. This automatically resumes application
    7. Client executes sync. This should drop the old snapshot and recreate the new snapshot. Use MSQL to check
    snapshot definitions.
    D) Drop table
    1. Client syncs. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Drop base table
    4. Call DropPublicationItem(). Check if the ErrorQueue and InQueue no longer exist.
    5. Start Mobile Server. This automatically resumes application
    6. Client executes sync. This should drop the old snapshot. Use MSQL to check snapshot definitions.
    E) Add table
    1. Client syncs. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Add new base table
    4. Call CreatePublicationItem() and AddPublicationItem() method
    5. Start Mobile Server. This automatically resumes application
    6. Client executes sync. This should add the new snapshot. Use MSQL to check snapshot definitions.
    F) Changing Primary Keys
    Chaning PK is a severe operation which must be executed manually. A snapshot must be deleted and recreated to propagate the changes to the clients. This causes a full refresh on this snapshot.
    1. Client syncs. Clients should not add new data until they are told by the administrator to sync again!!
    2. Stop Mobile Server listener
    3. Drop the snapshot using DropPublicationItem() method o
    4. Alter the base table
    5. Call CreatePublicationItem()and AddPublicationItem() methods for the altered table
    6. Start Mobile Server. This automatically resumes application
    7. Client executes sync. The old snapshot will be replaced by the new snapstot using a full refresh. Use MSQL to check snapshot definitions.
    G) To Change a Table Weight =>
    Follow the procedure below to change the Table Weight parameter. The table weight is used by the Mobile Server/Synchronization to determin the sequence in which client records are applied to the Oracle database.
    1. Run MGP to apply any changes in the InQueue to the Oracle databse
    2. Change table weight using SetTemplateItemMetadata() method
    3. Add/change constraint on the the base table which reflects the change in table weight
    4. Synchronize
    gl m8

  • Generate  primary key automatically

    Hi, I'd like to know how to generate primary keys automatically with JHeadStart because when I try to make an insert into a table, the page gives me the option of insert the primary key of the register.
    Thanks a lot

    I have a table which have 2 fields, one of those is the primary key, the other is the description.
    I have established the primary key as a DBSequence, but when I try to insert a new record testing the service, appears a negative number in the primary key and instead of that I want to appear the correspondent key, or if doesn't appear the correct value, the insert be done correctly.
    At least I change manually the value if this key, the insert can't be done.

  • Knowing the Primary Key Sequence Generator of a table

    Hello All,
    I'm working on an application that uses Oracle toplinks/JPA for persistence. The entity classes in the application have primary key fields with annotations @Id and @GeneratedValue(strategy = GenerationType.AUTO). Per our understanding, this means the primary key generation is done by JPA/Top-links. When we see our database, we notice only one SEQUENCE table available and that table has only one row, while in the application, we are getting different sequence numbers for the primary key of each entity. So, not clear on how this sequence number is generated. Could anybody share information on where the sequence number is stored for each entity/table? Really appreciate your help here. Our database is MSSQL.
    Thank you,
    Venkatesh

    EclipseLink/TopLink uses Table sequencing for GenerationType.AUTO because it is more portable between databases. My understanding of your issue is from
    http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Table_sequencing
    Each row in the table represents one sequence generator, and your entities are all using the same default sequence generator and so all use the same row.
    To use multiple rows I believe you need to define multiple TableGenerators.
    Best Regards,
    Chris

  • Problem in universe while joining as the primary key is NUMBER

    Hi,
    I'm trying to join TEST.SUMMARY.NUMBER to TEST.RESPONSE.FOREIGN_KEY. The problem arises from the first of these, as the primary key is in a column NUMBER. Stupid? Definitely. Rename? Not an option.
    I think NUMBER is seen as a magic word (type), and once parsing (for example in "edit join", I get the message "Exception: DBD, ORA-01747: invalid user.table.column, table.column, or column specification State: N/A" .
    Normally putting " around the word would do the trick ("NUMBER"), but is seems universe designer removes those during the parsing (?). I come to this conclusion, because if I choose the join line from the graphical menu, and then write to the function line TEST.SUMMARY."NUMBER"=TEST.RESPONSE.FOREIGN_KEY (and press enter), the " are removed. (To get the NUMBER's to the report is good, though, by creating a variable with TEST.SUMMARY."NUMBER")
    The database is oracle, and universe is on BusinessObjecs XI 3.1.  I've tried to join in the edit join, create a derived table and use ANSI92. No good so far. I also tried to join the fields on report (WebI), but the result was always too many or not enough data from one of the tables. Merging dimensions leads to other problems. I was checking on JOIN_BY_SQL as well as PARSE_SELECT_IN_JOIN in universe parameters, but at glance I didn't find how to solve this with them.
    Any ways to force the join, or achieve the data from the both tables in one report table otherwise?

    Well, I managed to sort this out somehow by using custom SQL in the Web Intelligence report, and joining the tables there with
    LEFT JOIN TEST.RESPONSE
    ON TEST.SUMMARY."NUMBER"=TEST.RESPONSE.FOREIGN_KEY
    Smells like duck tape, but it's  working at least somehow. I guess the custom SQL is passed to some lower level, and so the universe-automatic-whatever doesn't handle it in the fly.
    Any other ideas?

  • DBMS_CDC find only the columns that are changed along with the primary key in the table

    Hello,
    We are having a requirement to find the change data in the production environment.
    We are planning to use the DBMS_CDC utility.
    But for  example in the create change table 1 picked emp_id,ename, address, salary,dob.
    I have a sample data of
    empid
    ename
    address
    salary
    DOB
    1
    test1
    24 test street
    2000
    20-Jan-98
    2
    test2
    25 test street
    2500
    15-Aug-97
    if ename for empid 1 is changed to test1_test3 from test1.
    My CDC is capturing  the values in the old and new values in the 5 columns.
    But i need to get only the empid (primary key of the source table) and the ename column as only that's been updated not the rest of the 3 columns.
    Can i accomplish this.
    Please advice.

    Hello,
    Thanks for the information.
    but if i change the change table  then i will miss the other columns right?
    I want to get the columns( empid and ename) only if ename is changed. i.e when ever any column in emp table changes i need to get all the columns where the data is changed along with the primary key columns empid.
    Is there any way i can tweak the parameters so that i can achieve this or is there any other way using the cdc i can get this data.
    Thanks

  • How to khow how many foreign key are referenceing the primary key

    sir i would like to know that how many foreign key are referencing the primary key of a table
    is any command to know the table name
    please suggest
    thanks in advance..

    In the query below, table_name is the name of the table whose primary key is referenced.
    SELECT b.owner owner
    ,b.constraint_name foreign_key
    ,b.constraint_type constraint_type
    ,b.table_name referencing_table
    ,b.r_constraint_name primary_key
    ,c.table_name referenced_table
    ,c.column_name referenced_column
    FROM all_constraints a
    ,all_constraints b
    ,all_cons_columns c
    WHERE a.owner = b.owner
    AND a.table_name = :table_name
    AND a.constraint_type = 'P'
    AND b.r_constraint_name = a.constraint_name
    AND b.constraint_type = 'R'
    AND c.constraint_name = a.constraint_name
    AND c.owner = a.owner;
    If the name of the primary key is known, the query below
    select * from all_constraints where constraint_type = 'R' and r_constraint_name = :pk_name

  • Populate the foreign key automatically

    HI All!
    I have a form in which there are two data blocks One is emp_master and other is salary_details.I have a foreign key salary_code in Emp_master and similarly Salary_code as primary key in salary details.I have used two list item in place of Emp_id and Salary_code.I want that when I select the emp_id as 10 from the list automatically salary_code list item should get populated by 1 item in the list item.Similary the rest should follow .Please someone look into this matter it would be a gr8t help to me.
    Thanks

    Abha,
    I would not use list items for this. Instead, use a multi-record text box with a scroll bar. It looks and behaves like a t-list, but is much easier to code and manage.
    Use the datablock wizard to create the master-detail relationship. When you use the wizard, all the code will be generated for you. Then use the layout wizard, and display multiple records with scroll bars.
    BTW, it is customary to have the primary key in the master, and the foreign key in the details. In your case it is backwards.
    Also see
    http://www.oracle.com/technology/obe/obe_as_10g/bi/forms/formsmasterdetailobe.htm

  • Does JDBC insert a value into the Primary Key?

    Hi,
    I'm using a servlet to input data froma n html form ,into an ACCESS Database.I'm using SQL statements i t he servlet ,and i'm confronted with the question:
    ALL database records are indexed with B_ID as the "Primary Key".
    I want to know: If I add the fields without a B_ID ..will SQL/JDBC/Access automatically add one for me?
    Or must I create the system that will count the records before adding a new B_ID?
    Hope you can help me.Thanks!
    Aesh83

    Access has a datatype claus for this autoincrement feature.
    I just can't remember its name.
    If you have such a primary key column in your table, you would simply insert values in each column except that, so this would automatically generate its value by incrementing the key.
    Your INSERT had to enumerate all columns you explicitely fill with values and skip this key column and those ones which shall be set to NULL btw. the defined default value (is there a DEFAULT clause in Access?)

  • Too many objects match the primary key oracle.jbo.Key

    Hi OAF Gurus,
    Currently we are implementing R12 Upgrade , for this we have deployed all the custom OAF Application related files on to the the respective JAVA_TOP folder.
    We have a custom municipal postal application which tracks the Postal Details.
    The page runs perfectly fine without any error in 11i instance, but the same is erroring out In R12.
    In R12 it shows an error as Too many objects match the primary key oracle.jbo.Key[112010 2014-10-01]
    here 112010 is nothing but the postal code id and 2014-10-01 is the Effective Start Date
    We have a custom table as xxad_postal_codes_f  (Date Track table)which contains the postal_code_id and effective_start_date (primary key is combination of postal_code_id and effective_start_date ).
    The Table already contains a row for postal_code_id = 112010  and Effective_Start_date = Sysdate.
    Now we want to update the entry for the same postal code with the Id being same as 112010  and  Effective_Start_date as 2014-10-01 through custom PostCodeChangePG
    at the time of save we are getting an error as Too many objects match the primary key oracle.jbo.Key[112010 2014-10-01]
    The table doesn't contain any of the data mentioned ([112010 2014-10-01]) at the time of insertion, hence there should not be any duplication of primary key but still we are getting the error.
    Please let us know how can we handle this..?
    Below is the code which is getting called on Click of Save button of PostCodeChangePG
    if (pageContext.getParameter("Apply") != null)
          PCodeCoWorkerBase coWorker = getCoWorker(pageContext, webBean);
              coWorker.processApply();
    Code in PCodeCoWorkerBase
        public void processApply()
          String postalCodeId = UIHelper.getRequiredParameter(pageContext, "postalCodeId");
          Date startDate = UIHelper.getRequiredDateParameter(pageContext , "EffectiveStartDate");
         Serializable[] postalCodeData = (Serializable[]) applicationModule.invokeMethod( "insertPostalCodeMajorChange", params, paramTypes );
          finalizeTransactionAndRedirect( postalCodeData );
    Code in Application Module
      public Serializable[] insertPostalCodeMajorChange ( String postalCodeId, Date date )
        PCodeAmWorker amWorker = new PCodeAmWorker(this);
        return amWorker.insertMajorChange( postalCodeId, DateHelper.convertClientToServerDate( getOADBTransaction(), date )
    Code in PCodeAmWorker
      public Serializable[] insertMajorChange ( String postalCodeId, Date date )
        // Get the view objects we need from the application module
        OAViewObject viewObject = (OAViewObject) applicationModule.getPCodesVO();
        PCodesVORowImpl currentRow = (PCodesVORowImpl) viewObject.getCurrentRow();
        currentRow.validate();
        currentRow.setEffectiveStartDate(date);
        currentRow.setComment1(currentRow.getNewComment());
    // Create a new row based on the current row
    PCodesVORowImpl newRow = (PCodesVORowImpl) viewObject.createAndInitRow(currentRow); //This is failing out and gives the error
    // Get the new effective start date as entered by the user
    Date effectiveStartDate = currentRow.getEffectiveStartDate();
        // Calculate the previous period's effective end date
        Date previousEffectiveEndDate = DateHelper.addDays(effectiveStartDate, -1);
        // Refresh the current row (the one changed by the UI) with the data it had at the beginning of the transaction
        currentRow.refresh(Row.REFRESH_UNDO_CHANGES);
        // The current row will now represent data for the the previous period set the effective end date for the previous period
        currentRow.setEffectiveEndDate(previousEffectiveEndDate);
        // Insert the newly created row that now represents the new period
        viewObject.insertRow(newRow);
        applicationModule.apply();
        return generateResult(newRow);
    PCodesVO() is based on PostalCodeEO
    below is the code from PostalCodeEOImpl
      public void create(AttributeList attributeList)
        // NOTE: This call will set attribute values if the entity object  is created with a call to vo.createAndInitRow(..)
        super.create(attributeList);
        if (getPostalCodeId() == null)
          setPostalCodeId(getOADBTransaction().getSequenceValue("XXAD_POSTAL_CODES_S"));
        if (getEffectiveStartDate() == null)
          setEffectiveStartDate(getOADBTransaction().getCurrentDBDate());
    After diagnosing the issue we found that the error is on the code of AMworker file while creating a new row PCodesVORowImpl newRow = (PCodesVORowImpl) viewObject.createAndInitRow(currentRow);
    we tried so many things such as clearing entity cache, VO cache, validating for duplicate primary key but still not able to resolved this.
    Please advice how to insert a new row on the PCodesVORowImpl without any exception.
    Thanks,
    Pallavi

    Hi ,
    One question here , if you are udating a existing record then why you are trying to create a new row
    PCodesVORowImpl newRow = (PCodesVORowImpl) viewObject.createAndInitRow(currentRow);
    Thanks
    Pratap

Maybe you are looking for

  • Table Column Header Text - Refresh Table

    Hi. A question about programmatically changing the Header Text property of a Table Component. I've added code, in the backing bean Setter for the Table component, to change the header text as required. The problem is that when the page is rendered, t

  • Setting up a Time Capsule for the first time and replacing it with an existing Router

    Hey there, I have got a new TC which I will be setting it up for the first time. I have a very old beetle router. I would be using the TC as a wireless hard drive and also as my WiFi Router. After reading the setup guide, I am confused about which op

  • Re linking Media

    I have FCP 6.04 I am trying to relink media, I have a lot of media to relink and I can only relink one at a time. I have to highlight the clip and select relink to get it to work. How can I just select the entire timeline and select re link media? I

  • Photoshop CC Not Remebering Brush Preset Color

    Hi everyone, im having an issue with CC with my brush presets not remembering the color.  I've created 4 brush presets (see pics for settings) of which i checked on the "Include Color" to include the default black & white for every brush preset. asid

  • Export outpus area issues in MX!

    Hi there I have designed some logos for a client and he needs them as JPGs and TIFF files as finished art. when I export them as that format...the finished file is cropped perilously close to the edges of the logo - so I need a wider crop. I have use