4 Replies Latest reply on Nov 12, 2012 10:23 PM by codigoadf

    pb Insertion DBSequence value  programmatically


      I try to insert a record that have a DBSequence Primary key programmatically ,

      so I create a method in AppModuleImp
      public oracle.jbo.domain.Number getDBSequencenumber(String sequenceName){
      oracle.jbo.server.SequenceImpl theSeq = new oracle.jbo.server.SequenceImpl(sequenceName, getDBTransaction());
      oracle.jbo.domain.Number seqNextNumber = theSeq.getSequenceNumber();
      return seqNextNumber;
      catch (Exception e){
      //handle exceptions
      return null;

      after that I initiate it in a bean,

      public oracle.jbo.domain.Number getNextBonSRTSequenceNumber() {
      BindingContext bindingContext = BindingContext.getCurrent();
      BindingContainer bindings = bindingContext.getCurrentBindingsEntry();
      OperationBinding getNextSequence = bindings.getOperationBinding("getDBSequencenumber");
      getNextSequence.getParamsMap().put("sequenceName", "OFFRE_SEQ");
      oracle.jbo.domain.Number seqVal = (oracle.jbo.domain.Number)getNextSequence.execute();
      return seqVal;

      and in my ViewRowImp Class I have a method that accept the sequence value and use setter method :

      public void convertQuoteToSale(oracle.jbo.domain.Number vcdsrt) {

      DBSequence seqcdSRT = new DBSequence((oracle.jbo.domain.Number)vcdsrt);

      // insert data


      public void createBonSRT(DBSequence seqcdSRT) {

      EntityDefImpl bonSrtDef = BonSrtImpl.getDefinitionObject();
      BonSrtImpl newBonSRT = (BonSrtImpl)bonSrtDef.createInstance2(getDBTransaction(), null);



      try {
      } catch (Exception e) {


      in the last bold text mark the value of the sequence is for example 30 and it's correct  but the value inserted in the database was different !!!!

      I don't know why the value inserted was different.

      in my case i have to insert other data that depend on this primary key

      thank for helping me