1

I can run the following statement in SQL Plus

CREATE OR REPLACE TRIGGER TEST.RECORD_TABLE.BIR
BEFORE INSERT ON TEST.CURRENT_VACANCIES
FOR EACH ROW WHEN (new.VACANCY_ID IS NULL)
BEGIN 
   SELECT TEST.CURRENT_VACANCIES_SEQ.NEXTVAL INTO :new.VACANCY_ID FROM dual; 
END;

and it woks perfectly.

However, when I try to call it from a prepared statement in a Java App I get the following error

SQL Exception;java.sql.SQLException: Missing IN or OUT parameter at index:: 1

Has anybody got any ideas?

Thanks

1
  • You're trying to create the trigger from within the Java application? Why would you want to do that? Without seeing your code, I would guess that it's interpreting :new as a bind variable, which seems odd as those are usually ? in a prepared statement. Commented Jun 21, 2012 at 10:28

1 Answer 1

5

Do not use the PreparedStatement interface to create a trigger that refers to a:NEW or :OLD column. Use Statement instead. Using PreparedStatement will cause execution to fail with the message java.sql.SQLException: Missing IN or OUT parameter at index:: 1.

see: http://docs.oracle.com/cd/E11882_01/java.112/e16548/oraint.htm#CHDIIDBE

use:

session.doWork(new Work() {
    @Override
    public void execute(Connection connection) throws SQLException {
        //connection, finally!
    }
});

from: How to get jdbc connection from hibernate session?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.