This discussion is archived
1 Reply Latest reply: May 22, 2013 9:26 AM by rp0428 RSS

how to read in Java  the dbms_output.put_line of oracle

936666 Newbie
Currently Being Moderated
how to read in Java the dbms_output.put_line of oracle

I am having a stored procedure which will return the success or failure
Note it is a sample Stored procedure i have used try to understand how it works in real case

In Oracle 11g i am having the below table and stored procedure.
Create Table Test(Col1 number(5),Col2 Varchar2(30));

Create or replace procedure P_Test (P_check char,p_Col1 number ,p_Col2 Varchar2)
as
begin
If P_check <=5 then
dbms_output.put_line (1 ||','|| 'Please pass more than 5');
return;
end if;
Insert into Test (Col1, Col2)
Values (p_Col1,p_Col2);
Commit;
dbms_output.put_line (0 ||','||p_Col1 ||','|| p_Col2);
End;

exec P_Test(6,1,'test')
I would like to read the output from the P_Test and display in front end application.

is it is possible to read if the output is as dbms_output.put_line or the stored procedure needs to modify here with out parameter or ref-cursor.

Since it is java based i am posting here.

Thanks!
  • 1. Re: how to read in Java  the dbms_output.put_line of oracle
    rp0428 Guru
    Currently Being Moderated
    >
    I would like to read the output from the P_Test and display in front end application.

    is it is possible to read if the output is as dbms_output.put_line or the stored procedure needs to modify here with out parameter or ref-cursor.
    >
    Sure - first you need to enable DBMS_OUTPUT and then you need to actually go get it.

    The procedure calls to methods such as PUT_LINE do nothing more than put text into a buffer. It is up to a client application to get the lines FROM the buffer.

    Here is an AskTom blog that shows how to do that using Java - it is too lengthy to copy here.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:45027262935845

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points