title: using sequence in namedparameterJDBCTemplate for insertion into two tables
body: <p>how to use sequence in namedparameterJDBCTemplate for insertion into two tables ?
      Database- orcale
      springjdbcnamedparametertemplate .</p>
  
  <p>my Dao is looking like this  </p>
  
  <pre><code>@Override
      public void insert(Message message) {
          String SQL = "INSERT into mssg (mssg_id, mssg_text, mssg_channel)"
                  + " values (mssg_sequence.nextval,:mssg_text,:mssg_channel)";
  
          String SQLMessage_app = "INSERT into message_app(mssg_app_type,mssg_id)"
                  + "values(:mssg_app_type,mssg_sequence.currval)";
          namedParameterJdbcTemplate.update(SQL,
                  new BeanPropertySqlParameterSource(message));
          namedParameterJdbcTemplate.update(SQLMessage_app,
                  new BeanPropertySqlParameterSource(message));
      }
  </code></pre>
  
  <p>oracle  tables are these </p>
  
  <p>This is the first  table</p>
  
  <pre><code>create table mssg (
  mssg_id number(10) NOT NULL,
  mssg_text varchar2(25)NOT NULL,
  mssg_channel varchar(25)NOT NULL,
  constraint pk_mssg_id PRIMARY KEY(mssg_id)
  );
  
  Create sequence mssg_sequence
  start with 1
  increment by 1
  minvalue 1
  maxvalue 100000;
  </code></pre>
  
  <p>This is the second table </p>
  
  <pre><code>CREATE TABLE MESSAGE_APP( 
  mssg_app_type VARCHAR2(25),
  mssg_id NUMBER(10),
  CONSTRAINT fk_mssg
      FOREIGN KEY(mssg_id)
      REFERENCES mssg(mssg_id)
      ON DELETE CASCADE);
  COMMIT;
  </code></pre>
  
  <p>iam getting this error :</p>
  
  <blockquote>
    <p>org.springframework.jdbc.UncategorizedSQLException:
    PreparedStatementCallback; uncategorized SQLException for SQL [INSERT
    into
    message_app(mssg_app_type,mssg_id)values(?,mssg_sequence.currval)];
    SQL state [72000]; error code [8002]; ORA-08002: sequence
    MSSG_SEQUENCE.CURRVAL is not yet defined in this session ; nested
    exception is java.sql.SQLException: ORA-08002: sequence
    MSSG_SEQUENCE.CURRVAL is not yet defined in this session</p>
  </blockquote>
  
  <p>can anybody help me to insert data into two tables by using sequence???</p>
  
  <p>Thanks in advance :)</p>