pl sql debug
CREATE OR REPLACE PACKAGE xxpeug_jdebug IS
PROCEDURE pr_set_message(pi_pipe IN VARCHAR2, pi_message IN VARCHAR2);
FUNCTION f_get_message(pi_pipe IN VARCHAR2) Return VARCHAR2;
END xxpeug_jdebug;
/
CREATE OR REPLACE PACKAGE BODY xxpeug_jdebug AS
PROCEDURE pr_set_message(pi_pipe IN VARCHAR2, pi_message IN VARCHAR2) IS
pragma autonomous_transaction;
va_n_s INTEGER;
BEGIN
dbms_pipe.pack_message(pi_message);
va_n_s := dbms_pipe.send_message(pi_pipe, 1 /* maxwait = 1 sec */);
if va_n_s = 1 then
-- Timeout because buffer is full, so purge
dbms_pipe.purge(pi_pipe);
elsif va_n_s <> 0 then
raise_application_error(-20000, 'Error:' || to_char(va_n_s) || ' sending pipe');
end if;
END;
FUNCTION f_get_message(pi_pipe IN VARCHAR2) Return VARCHAR2 IS
va_n_s INTEGER;
va_v_message VARCHAR2(4096);
BEGIN
va_n_s := dbms_pipe.receive_message(pi_pipe);
if va_n_s <> 0 then
raise_application_error(-20000, 'Error:' || to_char(va_n_s) || ' reading pipe');
end if;
dbms_pipe.unpack_message(va_v_message);
Return(va_v_message);
END;
END xxpeug_jdebug;
/
Java
// FrontEnd Plus GUI for JAD
// DeCompiled : jdebug.class
import java.io.InputStream;
import java.io.PrintStream;
import java.sql.*;
import java.util.Calendar;
public class JDebug extends Thread
{
static Connection conn = null;
static String pipe = null;
static String stopmsg = "JDebug - Stop";
public JDebug()
{
}
public void run()
{
CallableStatement call = null;
String value = null;
Calendar now = null;
try
{
call = conn.prepareCall("begin ? := xxpeug_jdebug.f_get_message(?); end;");
call.registerOutParameter(1, 12);
call.setString(2, pipe);
do
{
call.execute();
value = call.getString(1);
if(value.equals(stopmsg))
break;
now = Calendar.getInstance();
System.out.println(now.get(11) + ":" + now.get(12) + ":" + now.get(13) + "." + now.get(14) + " " + value);
} while(true);
}
catch(SQLException se)
{
System.out.println("SQL Error : " + se);
}
finally
{
try
{
if(call != null)
call.close();
}
catch(SQLException sqlexception) { }
}
}
public static void main(String args[])
{
CallableStatement call = null;
Connection conn2 = null;
if(args.length != 4)
{
System.out.println("usage: JDebug ");
System.exit(-1);
}
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(args[0], args[1], args[2]);
pipe = args[3];
System.out.println("Reading pipe : " + pipe + ". Press to exit");
Thread jDebug = new JDebug();
jDebug.start();
System.in.read();
conn2 = DriverManager.getConnection(args[0], args[1], args[2]);
call = conn2.prepareCall("begin xxpeug_jdebug.pr_set_message(?, ?); end;");
call.setString(1, pipe);
call.setString(2, stopmsg);
call.execute();
call = conn2.prepareCall("begin ? := dbms_pipe.remove_pipe(?); end;");
call.registerOutParameter(1, 4);
call.setString(2, pipe);
call.execute();
call.close();
}
catch(Exception e)
{
System.out.println(e);
}
finally
{
try
{
if(!conn.isClosed())
conn.close();
if(!conn2.isClosed())
conn2.close();
}
catch(Exception exception1) { }
}
}
}
cmd line
========
SET JAVA_HOME = C:\jdevR12\jdevbin\jdk
java -Xms128m -Xmx128m -classpath C:\Oracle\product\10.1.0\Client_1\jdbc\lib\classes12.zip;. JDebug jdbc:oracle:thin:@dendbd2:1552:DERP3DEV apps apps PRA
PAUSE
PROCEDURE pr_set_message(pi_pipe IN VARCHAR2, pi_message IN VARCHAR2);
FUNCTION f_get_message(pi_pipe IN VARCHAR2) Return VARCHAR2;
END xxpeug_jdebug;
/
CREATE OR REPLACE PACKAGE BODY xxpeug_jdebug AS
PROCEDURE pr_set_message(pi_pipe IN VARCHAR2, pi_message IN VARCHAR2) IS
pragma autonomous_transaction;
va_n_s INTEGER;
BEGIN
dbms_pipe.pack_message(pi_message);
va_n_s := dbms_pipe.send_message(pi_pipe, 1 /* maxwait = 1 sec */);
if va_n_s = 1 then
-- Timeout because buffer is full, so purge
dbms_pipe.purge(pi_pipe);
elsif va_n_s <> 0 then
raise_application_error(-20000, 'Error:' || to_char(va_n_s) || ' sending pipe');
end if;
END;
FUNCTION f_get_message(pi_pipe IN VARCHAR2) Return VARCHAR2 IS
va_n_s INTEGER;
va_v_message VARCHAR2(4096);
BEGIN
va_n_s := dbms_pipe.receive_message(pi_pipe);
if va_n_s <> 0 then
raise_application_error(-20000, 'Error:' || to_char(va_n_s) || ' reading pipe');
end if;
dbms_pipe.unpack_message(va_v_message);
Return(va_v_message);
END;
END xxpeug_jdebug;
/
Java
// FrontEnd Plus GUI for JAD
// DeCompiled : jdebug.class
import java.io.InputStream;
import java.io.PrintStream;
import java.sql.*;
import java.util.Calendar;
public class JDebug extends Thread
{
static Connection conn = null;
static String pipe = null;
static String stopmsg = "JDebug - Stop";
public JDebug()
{
}
public void run()
{
CallableStatement call = null;
String value = null;
Calendar now = null;
try
{
call = conn.prepareCall("begin ? := xxpeug_jdebug.f_get_message(?); end;");
call.registerOutParameter(1, 12);
call.setString(2, pipe);
do
{
call.execute();
value = call.getString(1);
if(value.equals(stopmsg))
break;
now = Calendar.getInstance();
System.out.println(now.get(11) + ":" + now.get(12) + ":" + now.get(13) + "." + now.get(14) + " " + value);
} while(true);
}
catch(SQLException se)
{
System.out.println("SQL Error : " + se);
}
finally
{
try
{
if(call != null)
call.close();
}
catch(SQLException sqlexception) { }
}
}
public static void main(String args[])
{
CallableStatement call = null;
Connection conn2 = null;
if(args.length != 4)
{
System.out.println("usage: JDebug
System.exit(-1);
}
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection(args[0], args[1], args[2]);
pipe = args[3];
System.out.println("Reading pipe : " + pipe + ". Press
Thread jDebug = new JDebug();
jDebug.start();
System.in.read();
conn2 = DriverManager.getConnection(args[0], args[1], args[2]);
call = conn2.prepareCall("begin xxpeug_jdebug.pr_set_message(?, ?); end;");
call.setString(1, pipe);
call.setString(2, stopmsg);
call.execute();
call = conn2.prepareCall("begin ? := dbms_pipe.remove_pipe(?); end;");
call.registerOutParameter(1, 4);
call.setString(2, pipe);
call.execute();
call.close();
}
catch(Exception e)
{
System.out.println(e);
}
finally
{
try
{
if(!conn.isClosed())
conn.close();
if(!conn2.isClosed())
conn2.close();
}
catch(Exception exception1) { }
}
}
}
cmd line
========
SET JAVA_HOME = C:\jdevR12\jdevbin\jdk
java -Xms128m -Xmx128m -classpath C:\Oracle\product\10.1.0\Client_1\jdbc\lib\classes12.zip;. JDebug jdbc:oracle:thin:@dendbd2:1552:DERP3DEV apps apps PRA
PAUSE