Menu

db sequence value insert

Help
ann
2004-12-08
2013-06-03
  • ann

    ann - 2004-12-08

    Hello,

    Can someone tell me how to insert a value into <db:textField >
    that is created in DB.
    I have a transactions ID, that is unique and is generated
    in oracle DB as sequence.

    <db:textField size="1" overrideValue=TXN_ID.nextval hidden="true" fieldName="TXN_ID"/>

    above does not work

    thank you in advance

     
    • Henner Kollmann

      Henner Kollmann - 2004-12-09

      You need an interceptor to do this.

      Please ask your questions in the mailing list so that more  people can help you!

      Thanks
      Henner

       
    • ann

      ann - 2004-12-09

      Can you please point me where and how to do that,
      i can see lists only in read-only mode?

       
      • Henner Kollmann

        Henner Kollmann - 2004-12-09

        Have a look at the documentation and the bookstore example.
        See the BookstoreInsertDataInterceptor class for an example.

        Henner

         
        • soniasr

          soniasr - 2007-11-30

          Hello,
          I have the same problem.
          Using an interceptor like the BookstoreInsertDataInterceptor I'm receiving the next error:
          Error:

              * Field GEN_ID should be calculated by RDBMS, remove it from the form

          In my form (in the jsp) I have this line: <db:textField fieldName="GEN_ID" hidden="true"></db:textField>
          and the interceptor is very simple:
          public int preInsert(HttpServletRequest request, Table table, FieldValues fieldValues,DbFormsConfig config, Connection con) throws ValidationException {
                  long id = 8;
                  setValue(table, fieldValues, "GEN_ID", String.valueOf(id));
                 
                  return GRANT_OPERATION;
              }

          (8 is the nextval of the sequence)

          What I'm doing wrong?

          Thanks in advance,
          Sonia

           
    • David Horkoff

      David Horkoff - 2008-02-06

      I believe that if you are using something like an Oracle sequence generator to generate your primary key then you should not have your field "GEN_ID" set as autoInc="true" in your dbforms-config.xml file. This is only for use if you are using an auto-id field such as is available in MS SQLServer or MySQL.

      Your interceptor code looks fine.

       

Log in to post a comment.

MongoDB Logo MongoDB