I have a query in java string. What i need to do is fire that query by jdbc. Query is:
String strQuery= " CREATE OR REPLACE FUNCTION GET_CLOSE_DATE ( PARAM_DOCUMENT_ID IN NUMBER ) RETURN DATE AS V_CLOSE_DATE DATE; BEGIN SELECT MAX(TOP_LEVEL_ELEMENT.CLOSE_DATE_TIME) INTO V_CLOSE_DATE FROM TOP_LEVEL_ELEMENT WHERE TOP_LEVEL_ELEMENT.DOCUMENT_ID = PARAM_DOCUMENT_ID; RETURN V_CLOSE_DATE; END GET_CLOSE_DATE;";
I am using JDBC
Statement stmt = con.createStatement(); stmt.executeUpdate(strQuery);
The query gets executed successfully but when I try to use this function it throws an an exception saying the GET_CLOSE_DATE function is in invalid state. I have also tried firing
alter function GET_CLOSE_DATE compile;
immediately after firing the create function query. Both are executed successfully but still the the function remains in invalid state. Please suggest some solutions.
preguntado el 08 de noviembre de 11 a las 15:11
Try this command to see what, if any errors are associated with this function:
SELECT * FROM user_errors WHERE name = 'GET_CLOSE_DATE';
It might be the embedded CR/LF's in your string. Try concatenating your SQL string, as in:
String strQuery= " CREATE OR REPLACE FUNCTION GET_CLOSE_DATE ( PARAM_DOCUMENT_ID IN" + " NUMBER) RETURN DATE AS " + " V_CLOSE_DATE DATE " + ...