Executing A Stored Function
I created the function below to generate four random number and to have them inserted into a table called RANNUMBERS.
CREATE OR REPLACE FUNCTION randnumber RETURN NUMBER IS
BEGIN
declare
i number;
inivar_v number;
rannumb number;
multi_v1 number;
addm_v number;
inicon_v number;
duocon_v number;
divisor_v number;
begin
i := 1;
inivar_v := 3;
inicon_v := 4;
duocon_v := 1;
divisor_v := 9;
loop
multi_v1 := inicon_v * inivar_v;
addm_v := multi_v1 + duocon_v;
rannumb := mod(addm_v,divisor_v);
insert into rannumbers values ('rannumb');
i := i+1;
inivar_v := rannumb;
exit when i > 4;
end loop;
return rannumb;
end;
COMMIT;
END;
I then run the script in sql* Plus and the result I had was:
Function Created.
I checked the table to see if the four random numbers had been inserted but alas the table was empty. I then realized the function had not been invoked or executed. But, how do I execute a fuction? Could someone please help.
Why can't you use the package 'DBMS_RANDOM' to generate random numbers?
SQL> CREATE OR REPLACE PROCEDURE randnumber IS
2 BEGIN
3 declare
4 i number;
5 inivar_v number;
6 rannumb number;
7 multi_v1 number;
8 addm_v number;
9 inicon_v number;
10 duocon_v number;
11 divisor_v number;
12 begin
13 i := 1;
14 inivar_v := 3;
15 inicon_v := 4;
16 duocon_v := 1;
17 divisor_v := 9;
18 loop
19 multi_v1 := inicon_v * inivar_v;
20 addm_v := multi_v1 + duocon_v;
21 rannumb := mod(addm_v,divisor_v);
22 insert into rannumbers values (rannumb);
23 i := i+1;
24 inivar_v := rannumb;
25 exit when i > 4;
26 end loop;
27 end;
28 COMMIT;
29 END;
30 /
Procedure created.
SQL> DESC RANNUMBERS
Name Null? Type
COL1 VARCHAR2(10)
SQL> TRUNCATE TABLE RANNUMBERS;
Table truncated.
SQL> EXEC RANDNUMBER
PL/SQL procedure successfully completed.
SQL> SELECT * FROM RANNUMBERS;
COL1
4
8
6
7
4 rows selected.
SQL> SELECT DBMS_RANDOM.RANDOM FROM DUAL;
RANDOM
-60130308
1 row selected.
SQL> /
RANDOM
1691559234
1 row selected.
SQL> /
RANDOM
-168493545
1 row selected.
SQL> /
RANDOM
-909781409
1 row selected.
Similar Messages
-
Execute a stored function from command line
Hello,
I have a db stored function and I need to execute it from command line. I've tried by this way:
(I need to connect with sys credentials)
sqlplus sys/mypwd@mydb AS SYSDBA @myfile.sql
and myfile.sql is:
exec myschema.sf_test;
but I get this error:
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00221: 'sf_test' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignoredYou can use exec command for the execution of a procedure with out bind variable, but for a function always use bind variable.
Function should return a value, so you must have to assign the function return value to a variable.
like given below(or simply query the function using select statement)
Method 1
======
variable v1 number;
exec :v1 := t_func;
Method 2
======
declare
x1 NUMBER;
begin
x1 := t_func;
end;
SQL> create function t_func return number
2 as
3 begin
4 return 0;
5 end;
6 /
Function created.
SQL> exec t_func;
BEGIN t_func; END;
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00221: 'T_FUNC' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Method 3
======
SQL> select t_func from dual;
T_FUNC
0
Regards
JJ -
Executing stored function using Native SQL
In SAP documentation, I can see how to execute an Oracle stored procedure in an external database using:
EXEC SQL.
EXECUTE PROCEDURE procname
ENDEXEC.
I want to execute a stored FUNCTION within a package. I have tried executing it using the syntax for PROCEDURE above and get a "ORA-06550 wrong type or number of arguments" error. Since the function has one argument in and one argument out, I think I am counting the number of arguments correctly. Has anyone executed from within ABAP an Oracle function stored in an external database?
Thanks
Janice IsheeJanice - from help.sap.com:
Stored Procedures
The command EXECUTE PROCEDURE proc allows you to call a procedure stored in the database. When you call it, you can pass a list of host variables as parameters. When yuo call a procedure, you must specify for each parameter whether it is an input parameter ( IN), output parameter (OUT) or changing parameter (INOUT).
Example
Calling a Procedure:
DATA Y TYPE I VALUE 300.
DATA Z TYPE I.
EXEC SQL.
INSERT INTO AVERI_CLNT (CLIENT, ARG1, ARG2, ARG3)
VALUES ('000', 9, 2, 47)
ENDEXEC.
EXEC SQL.
CREATE OR REPLACE PROCEDURE PROC1 (X IN NUMBER) IS
BEGIN
UPDATE AVERI_CLNT SET ARG3 = ARG3 + X;
END;
ENDEXEC.
EXEC SQL.
CREATE OR REPLACE PROCEDURE PROC2 (X IN NUMBER, Y OUT NUMBER) IS
BEGIN
SELECT ARG3 INTO Y
FROM AVERI_CLNT
WHERE CLIENT = '000' AND ARG1 = 9 AND ARG2 = 2;
UPDATE AVERI_CLNT SET ARG3 = ARG3 - X;
END;
ENDEXEC.
EXEC SQL.
EXECUTE PROCEDURE PROC1 ( IN :Y )
ENDEXEC.
EXEC SQL.
EXECUTE PROCEDURE PROC2 ( IN :Y, OUT :Z )
ENDEXEC.
IF SY-SUBRC <> 0 OR Z <> 347.
WRITE: / 'Wrong result for EXECUTE PROCEDURE:', Z.
ENDIF.
EXEC SQL.
DROP PROCEDURE PROC1
ENDEXEC.
EXEC SQL.
DROP PROCEDURE PROC2
ENDEXEC.
Rob -
Hi,
My Stored Procedure is
create or replace procedure concatname(a varchar2,
b varchar2,
c out varchar2)
as
begin
c := a || b;
end;
My Function is
create or replace function ex(sp varchar2)
return varchar2 as
v varchar2(100);
begin
execute immediate 'begin '||sp||'(''test'','' procedure'',:o); end;'
using out v;
return v;
end;
Iam using PowerBuilder 8 as a FRONT END Tool ( connecting to ORACLE db - 10gR2 through ODBC driver) for executing the above function where i will pass the stored procedure name ( CONCATNAME ) as an argument.
The function is executing fine when i execute through ISQL interface.
While executing this function from the front end tool( POWER BUILDER ) iam getting the following error.
ORA-03113: end-of-file on communication channel.
I dont know, why this error is coming ? As the function is executing fine
through ISQL ?
I think this error will come if you execute the above function from any front
end tool( like .Net etc. ).
Can anybody help me ? How to avoid this error ( ORA-03113 ) ?
For Your Information: All other simple functions are executing fine through POWER BUILDER in my application.ORA-03113: end-of-file on communication channel is a client driver error. It is a symptom of a problem - it is not the problem itself.
This error message simply says that your client was still talking to the database service process servicing your client session, when that (TCP/IP socket) connection was unexpectedly torn down by the server.
This is often caused by that database service process crashing due to an internal (ORA-0600) error - and taking the TCP/IP connection down with it.
You need to ask your DBA to have a look at the alert log file for the Oracle instance. The crash will be recorded there. In addition a trace file should have been created.
Using the 1st parameter of the ORA-0600 message for the crash in the alert log file, the DBA should lookup the possible causes of the crash on Metalink note 153788.1 -
How to execute a stored procedure/function in TOAD?
Hi, All ,
Can someone please tell me how to execute a stored procedure/function in TOAD?
I have tired
EXECUTE PROCEDURENAME(888), but it doesn’t work.
TOAD give me the error: invalid SQL statement.
Thanks a lotWrite PL/SQl block.
i.e Begin
Procedure name..
end;
Then it will be excuted.
Ashutosh -
ORA-29531 when i execute a java stored function
I get the following error when i tried to execute java stored procedure
ORA-29531: no method secondConcat in class secondProcedure
The code below will explain my problem clearly
Java Class:(secondProcedure)
import java.lang.*;
public class secondProcedure
public static String secondConcat(String inStr1, String inStr2, String outStr)
System.out.println("Calling secondProcedure.secondConcat\n");
outStr = inStr1 + inStr2;
String retStr = outStr;
return retStr;
Database Function:(fn_sec_concat)
FUNCTION fn_sec_concat(Str1 IN VARCHAR2, Str2 IN VARCHAR2, Str3 OUT VARCHAR2)
RETURN VARCHAR2
AS LANGUAGE JAVA
NAME 'secondProcedure.secondConcat(java.lang.String, java.lang.String, java.lang.String[])
return java.lang.String';
I used loadjava utility to load the java class into database which went fine.
I searched for the error message on the web, & i response i got from everywhere is to add the static attribute to method, which was already there in my code.
Please help!
nullI get the following error when i tried to execute java stored procedure
ORA-29531: no method secondConcat in class secondProcedure
The code below will explain my problem clearly
Java Class:(secondProcedure)
import java.lang.*;
public class secondProcedure
public static String secondConcat(String inStr1, String inStr2, String outStr)
System.out.println("Calling secondProcedure.secondConcat\n");
outStr = inStr1 + inStr2;
String retStr = outStr;
return retStr;
Database Function:(fn_sec_concat)
FUNCTION fn_sec_concat(Str1 IN VARCHAR2, Str2 IN VARCHAR2, Str3 OUT VARCHAR2)
RETURN VARCHAR2
AS LANGUAGE JAVA
NAME 'secondProcedure.secondConcat(java.lang.String, java.lang.String, java.lang.String[])
return java.lang.String';
I used loadjava utility to load the java class into database which went fine.
I searched for the error message on the web, & i response i got from everywhere is to add the static attribute to method, which was already there in my code.
Please help!
null -
Executing DML-ing stored function from EntityManager
Hi,
Is there some way of getting the result from a DML-ing stored function from the EntityManager? I can use a native query and just select the function from dual if it doesn't do any DML but when it does, it is not permitted. I can't use getDelegate() to get the raw connection either :-/
Edited by: nickarls on Sep 25, 2007 2:19 AM
Edited by: nickarls on Sep 25, 2007 2:20 AM
Hmmm. the *** should be "ing". Probably looks like a curseanyone, anyone?
-
Incorrect Update Count by executing a stored procedure from Java
Hi Guys,
I am calling a stored procedure from the java program which is modifying the rows of a table. Now I want to know how many rows have been modified by executing the stored procedure. I am writing the following code for the purpose:
OracleCallableStatement stmt =
(oracle.jdbc.driver.OracleCallableStatement)con.prepareCall("{callsp_um_setForumID(?,?)}");
stmt.setInt(1,101);
stmt.setInt(2,666);
n = stmt.executeUpdate();
System.out.println(n + " row(s) updated");
This procedure is actually modifying the table(When I query the databse it has modified 1 row). But it is returning a value 0 and is printing "0 row(s) updated".
Is there a way by which I can find out the number of rows updated by executing the stored procedure?
Thanks
Sachin
[email protected]I'm no expert on this, but I have a similar call where I fetch
an Oracle REF CURSOR from a call to a stored function. If you
fetch the cursor as an Object from your CallableStatement, you
can then cast it to a ResultSet e.g.
mystatement.executeUpdate();
ResultSet rs = (ResultSet) mystatement.getObject(1);
Then you should be able to loop through your ResultSet as usual.
Good luck!
Chris -
Execute oracle stored procedure in CF8
I am executing a stored procedure like this.
<cfstoredproc procedure="GetAction"
datasource="test_DSN">
<cfprocparam cfsqltype="CF_SQL_INTEGER"
dbvarname="actionId" type="in" value="1">
<cfprocresult name="actions" resultset="1" >
</cfstoredproc>
and my stored procedure in oracle is,
create or replace function GetAction(actionId IN
ACTION.ID%TYPE)
RETURN ACTION%ROWTYPE
IS
actions
ACTION%ROWTYPE;
begin
select *
INTO actions
FROM ACTION WHERE ID = actionId;
RETURN actions;
end GetAction;
then I get the error message like,
ORA-01008: not all variables bound
Please help me on this.
ThanxIf you want to return a result set (result of a query) from
your PL/SQL, you will have to do what Daverms suggested and convert
your function to a procedure
and use a reference cursor to return your result set. Your
procedure will have to be contained in a package in order for you
to declare a ref cursor "globally" so that it can be accessed by
CF.
Oh, and be sure to change your cfstoredproc procedure
parameter to add the package name to the proc name.
<cfstoredproc procedure="your_pkg.GetAction"
datasource="test_DSN">
Phil -
Execute oracle stored procedure from C# always returns null
Hi,
I'm trying to execute a stored procedure on oracle 9i. I'm using .Net OracleClient provider.
Apparently, I can execute the stored procedure, but it always returns null as a result (actually all the sp's I have there returns null)! I can execute any text statement against the database successfully, and also I can execute the stored procedure using Toad.
This is not the first time for me to call an oracle stored procedure, but this really is giving me a hard time! Can anyone help please?
Below are the SP, and the code used from .Net to call it, if that can help.
Oracle SP:
CREATE OR REPLACE PROCEDURE APIECARE.CHECK_EXISTENCE(l_number IN NUMBER) AS
v_status VARCHAR2(5) := NULL;
BEGIN
BEGIN
SELECT CHECK_NO_EXISTENCE(to_char(l_number))
INTO v_status
FROM DUAL;
EXCEPTION WHEN OTHERS THEN
v_status := NULL;
END;
DBMS_OUTPUT.PUT_LINE(v_status);
END CHECK_CONTRNO_EXISTENCE;
C# Code:
string connStr = "Data Source=datasource;Persist Security Info=True;User ID=user;Password=pass;Unicode=True";
OracleConnection conn = new OracleConnection(connStr);
OracleParameter param1 = new OracleParameter();
param1.ParameterName = "v_status";
param1.OracleType = OracleType.VarChar;
param1.Size = 5;
param1.Direction = ParameterDirection.Input;
OracleParameter param2 = new OracleParameter();
param2.ParameterName = "l_number";
param2.OracleType = OracleType.Number;
param2.Direction = ParameterDirection.Input;
param2.Value = 006550249;
OracleParameter[] oraParams = new OracleParameter[] { param1, param2 };
OracleCommand cmd = new OracleCommand("CHECK_EXISTENCE", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(oraParams);
conn.Open();
object result = cmd.ExecuteScalar();
conn.Close();Hi,
Does that actually execute? You're passing two parameters to a procedure that only takews 1 and get no error?
Your stored procedure doesnt return anything and has no output parameters, what are you expecting to be returned exactly?
If you're trying to access V_STATUS you'll need to declare that as either an output parameter of the procedure, or return value of the function, and also access it via accessing Param.Value, not as the result of ExecuteScalar.
See if this helps.
Cheers,
Greg
create or replace function myfunc(myinvar in varchar2, myoutvar out varchar2) return varchar2
is
retval varchar2(50);
begin
myoutvar := myinvar;
retval := 'the return value';
return retval;
end;
using System;
using System.Data;
using Oracle.DataAccess.Client;
public class odpfuncparams
public static void Main()
OracleConnection con = new OracleConnection("user id=scott;password=tiger;data source=orcl");
con.Open();
OracleCommand cmd = new OracleCommand("myfunc", con);
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter retval = new OracleParameter("retval",OracleDbType.Varchar2,50);
retval.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(retval);
OracleParameter inval = new OracleParameter("inval",OracleDbType.Varchar2);
inval.Direction = ParameterDirection.Input;
inval.Value="hello world";
cmd.Parameters.Add(inval);
OracleParameter outval = new OracleParameter("outval",OracleDbType.Varchar2,50);
outval.Direction = ParameterDirection.Output;
cmd.Parameters.Add(outval);
cmd.ExecuteNonQuery();
Console.WriteLine("return value is {0}, out value is {1}",retval.Value,outval.Value);
con.Close();
} -
Calling Stored Function from TopLink
I have a simple Stored Function that I'm trying to call using TopLink API:
TopLink Version: 10.1.3.3.
Oracle JDBC Driver: ojdbc5.jar (Oracle JDBC Driver version - "11.1.0.6.0-Production+")
Stored Procedure:
Function Get_Email_Address_Id(P_EMAIL_ADDRESS IN varchar2) return number;
TopLink Code:
public String executeStoredFunction() {
TopLinkTemplate tlTemplate = getTopLinkTemplate();
StoredFunctionCall call = new StoredFunctionCall();
call.setProcedureName("EMAIL_ADDRESS_PKG.Get_Email_Address_Id");
call.setResult("FUNCTION_RESULT", String.class);
call.addNamedArgument("P_EMAIL_ADDRESS");
ValueReadQuery query = new ValueReadQuery();
query.setCall(call);
query.addArgument("P_EMAIL_ADDRESS");
Vector parameters = new Vector();
parameters.addElement("1009");
String result = (String)tlTemplate.executeQuery(query, parameters.toArray());
return result;
Error I'm getting:
Exception [TOPLINK-7121] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070428)): oracle.toplink.exceptions.ValidationException
Exception Description: DatabasePlatform does not support stored functions
at oracle.toplink.exceptions.ValidationException.platformDoesNotSupportStoredFunctions(ValidationException.java:1299)
at oracle.toplink.queryframework.StoredFunctionCall.prepareInternal(StoredFunctionCall.java:52)
at oracle.toplink.internal.databaseaccess.DatabaseCall.prepare(DatabaseCall.java:494)
at oracle.toplink.internal.queryframework.CallQueryMechanism.prepareCall(CallQueryMechanism.java:102)
at oracle.toplink.internal.queryframework.CallQueryMechanism.prepareExecuteSelect(CallQueryMechanism.java:203)
at oracle.toplink.queryframework.DataReadQuery.prepare(DataReadQuery.java:150)
at oracle.toplink.queryframework.DatabaseQuery.checkPrepare(DatabaseQuery.java:405)
at oracle.toplink.queryframework.DatabaseQuery.checkPrepare(DatabaseQuery.java:375)
at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:598)
at oracle.toplink.queryframework.DataReadQuery.execute(DataReadQuery.java:96)
at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:2089)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:993)
at oracle.toplink.publicinterface.Session.executeQuery(Session.java:965)
Observations:
Why is TopLink complaining about DatabasePlatform?
I'm using Oracle 10g as my database platform. Did anyone encounter this problem?
I have tried various combinations but it always have same complaint.
Thanks in advance for help.Hello,
It is complaining because the DatabasePlatform being used doesn't support functions. So the problem is that it is using the DatabasePlatform instead of the Oracle10Platform that you are expecting. How have you defined it? Could you have multiple sessions.xml files, and the one that is being picked not define the Oracle10Platform? Or could you be overriding the login somehow (prelogin event etc) and setting it to use the default DatabasePlatform by accident?
Best Regards,
Chris -
Stored function not returning result set unless recompiled
Hi,
I have a strange situation going on with a basic Java (1.6.0.17) application talking to an Oracle 11g (11.2.0.1.0) database. Basically what is happening is that sometimes a stored function's return value (a result set) is not making it as far as JDBC/Java, unless I recompile the stored function (with absolutely no changes to the application or function's code). I am always able to successfully see the result set if I call the function directly from within SQL Developer, just not on the Java app/JDBC side.
I've tried running with 3 different physical Oracle 11g servers and tried running the app on a couple of machines. I'm wondering if this is either some kind of caching issue or perhaps a JDBC bug/misconfiguration.
Any help would be greatly appreciated. Attached to this message:
1. stored function code
2. snippet of Java app code
3. ODBC trace output when returned a empty result set (ie failure scenario)
4. ODBC trace out when returned the correct result set (ie success scenario)
* it's helpful if you compare the texts of 3 & 4 with Vim diff or WinMerge etc.
** as they're large I've just extracted the sections that had differences. Leave a message here and I can send you the full ones if necessary.
1. stored function code
===============
FUNCTION getRecordSet (
ActionId Number
RETURN CallingList.ref_cursor
IS
myDataCursor CallingList.ref_cursor;
ActionId_ Number;
BEGIN
ActionId_ := ActionId;
IF isActionExpired(ActionId) <= 0 THEN
ActionId_ := 0;
END IF;
OPEN myDataCursor FOR
SELECT
C.ID,
C.CUSTOMER_ID,
C.CAMPAIGN_ID,
c.phone,
C.TRANSFERDN,
(SELECT
TTS_MESSAGE
FROM CAMPAIGN CMP
WHERE CMP.CAMPAIGN_ID = C.CAMPAIGN_ID) "TTS"
FROM
CALLING_LIST C
WHERE
C.ACTION_ID = ActionId_
AND
C.CALL_STATUS = 1
AND
C.CALLCOUNT > 0
And rownum <=5;
RETURN myDataCursor;
EXCEPTION
WHEN CURSOR_ALREADY_OPEN THEN
RETURN NULL;
WHEN INVALID_CURSOR THEN
RETURN NULL;
WHEN NO_DATA_FOUND THEN
RETURN NULL;
END getRecordSet;
....and the isActionExpired function that is called from within getResultSet is (but for all my testing it's been returning 1 with no problems)
FUNCTION isActionExpired (
ActionId number
) RETURN number
AS
Today varchar2(12);
myCount number(6);
BEGIN
myCount := 0;
today := to_char(sysdate, 'dd.mm.yyyy');
SELECT
count(*)
INTO
myCount
FROM
ACTION A
where
ACTION_ID = ActionId
AND
SYSDATE BETWEEN ACTION_STARTDATETIME
AND
ACTION_STOPDATETIME
and
SYSDATE BETWEEN to_date(today || ' ' || A.STARTTIME, 'dd.mm.yyyy HH24:MI:SS') and to_date(today || ' ' || A.ENDTIME, 'dd.mm.yyyy HH24:MI:SS')
AND
ACTION_STATUS = 1;
return myCount;
END isActionExpired;
2. snippet of Java app code
=================
... db connect logic...
javax.management.MBeanServer mbs = null;
javax.management.ObjectName name = null;
try {
String loader = Thread.currentThread().getContextClassLoader().toString().replaceAll("[,=:\"]+", "");
name = new javax.management.ObjectName("com.oracle.jdbc:type=diagnosability,name="+loader);
mbs = java.lang.management.ManagementFactory.getPlatformMBeanServer();
mbs.setAttribute(name, new javax.management.Attribute("LoggingEnabled", true));
} catch (Exception e) {
System.out.println("ORACLE TRACE ERROR: " + e.getStackTrace());
try {
String query = "begin ? := CALLINGLIST.getRecordSet(?); end;";
CallableStatement stmt = conn.prepareCall(query);
stmt.registerOutParameter(1, OracleTypes.CURSOR);
stmt.setInt(2, actionId);
stmt.execute();
ResultSet rs = (ResultSet) stmt.getObject(1); // So, here it works.
// print the results
int count=0;
while (rs.next()) {
count++;
stmt.close();
System.out.println("rs count was: " + count);
} catch (SQLException e) {
System.out.println("Exception occurred: " + e.getMessage());
3. ODBC trace output when returned a empty result set (ie failure scenario)
===============================================
Jul 1, 2010 3:30:47 PM oracle.net.ns.Packet receive
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.net.ns.Packet receive
TRACE_20: Debug: type=6, length=121, flags=0
00 79 00 00 06 00 00 00 |.y......|
00 00 06 22 01 06 00 01 |..."....|
0A 00 00 00 07 03 C2 04 |........|
0E 04 C3 5E 22 03 02 C1 |...^"...|
2A 04 33 30 30 32 03 37 |*.3002.7|
37 37 05 48 65 6C 6C 6F |77.Hello|
08 01 06 00 00 01 02 00 |........|
00 00 00 00 00 04 01 05 |........|
01 01 02 05 7B 00 00 01 |....{...|
02 00 03 00 00 00 00 00 |........|
00 00 00 00 00 00 00 00 |........|
00 01 01 00 00 00 00 19 |........|
4F 52 41 2D 30 31 34 30 |ORA-0140|
33 3A 20 6E 6F 20 64 61 |3:.no.da|
74 61 20 66 6F 75 6E 64 |ta.found|
0A |. |
Jul 1, 2010 3:30:47 PM oracle.net.ns.Packet receive
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 1, [I@1315d34, 20
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 1, 871, [I@1315d34, 20, oracle-character-set-830, oracle-character-set-2000, oracle-character-set-871, false
Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 1, [I@1315d34, true, 20
Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
TRACE_16: return: 4
Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
TRACE_16: return: 4
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
TRACE_16: return: 4
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 211, [I@1de256f, 10
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 211, 871, [I@1de256f, 10, oracle-character-set-830, oracle-character-set-2000, oracle-character-set-871, false
Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 211, [I@1de256f, true, 10
Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
TRACE_16: return: 3
Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
TRACE_16: return: 3
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
TRACE_16: return: 3
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 321, [I@16bd8ea, 2000
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 321, 871, [I@16bd8ea, 2000, oracle-character-set-830, oracle-character-set-2000, oracle-character-set-871, false
Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
TRACE_16: Enter: [B@1fa1bb6, 0, [C@1b000e7, 321, [I@16bd8ea, true, 2000
Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
TRACE_16: return: 5
Jul 1, 2010 3:30:47 PM oracle.sql.CharacterSet convertUTFBytesToJavaChars
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
TRACE_16: return: 5
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion _CHARBytesToJavaChars
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
TRACE_16: return: 5
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.DBConversion CHARBytesToJavaChars
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
TRACE_16: Enter: [Loracle.jdbc.internal.KeywordValue;@16e1fb1
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement fetch
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement checkValidRowsStatus
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement checkValidRowsStatus
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl <init>
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.ResultSetAccessor getObject
TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.ResultSetAccessor getObject
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatement getObject
TRACE_1: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatement getObject
TRACE_1: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
TRACE_30: return: oracle.jdbc.driver.OracleResultSetImpl@e2cb55
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
TRACE_30: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
TRACE_1: Public Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
TRACE_20: Debug: closed=false, statement.currentRow=-1, statement.totalRowsVisited=0, statement.maxRows=0, statement.validRows=1, statement.gotLastBatch=true
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
TRACE_1: return: true
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
TRACE_1: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
TRACE_1: Public Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
TRACE_20: Debug: closed=false, statement.currentRow=0, statement.totalRowsVisited=1, statement.maxRows=0, statement.validRows=1, statement.gotLastBatch=true
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
TRACE_16: Enter: false
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BaseResultSet close
TRACE_16: Public Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BaseResultSet close
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLine
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection needLine
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement closeQuery
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
TRACE_16: Enter: "oracle.jdbc.driver.T4CStatement.closeQuery"
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement closeQuery
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement endOfResultSet
TRACE_16: Enter: false
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
TRACE_16: Enter: false, false
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearWarnings
TRACE_16: Public Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearWarnings
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
TRACE_16: Enter: true
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
TRACE_16: return:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement clearDefines
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearDefines
TRACE_16: Public Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement freeLine
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement freeLine
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement cleanupDefines
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
TRACE_16: Enter: [B@8e32e7
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
TRACE_16: Enter: [B@8e32e7
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
TRACE_30: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
TRACE_16: Enter: [C@1b000e7
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
TRACE_16: Enter: [C@1b000e7
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.BufferCache put
TRACE_30: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement cleanupDefines
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement clearDefines
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.T4CStatement clearDefines
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement endOfResultSet
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
TRACE_16: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
TRACE_1: return: false
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleResultSetImpl next
TRACE_1: Exit
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleCallableStatementWrapper close
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OraclePreparedStatementWrapper close
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatementWrapper close
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement close
TRACE_1: Public Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.OracleStatement closeOrCache
TRACE_16: Enter: null
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection isStatementCacheInitialized
TRACE_16: Enter:
Jul 1, 2010 3:30:47 PM oracle.jdbc.driver.PhysicalConnection isStatementCacheInitialized
4. ODBC trace out when returned the correct result set (ie success scenario)
===============================================
TRACE_16: Enter:
Jul 1, 2010 3:30:07 PM oracle.net.ns.Packet receive
TRACE_20: Debug: type=6, length=82, flags=0
00 52 00 00 06 00 00 00 |.R......|
00 00 08 01 06 00 00 01 |........|
02 00 00 00 00 00 00 04 |........|
01 05 00 02 05 7B 00 00 |.....{..|
01 02 00 03 00 00 00 00 |........|
00 00 00 00 00 00 00 00 |........|
00 00 01 01 00 00 00 00 |........|
19 4F 52 41 2D 30 31 34 |.ORA-014|
30 33 3A 20 6E 6F 20 64 |03:.no.d|
61 74 61 20 66 6F 75 6E |ata.foun|
64 0A |d. |
Jul 1, 2010 3:30:07 PM oracle.net.ns.Packet receive
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
TRACE_16: Enter: [Loracle.jdbc.internal.KeywordValue;@1fa1bb6
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection updateSessionProperties
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement fetch
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
TRACE_16: Enter: false
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BaseResultSet close
TRACE_16: Public Enter:
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BaseResultSet close
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
TRACE_16: Enter:
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection registerHeartbeat
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLine
TRACE_16: Enter:
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
TRACE_16: Enter:
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLineUnchecked
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection needLine
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement closeQuery
TRACE_16: Enter:
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
TRACE_16: Enter: "oracle.jdbc.driver.T4CStatement.closeQuery"
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CConnection assertLoggedOn
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement closeQuery
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement endOfResultSet
TRACE_16: Enter: false
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
TRACE_16: Enter: false, false
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearWarnings
TRACE_16: Public Enter:
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearWarnings
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement prepareForNewResults
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement clearDefines
TRACE_16: Enter:
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearDefines
TRACE_16: Public Enter:
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement freeLine
TRACE_16: Enter:
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement freeLine
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement cleanupDefines
TRACE_16: Enter:
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
TRACE_16: Enter: [B@8e32e7
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
TRACE_16: Enter: [B@8e32e7
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
TRACE_30: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
TRACE_16: Enter: [C@1b000e7
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
TRACE_16: Enter: [C@1b000e7
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.BufferCache put
TRACE_30: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.PhysicalConnection cacheBuffer
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement cleanupDefines
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement clearDefines
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CStatement clearDefines
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleStatement endOfResultSet
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl internal_close
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl <init>
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.T4CResultSetAccessor getCursor
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.ResultSetAccessor getObject
TRACE_16: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.ResultSetAccessor getObject
TRACE_16: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatement getObject
TRACE_1: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatement getObject
TRACE_1: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
TRACE_30: return: oracle.jdbc.driver.OracleResultSetImpl@1315d34
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleCallableStatementWrapper getObject
TRACE_30: Exit
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl next
TRACE_1: Public Enter:
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl next
TRACE_20: Debug: closed=true, statement.currentRow=-1, statement.totalRowsVisited=0, statement.maxRows=0, statement.validRows=0, statement.gotLastBatch=false
Jul 1, 2010 3:30:07 PM oracle.jdbc.driver.OracleResultSetImpl next
Edited by: user9376621 on Jul 1, 2010 1:07 AM
Edited by: user9376621 on Jul 1, 2010 1:13 AMPlease ignore this, it was a non-issue in the end.
-
Cannot call ANY stored functions from my Java program
My problem is that I cannot call ANY stored procedure from my Java
program. Here is the code for one of my stored procedures which runs
very well in PL/SQL:
PL/SQL code:
CREATE OR REPLACE PACKAGE types AS
TYPE cursorType IS REF CURSOR;
END;
CREATE OR REPLACE FUNCTION list_recs (id IN NUMBER)
RETURN types.cursorType IS tracks_cursor types.cursorType;
BEGIN
OPEN tracks_cursor FOR
SELECT * FROM accounts1
WHERE id = row_number;
RETURN tracks_cursor;
END;
variable c refcursor
exec :c := list_recs(11)
SQL> print c
COLUMN1 A1 ROW_NUMBER
rec_11 jacob 11
rec_12 jacob 11
rec_13 jacob 11
rec_14 jacob 11
rec_15 jacob 11
Here is my Java code:
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
class list_recs
public static void main(String args[]) throws SQLException,
IOException
String query;
CallableStatement cstmt = null;
ResultSet cursor;
// input parameters for the stored function
String user_name = "jacob";
// user name and password
String user = "jnikom";
String pass = "jnikom";
DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
try { Class.forName ("oracle.jdbc.driver.OracleDriver"); }
catch (ClassNotFoundException e)
{ System.out.println("Could not load driver"); }
Connection conn =
DriverManager.getConnection (
"jdbc:oracle:thin:@10.52.0.25:1521:bosdev",user,pass);
try
String sql = "{ ? = call list_recs(?) }";
cstmt = conn.prepareCall(sql);
// Use OracleTypes.CURSOR as the OUT parameter type
cstmt.registerOutParameter(1, OracleTypes.CURSOR);
String id = "11";
cstmt.setInt(2, Integer.parseInt(id));
// Execute the function and get the return object from the call
cstmt.executeQuery();
ResultSet rset = (ResultSet) cstmt.getObject(1);
while (rset.next())
System.out.print(rset.getString(1) + " ");
System.out.print(rset.getString(2) + " ");
System.out.println(rset.getString(3) + " ");
catch (SQLException e)
System.out.println("Could not call stored function");
e.printStackTrace();
return;
finally
cstmt.close();
conn.close();
System.out.println("Stored function was called");
Here is how I run it, using Win2K and Oracle9 on Solaris:
C:\Jacob\Work\Java\Test\Vaultus\Oracle9i\FunctionReturnsResultset>java
list_recs
Could not call stored function
java.sql.SQLException: ORA-00600: internal error code, arguments:
[ttcgcshnd-1], [0], [], [], [], [], [], []
at
oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:889)
at
oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:490)
at
oracle.jdbc.driver.OracleStatement.getCursorValue(OracleStatement.java:2661)
at
oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:4189)
at
oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:4123)
at
oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:541)
at list_recs.main(list_recs.java:42)
C:\Jacob\Work\Java\Test\Vaultus\Oracle9i\FunctionReturnsResultset>
Any help is greatly appreciated,
Jacob NikomThank you for your suggestion.
I tried it, but got the same result. I think the difference in the syntax is due to the Oracle versus SQL92 standard
conformance. Your statament is the Oracle version and mine is the SQL92. I think both statements are acceptable
by the Oracle.
Regards,
Jacob Nikom -
Why returning string from java stored function failed ? HELP ME, PLEASE
Hi everybody,
I created java stored function: it's doing http post, parsing xml from http reply, and returning string result.
Sometimes, it doesn't return any value. What can be a reason ?
The high level procedure, has following form:
class SBE {
public static String call(String arg0) {
SBE sbe=new SBE("d:\\oracle\\ora81\\network\\log\\SBE.log");
String result=SBEParser.go(sbe.sendRequest(arg0, ""), sbe.logger);
sbe.logger.log(result);
sbe.logger.log("Finish SBE intetraction");
return result;
PLSQL wrapper has a simple form:
create or replace package PG_SBE as
function CALL(arg0 in varchar2) return varchar2;
end;
create or replace package body PG_SBE as
function CALL(arg0 varchar2) return varchar2 as language java name 'SBE.call(java.lang.String) return java.lang.String';
end;
In log file ("d:\\oracle\\ora81\\network\\log\\SBE.log"), I can find message :
"Finish SBE intetraction"
but query:
select pg_sbe.call("any argument") from dual;
doesn't finish.
What can be a reason ? What can I do to trace stage of convertion java string to varchar ?
Please help me...
Best regards
Marek<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Stefan Fdgersten ([email protected]):
Maybe your call is wrong... Shouldn't there be a "?" instead of "1"?
Your code:
String myquery = "begin :1 := jspTest; end;";
I provide my (working) call from java as an example. Maybe it is of any help... :)
import java.sql.*;
import oracle.jdbc.driver.*;
public Vector getAllHosts() throws SQLException {
//return getHosts(false, -1);
Connection conn = null;
CallableStatement cs = null;
Vector hostV = new Vector();
try {
conn = getConnection();
String query = "{ ? = call curTestPkg.curTestFunc}";
cs = conn.prepareCall(query);
cs.registerOutParameter(1, OracleTypes.CURSOR);
cs.execute();
ResultSet rs = ((OracleCallableStatement)cs).getCursor(1);
while (rs.next()) {
Host host = new Host(
rs.getInt("hostid")
, rs.getString("name")
, rs.getString("descr")
, rs.getString("os"));
hostV.add(host);
cs.close();
return hostV;
} finally {
close(conn, cs);
<HR></BLOCKQUOTE>
hi Stefan thanx.....even after changing the call statement i get the same error. i changed query string as...
String myquery = "{ ? = call jspTest}";
CallableStatement cst = con.prepareCall(myquery);
Can u please check out my call sepc that i have written in pl/sql and plz let me know it there is any error in that.
PS : THIS IS THE FIRST TIME I AM WORKING WITH PL/SQL AND IT IS URGENT -
Named parameters in stored function
Hi,
I am trying to execute stored function from java in oracle . I am using Oracle 9.2.0.1.0 and the newest JDBC drivers, ie. for 10g which are compatible. I have flicked through JDBC Named Parameters example but it only addresses stored procedures.
The problem I have is that I do not know what name the return value of stored procedure has.
stored function parameter names:
1. ????
2. test1 Mode: IN
3. test2 Mode: IN
?=call test_function(?,?);
When I am trying to set values as indexes everything works perfect.
CallableStatement cs = .....
cs.registerOutParameter(1, Types.VARCHAR);
cs.setString(2, "a");
cs.setString(3, "b");
cs.execute();
String returnedValue = cs.getString(1);
However, when I am trying to use named parameters the code looks like this:
CallableStatement cs = .....
cs.registerOutParameter(1, TYPES.VARCHAR);
cs.setString("test1", "a");
cs.setString("test2", "b");
and the question is what is the name of return parameter.
I have tried to put the same name as the name of stored function but is reports error.
Instead I had to first getmetadata from oracle and in case of stored functions utilize it, unfortunatelly getting metadata has perfomance issues and I heard that oracle 10g is even slower in getting metadata.
If anyone knows the answer to my question, please answer.
Thank you in advance,
Mateusz Szczap
Java Programmer
NCDC
[email protected]
http://www.ncdc.plHi,
I am trying to execute stored function from java in oracle . I am using Oracle 9.2.0.1.0 and the newest JDBC drivers, ie. for 10g which are compatible. I have flicked through JDBC Named Parameters example but it only addresses stored procedures.
The problem I have is that I do not know what name the return value of stored procedure has.
stored function parameter names:
1. ????
2. test1 Mode: IN
3. test2 Mode: IN
?=call test_function(?,?);
When I am trying to set values as indexes everything works perfect.
CallableStatement cs = .....
cs.registerOutParameter(1, Types.VARCHAR);
cs.setString(2, "a");
cs.setString(3, "b");
cs.execute();
String returnedValue = cs.getString(1);
However, when I am trying to use named parameters the code looks like this:
CallableStatement cs = .....
cs.registerOutParameter(1, TYPES.VARCHAR);
cs.setString("test1", "a");
cs.setString("test2", "b");
and the question is what is the name of return parameter.
I have tried to put the same name as the name of stored function but is reports error.
Instead I had to first getmetadata from oracle and in case of stored functions utilize it, unfortunatelly getting metadata has perfomance issues and I heard that oracle 10g is even slower in getting metadata.
If anyone knows the answer to my question, please answer.
Thank you in advance,
Mateusz Szczap
Java Programmer
NCDC
[email protected]
http://www.ncdc.pl
Maybe you are looking for
-
CFDiv - clearing the form after submission
I am using cfdiv with a data entry form and on submission writes the values to a db, works great, but, how can I clear the form after submission? reloading the page loads it in the cfdiv. TIA Jbird
-
About Nokia lumia 730 dual sim
may i known release date of this moblie in india i am waiting for this product
-
Bluetooth mouse not working on T430s
All my drivers are up to date, my mouse has new batteries, and I tried this fix: http://sherylcanter.com/wordpress/2010/01/bluetooth-mouse-losing-connection-no-more/ Now my bluetooth mouse only works after I reboot the computer, but then disconnects
-
What if an app is not installed on Mac but it shows the app is installed on App Store ?
I've recently bought MacBook Pro with Retina Display and got iLife for free. As the update for iMovie was not successfully installed due to lack for internet connectivity, I thought of removing it from from my mac and reinstall it. But as I opened th
-
Best cable modem & router combined?
I have the Motorola Surfboard SBG900, but was wondering if there are newer (and better) combo cable modem/wireless routers now available. Also, is cable still much faster than DSL, and, if not, are there good combined modem/routers for DSL? Thanks.