1

I need to use following via Java EXEC DBMS_STREAMS_ADM.SET_TAG(tag => HEXTORAW('17')); using a simple Database client. along with other usual select/delete queries but its complaining for invalid SQL statement.

I tried removing the exec as its for PL/SQL and calling it with {} but still I am getting the same error.

3
  • How are you calling the stored procedure in Java? Please include the code you have. Commented Jun 6, 2018 at 21:11
  • DBClient.execute("exec DBMS_STREAMS_ADM.set_tag(tag => HEXTORAW('17'))"); Commented Jun 6, 2018 at 21:16
  • 2
    EXEC is SQL*Plus syntax and you can't use it here. You could use an anonymous PL/SQL block or the CALL syntax instead. Commented Jun 6, 2018 at 21:20

1 Answer 1

2

EXEC is SQL*Plus (Oracle's native SQL client) syntax and you can't use it here. The JDBC syntax for calling stored procedures is through the CALL directive. You can omit the parameter name in the call (tag => HEXTORAW('17')). For example:

try (CallableStatement cs 
        = myConnection.prepareCall("{ call DBMS_STREAMS_ADM.SET_TAG(HEXTORAW(?)) }")) {

    cs.setString(1, "17");        
    cs.execute();
}

It is unclear which DBClient you are currently using (please tell us), but the following might work as well:

DBClient.execute("{ call DBMS_STREAMS_ADM.set_tag(HEXTORAW('17')) }");

or then

DBClient.execute("begin DBMS_STREAMS_ADM.SET_TAG(HEXTORAW('17')); end;");
Sign up to request clarification or add additional context in comments.

2 Comments

I tried DBClient.execute("{ call DBMS_STREAMS_ADM.set_tag(tag => HEXTORAW('17')) }"); but its complaning for DBMS_STREAMS_ADM must be declared
It works out now. Some user permission issue at the end. Thanks

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.