I'm trying to execute an oracle PL/SQL procedure with groovy but I get exceptions. From what I've understood it is due to these intial lines-
SET SERVEROUTPUT ON
SET FEEDBACK OFF
execute dbms_output.enable(buffer_time);
My code looks like this:
Connection con=DriverManager.getConnection(url,username,password);
def sql= new Sql(con)
String stmt= " SET SERVEROUTPUT ON
SET FEEDBACK OFF
execute dbms_output.enable(buffer_time);
declare
//some varaibles
begin
//code
dbms.output.put.line(variable)
end
"
sql.execute(stmt);
When I remove the first 3 lines, I get no errors but there will be no output as I'm using dbms.output.put.line hence they are neccessary. How do I resolve the SQL Syntax Exception I get from the intial lines?
dbms_outputto return data to a calling application is not something that makes sense in 99.99999% of cases.dbms_outputis more of a crude debugging tool. It would generally make far more sense to, say, declare a function that returned a value and to call that function from your client. Or a procedure with anoutparameter.dbms_output.enable();to afterbeginand it would run.