Stored procedure with cursor as out parameter
Can any one help me by showing how to write a procedure with cursor as out parameter and caputuring it in java using jdbc.
Thanks in advance,
shravan bharadwaj
I know that in the SQLJ distribution (which is also downloadable) there is an example in the demo directory called RefCursDemo that shows the SQL code and how to call it - albeit from SQLJ and not JDBC. There may also be a demo in the JDBC distribution, though I am not sure about that.
Similar Messages
-
With JDBC, calling a stored procedure with ARRAY as out parameter
Hi,
I want to use the data type ARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
my java program using JDBC.
The problem it's i use a 8.1.7 client to acces with oci to a 7.1.3 Database.
With this configuration I can get back a Cursor but not an Array.
Does it's possible ?
Thanks for your help !
MichaklOriginally posted by JDBC Development Team:
It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
cstmt.execute ();
ARRAY array = (ARRAY) cstmt.getObject (idx);
Thanks for your reply.
I have to use:-
OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
( "{call proj_array(?)}" ) ;
for retrieving a collection as an OUT parameter.
This gives me the errors:-
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
How do I get rid of these errors?
null -
Calling a stored procedure with VARRAY as out parameter using JDBC
Hi,
I want to use the data type VARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
my java program using JDBC.
I'm using Oracle 8.1.5 for Windows NT.
Please help me.
Thanks
Sumanta
nullOriginally posted by JDBC Development Team:
It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
cstmt.execute ();
ARRAY array = (ARRAY) cstmt.getObject (idx);
Thanks for your reply.
I have to use:-
OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
( "{call proj_array(?)}" ) ;
for retrieving a collection as an OUT parameter.
This gives me the errors:-
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
How do I get rid of these errors?
null -
Stored procedure with IN and OUT parameter
HI all,
here is code example
declare
in_dt date := '1-feb-2010' ;
col1 ...;
col2 ...;
col3 ...;
begin
select e.*
into col1,
col2,
col3
from table_xyz e
where e.start_dt = in_dt;
end;
How do i convert the above code into stored procedure by accepting "in_dt" as IN parameter and getting the result set displayed (output) through OUT parameter say "cur_out" (OUT paramter)
Thank you so much !!! I really appriciate it !!i ran my procedure which is very similar syndra posted
create or replace procedure foo(p_dt in date, cv out sys_refcursor) as
begin
open cv for
select e.*
from table_xyz e
where start_dt = p_dt;
end;
/Here is how is executed
DECLARE
P_DT DATE;
CV SYS_REFCURSOR;
BEGIN
P_DT := '10-oct-2005';
-- CV := NULL; Modify the code to initialize this parameter
scott.foo ( P_DT, CV );
COMMIT;
END;
-- i get PL/SQL procedure successfully complted , But i dont see the result set Or output
- How do i see the output when i m using refcursor ?? i tried using print , but nothing didnt work
- Any idea ??
Thank you!!
Edited by: user642297 on Jun 24, 2010 1:35 PM -
Call from Java Plsql Procedure with VArray as Out Parameter
Hi,
I have a Java web application(Tomcat server) that call a plsql procedure with Varray as OUT parameter.
The Plsql code is perfectly compiled.
When i run the application, I get the following error msg in my Tomcat window:
java.sql.SQLException: ORA-06530: Reference to uninitialized composite
ORA-06512: at "SEMS1.PACK_SEMSADMIN_OFFEREDJOBS", line 102
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:109
3)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStat
{color:#0000ff}
Doubt: Do I need to declare ArrayDescriptors to retrieve the VArray from the Plsql procedure.
I think the below statement is enough; we need ArrayDescriptors only when we we wish to send a Plsql Object or Varray from Java code to the procedure. Plz correct me if not so.
dbCallableStatement.execute();
ARRAY SimpleOUTArray = (ARRAY) ((OracleCallableStatement) dbCallableStatement).
getObject(Integer.parseInt(arlParameterOutIndex.get(i).toString()));{color}
I am unable to realize where the mistake is?
{color:#800000}
{color}{color:#800000}
VARRAY AND PROC DETAILS:
TYPE STRUCT_JOB_DETAILS AS OBJECT
APPL_NO NUMBER (10),
S_FNAME VARCHAR2 (32 Byte),
S_MI VARCHAR2 (32 Byte),
S_LNAME VARCHAR2 (32 Byte),
APPL_DATE DATE,
DESCRIPTION VARCHAR2 (100 Byte),
S_UCID VARCHAR2 (8 Byte)
TYPE VARRAY_JOB_DETAILS IS VARRAY(100) OF STRUCT_JOB_DETAILS;{color}
{color:#800000}PROCEDURE:{color}
{color:#800000}CREATE OR REPLACE PACKAGE PACK_SEMSADMIN_OFFEREDJOBS
AS
TYPE Generic_Cursor_Type IS REF CURSOR;
--TYPE varray_job_detail is VARRAY(100) OF STRUCT_JOB_DETAILS;
--va_varray_job_detail varray_job_detail := varray_job_detail();
va_varray_job_detail VARRAY_JOB_DETAILS := VARRAY_JOB_DETAILS();
PROCEDURE Admin_Jobs_Offered_Rtr
ic_status IN VARCHAR2,
or_offered_jobs OUT Generic_Cursor_Type,
va_varray_job_detail OUT VARRAY_JOB_DETAILS
CREATE OR REPLACE PACKAGE BODY PACK_SEMSADMIN_OFFEREDJOBS
AS
PROCEDURE Admin_Jobs_Offered_Rtr
ic_status IN VARCHAR2,
or_offered_jobs OUT Generic_Cursor_Type,
va_varray_job_detail OUT VARRAY_JOB_DETAILS
AS
vc_query VARCHAR2(15000) := '';
vc_query_1 VARCHAR2(15000) := '';
counter NUMBER := 1;
vc_no NUMBER := 0;
or_applicants_list Generic_Cursor_Type;
TYPE type_appln_list IS RECORD
job_no NUMBER(10),
job_title VARCHAR2(50 BYTE),
account_no VARCHAR2(10 BYTE),
head_fname VARCHAR2(32 BYTE),
head_minitial VARCHAR2(10 BYTE),
head_lname VARCHAR2(32 BYTE),
num NUMBER
vn_appln_list type_appln_list;
TYPE type_job_offered IS RECORD
APPL_NO NUMBER (10),
S_FNAME VARCHAR2 (32),
S_MI VARCHAR2 (32),
S_LNAME VARCHAR2 (32),
APPL_DATE DATE,
DESCRIPTION VARCHAR2 (100),
S_UCID VARCHAR2 (8)
vn_job_offered type_job_offered;
BEGIN
vc_query := vc_query || ' SELECT jobs.job_no,job_title, account_no, head_fname, head_minitial, head_lname, num';
vc_query := vc_query || ' FROM jobs, ( ' ;
vc_query := vc_query || ' SELECT jobs.job_no,count(*) as num' ;
vc_query := vc_query || ' FROM student_apps ,jobs ' ;
vc_query := vc_query || ' WHERE jobs.job_no = student_apps.job_no' ;
vc_query := vc_query || ' AND (student_apps.status in (''o'',''t'')) '; --|| ic_status || ')' ;
vc_query := vc_query || ' AND jobs.status not in (''z'', ''Z'')' ;
vc_query := vc_query || ' GROUP BY jobs.job_no' ;
vc_query := vc_query || ' ) no_apps_off' ;
vc_query := vc_query || ' WHERE jobs.job_no = no_apps_off.job_no' ;
dbms_output.put_line('Executed Query_1');
va_varray_job_detail := VARRAY_JOB_DETAILS();
va_varray_job_detail.extend(100);
OPEN or_offered_jobs FOR vc_query;
LOOP
FETCH or_offered_jobs INTO vn_appln_list;
EXIT WHEN or_offered_jobs%NOTFOUND;
vc_query_1 := '';
vc_query_1 := vc_query_1 || ' SELECT stud_apps.appl_no APPL_NO, stud_apps.s_fname S_FNAME, ';
vc_query_1 := vc_query_1 || ' stud_apps.s_mi S_MI, stud_apps.s_lname S_LNAME, ';
vc_query_1 := vc_query_1 || ' stud_apps.appl_date APPL_DATE, look_up.description DESCRIPTION, ' ;
vc_query_1 := vc_query_1 || ' stud_apps.s_ucid S_UCID ' ;
vc_query_1 := vc_query_1 || ' FROM student_apps stud_apps,jobs jbs,lookup look_up' ;
vc_query_1 := vc_query_1 || ' WHERE stud_apps.status in (''o'',''t'') '; --(' || ic_status || ') ' ;
vc_query_1 := vc_query_1 || ' AND jbs.job_no = stud_apps.job_no' ;
vc_query_1 := vc_query_1 || ' AND jbs.status not in (''z '', ''Z'')' ;
vc_query_1 := vc_query_1 || ' AND stud_apps.status = look_up.code ' ;
vc_query_1 := vc_query_1 || ' AND look_up.type = ''st''' ;
vc_query_1 := vc_query_1 || ' AND stud_apps.job_no = ''' || vn_appln_list.job_no || ''' ' ;
vc_query_1 := vc_query_1 || ' ORDER BY appl_date' ;
dbms_output.put_line('Executed Query_2');
OPEN or_applicants_list FOR vc_query_1;
LOOP
FETCH or_applicants_list INTO vn_job_offered;
EXIT WHEN or_applicants_list%NOTFOUND;
va_varray_job_detail(counter).APPL_NO := vn_job_offered.APPL_NO;
va_varray_job_detail(counter).S_FNAME := vn_job_offered.S_FNAME;
va_varray_job_detail(counter).S_MI := vn_job_offered.S_MI;
va_varray_job_detail(counter).S_LNAME := vn_job_offered.S_LNAME;
va_varray_job_detail(counter).APPL_DATE := vn_job_offered.APPL_DATE;
va_varray_job_detail(counter).DESCRIPTION := vn_job_offered.DESCRIPTION;
va_varray_job_detail(counter).S_UCID := vn_job_offered.S_UCID;
counter := counter + 1;
END LOOP; --end of FOR
CLOSE or_applicants_list;
END LOOP; -- end of FETCH
END Admin_Jobs_Offered_Rtr;
END PACK_SEMSADMIN_OFFEREDJOBS;
/{color}
Reqire help plzzzz !!!
Thanks.Originally posted by JDBC Development Team:
It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
cstmt.execute ();
ARRAY array = (ARRAY) cstmt.getObject (idx);
Thanks for your reply.
I have to use:-
OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
( "{call proj_array(?)}" ) ;
for retrieving a collection as an OUT parameter.
This gives me the errors:-
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
How do I get rid of these errors?
null -
Can Stored procedure with IN and OUT Paramter can be used in JDBC LOOKUP?
can Stored procedure with IN and OUT Paramter can be used in JDBC LOOKUP?
Checking online help, I do not see any possibility.
"Queries a data base by the given SQL statement."
http://help.sap.com/javadocs/pi/pi711sp03/com/sap/aii/mapping/lookup/DataBaseAccessor.html
-> execute -
Stored procedure with cursor as output param
It's the first time for me to test a stored procedure with a cursor as output parameter. I executed the following:
SQL> VARIABLE user_cur REFCURSOR; VARIABLE ret_code VARCHAR2; exec TEST_API.SEARCH_USER( :ret_code, '', '', 'john', '', :user_cur); print ret_code;print user_cur;
I got the following error:
Usage: VAR[IABLE] [ <variable> [ NUMBER | CHAR | CHAR (n [CHAR|BYTE]) |
VARCHAR2 (n CHAR) | NCHAR | NCHAR (n) |
NVARCHAR2 (n) | CLOB | NCLOB | REFCURSOR ] ]
May I know what's the problem?
The purpose of the stored procedure is to search for user with the name "john".
The stored procudure input/output params declaration is as follows:
PROCEDURE SEARCH_USER
RETURN_CODE OUT VARCHAR2,
USER_ID_IN IN VARCHAR2,
POSITION_IN IN VARCHAR2,
USERNAME_IN IN VARCHAR2,
STATUS_IN IN VARCHAR2,
USER_CUR_OUT OUT REFCURSOR
Edited by: user7383310 on Oct 19, 2008 9:05 PM
Edited by: user7383310 on Oct 19, 2008 9:05 PMfor the usage of refcursors in pl/sql refer here..
http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10807/06_ora.htm#sthref808
You can code like..
SQL> create or replace procedure p1(id number,csr out sys_refcursor) is
2 begin
3 open csr for select ename from emp where deptno = id;
4 end;
5 /
Procedure created.
SQL> var csr1 refcursor
SQL> var n number
SQL> exec :n := 30;
PL/SQL procedure successfully completed.
SQL> exec p1(:n,:csr1);
PL/SQL procedure successfully completed.
SQL> print csr1
ENAME
ALLEN
WARD
MARTIN
BLAKE
TURNER
JAMES
6 rows selected. -
Calling stored procedure with struct and boolean parameter
Hi all,
I am trying to write an EJB method using eclipselink that has to call a stored procedure which has the following parameters:
- an object type (in/out)
- a date (in)
- another date (in)
- a boolean (optional, in)
- a number (out)
- a string (out)
When using StoredProcedureCall, I succeed in passing the dates and the object type (as a STRUCT) into the procedure and read out the output variables. I can also do this using NamedStoredProcedureCall and only map the number and string in a result class. Drawbacks of NamedStoredProcedureCall:
- I cannot map the object type that comes back out (working example, anyone?)
- I cannot specify the boolean input variable
The problem is when I want to specify the boolean. In StoredProcedureCall, this is not possible since this only accepts native JDBC parameters. So I tried our PLSQLStoredProcedureCall.
Here, I can specify all in/out parameters except the object type! No matter what I try, I seem to end up with ORA-3115 - unsupported network datatype or representation. Does anyone have a working example on how to use this?
Regards,
Jeroen van Veldhuizen
REDORA B.V.The problem is not that I want to pass in a boolean. When I try to use PLSQLStoredProcedure, I do not succeed in passing in/out an object type (or STRUCT). It looks like the code has been made to access PLSQL record and table types by wrapping them in an object type, but it seems not to be possible to to use an object type directly.
To start with: when you create a STRUCT parameter, the generated sql code is this:
DECLARE
l_param_in STRUCT := :1;and since struct is not a datatype, this fails.
Jeroen -
Calling Stored Procedure with a DATE input parameter
Hi. A question about Date input parameters when calling a stored procedure...
I have a procedure that takes a DATE parameter as input. I would like that DATE value to include a Time element.
My Application Module method takes an input parameter as java.util.Date (myParamDate) - which will preserve a time element(?).
However when I create the CallableStatement, I'm trying to set the parameter using setDate like this (for param 5):
st = getDBTransaction().createCallableStatement("begin cs_my_pck.request_values(?,?,?,?,?,?,?,?); end;", 0);
Connection myConn = st.getConnection();
ArrayDescriptor myArrDesc = ArrayDescriptor.createDescriptor("CS_FIELD_TABT", myConn);
Array sqlParamNameArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramNames.toArray());
Array sqlParamValueArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramValues.toArray());
Array sqlFilterNameArray = new oracle.sql.ARRAY(myArrDesc,myConn,filterNames.toArray());
st.setString(1, repType);
st.setObject(2, sqlParamNameArray);
st.setObject(3,sqlParamValueArray);
st.setObject(4,sqlFilterNameArray);
java.sql.Date myRepDate = new java.sql.Date(myParamDate.getTime());
st.setDate(5,myRepDate);
System.out.println("Report Date = " + myRepDate.toString());
st.setString(6,repUser);
st.setString(7,repAttach);
// set out param
st.registerOutParameter(8, Types.NUMERIC);
st.execute();I understand java.sql.Date does NOT include a Time element. But setDate() accepts only a java.sql.Date so my procedure parameter ends up with a zero time element.
How do I call this procedure retaining the Time element?
Thanks.It includes time element, if you want more precision go with timestamp.
http://docs.oracle.com/javase/6/docs/api/java/sql/Date.html -
Java call stored procedure with nested table type parameter?
Hi experts!
I need to call stored procedure that contains nested table type parameter, but I don't know how to handle it.
The following is my pl/sql code:
create or replace package test_package as
type row_abc is record(
col1 varchar2(16),
col2 varchar2(16),
col3 varchar2(16 )
type matrix_abc is table of row_abc index by binary_integer;
PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
p_arg2 IN VARCHAR2,
p_arg3 IN VARCHAR2,
p_out OUT matrix_abc
END test_package;
create or replace package body test_package as
PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
p_arg2 IN VARCHAR2,
p_arg3 IN VARCHAR2,
p_out OUT matrix_abc
IS
v_sn NUMBER(8):=0 ;
BEGIN
LOOP
EXIT WHEN v_sn>5 ;
v_sn := v_sn + 1;
p_out(v_sn).col1 := 'col1_'||to_char(v_sn)|| p_arg1 ;
p_out(v_sn).col2 := 'col2_'||to_char(v_sn)||p_arg2 ;
p_out(v_sn).col3 := 'col3_'||to_char(v_sn)||p_arg3 ;
END LOOP ;
END ;
END test_package ;
My java code is following, it doesn't work:
Class.forName ("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection
("jdbc:oracle:thin:@10.16.102.176:1540:dev", "scott", "tiger");
con.setAutoCommit(false);
CallableStatement ps = null;
String sql = " begin test_package.test_matrix( ?, ? , ? , ? ); end ; ";
ps = con.prepareCall(sql);
ps.setString(1,"p1");
ps.setString(2,"p2");
ps.setString(3,"p3");
ps.registerOutParameter(4,OracleTypes.CURSOR);
ps.execute();
ResultSet rset = (ResultSet) ps.getObject(1);
error message :
PLS-00306: wrong number or types of arguments in call to 'TEST_MATRIX'
ORA-06550: line 1, column 8:
PL/SQL: Statement ignored
Regards
LouisLouis,
If I'm not mistaken, record types are not allowed. However, you can use object types instead. However, they must be database types. In other words, something like:
create or replace type ROW_ABC as object (
col1 varchar2(16),
col2 varchar2(16),
col3 varchar2(16 )
create or replace type MATRIX_ABC as table of ROW_ABC
/Then you can use the "ARRAY" and "STRUCT" (SQL) types in your java code. If I remember correctly, I recently answered a similar question either in this forum, or at JavaRanch -- but I'm too lazy to look for it now. Do a search for the terms "ARRAY" and "STRUCT".
For your information, there are also code samples of how to do this on the OTN Web site.
Good Luck,
Avi. -
Calling a Stored Procedure with a IN OUT VAR
Hi
I'm trying to call an oracle stored procedure and get a return code if it completely ran successfully. This is my first time doing this and would really appreciate some
PROCEDURE P_NP_OVERDUE_COMPLETED
(P_YEAR_NO IN NUMBER, P_WEEK_NO IN NUMBER,
P_RETURN_CODE IN OUT VARCHAR2)
I get the following error: One or more errors occurred during processing of command.
Dim OleDBCon As New OleDbConnection
Dim conStr As String = "Provider=MSDAORA;Data...................."
OleDBCon.ConnectionString = conStr
Dim OleDBCMD = New OleDbCommand _
("{call p_np_overdue_completed(?,?,{VARCHAR2(255), P_RETURN_CODE})}", OleDBCon)
OleDBCMD.CommandType = CommandType.Text
OleDBCMD.Parameters.Add("P_YEAR_NO", OleDbType.Numeric).Value = year
OleDBCMD.Parameters.Add("P_WEEK_NO", OleDbType.Numeric).Value = i
Dim myadapter As New OleDbDataAdapter(OleDBCMD)
OleDBCon.Open()
myadapter.Fill(ds)Originally posted by JDBC Development Team:
It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
cstmt.execute ();
ARRAY array = (ARRAY) cstmt.getObject (idx);
Thanks for your reply.
I have to use:-
OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
( "{call proj_array(?)}" ) ;
for retrieving a collection as an OUT parameter.
This gives me the errors:-
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
import java.sql.*;
^
How do I get rid of these errors?
null -
Procedure with table type out parameter
Hi,
I need to create a procedure which gives back a content of a table as an out parameter.
i have tried something like below code
it might not be correct since i am writing from home and cannot access any oracle db right now
create or replace procedure test (
table_out test_table%rowtype
) as
type table_out test_table%rowtype
begin
select * into table_out
from test_table
where country = 'HUN';
end;
compile doesnt gives error, but when running it i get error
declare
table_out test_table%rowtype
begin
test( table_out );
dbms_output.put_line( table_out );
end;
but it fails, could you help how to solve the above problem and call the proc correctly?
thanks in advanceWell you said you want the content of a table but your example says you just want a record. So for a record:
CREATE OR REPLACE PROCEDURE sp_test (EMP_REC OUT EMP%ROWTYPE) IS
BEGIN
select * into emp_rec from emp where empno = 7369;
END;The anonymous block to run it might be:
declare
tab_out emp%rowtype;
begin
sp_test(tab_out);
dbms_output.put_line(tab_out.ename);
end;As damorgan said the dbms_output can't be used with the record type. Notice I used it for the ENAME value of the record.
If you really want the entire table then do it the way damorgan suggests. A pipeline function can give you the table but not as an OUT parameter. -
Calling a stored procedure with array as IN parameter
Hi,
I need to invoke a stored procedure which actually requires 2 IN parameters , both are ARRAY of numbers.. Can anyone tell me using JDBC callableStatement how to invoke this stored procedure?
how to pass array of numbers as input to stored procedure? also what is the corresponding JAVA data type?
the procedure definition is as follows:
PROCEDURE update_group
( in_username IN consumers.consumer_name%type,
in_group_id IN account_group.acct_grp_id%type,
in_group_name IN account_group.acct_grp_dsply_nm%type,
in_group_type IN account_group.acct_group_type_cd%type,
in_rem_accts_arr IN number_array,
in_add_accts_arr IN number_array,
out_over_max_ind OUT integer);
thanks in advanceHi,
You need to define a Call Spec like the following (assume NVarrayClass class):
create or replace procedure nvaproc (x IN OUT number, y IN OUT
NVARRAY,
z IN NVARRAY)
as language java
name 'NVarrayClass.nvaproc(oracle.sql.NUMBER[], java.sql.Array[],
java.sql.Array)';
show errorsI have tons of examples of array in chapter 3 and 8 of my book. The code depot is available @ http://books.elsevier.com/companions/1555583296?country=United+States
Kuassi http://db360.blogspot.com -
How to execute a procedure with Object as OUT parameter
Hi,
I have a procedure and it consists 2 parameter, one is an input parameter and that is some ID (NUMBER datatype) and 2nd parameter is an out parameter and it an Object type. I want to execute that procedure but not able to do the same. Can anyone please suggest me how do I execute a procedure which has got Object as an out parameter.
Thanks a lot in advance for your support.Example:
SQL> create or replace type t_obj as object (ename varchar2(10), deptno number);
2 /
Type created.
SQL> ed
Wrote file afiedt.buf
1 create or replace procedure myproc (p_empno in number, obj out t_obj) is
2 begin
3 select t_obj(ename, deptno)
4 into obj
5 from emp
6 where empno = p_empno;
7* end;
SQL> /
Procedure created.
SQL> set serverout on
SQL> declare
2 v_obj t_obj;
3 begin
4 myproc(7788, v_obj);
5 dbms_output.put_line(v_obj.ename||','||v_obj.deptno);
6 end;
7 /
SCOTT,20
PL/SQL procedure successfully completed. -
Java Stored Procedure with LOB as input parameter (oracle 9i 9.2.0.6)
Hi,
Is there a way to pass CLOB as input and output as part of java stored proceudre in oracle 9i (9.2.0.6)?
I have to perform some data conversion on the CLOB data in java program and return the converted CLOB as output.
--Ramesh LokineniThe reason why I want to use java for conversion is because, I want to perform base64 encoding decoding on the content stored in CLOB column. I tried to use by chunking the data into smaller pieces and apply the base64 encoding, but when I decode the CLOB using base64, I am not getting the same data. Later when I read about how base64 encoding happens I realized chunking the data in CLOB doesn't work. That's when I started to diggin how I can pass CLOB to java stored procedures.
Maybe you are looking for
-
New message in Mail; old message from a year ago being opened
Okay, so here's a weird one. It is the second time it has happened in a week. I go to open a new message, however when I open it an old message from a year ago opens up in its place. It isn't even a year to date issue. For instance today (October 15)
-
Sales data not replicated for materials from ECC
Hello Experts, When creating a meterial in ECC, the same gets replicated to CRM 7, but the data maintained in the sales tabs of ECC is not getting replicated to the CRM material master Sales & Distribution tab. I have already maintained the correspon
-
Problem with General Ledger Budget Load
Hi All, We are experiencing an issue wherein the Budget figures for general ledger are incorrect in the cube. The data-flow is 0FI_GL_10 to DSO (daily delta) to Cube (daily delta). There is a singular DSO and Cube for Actuals and Budgets. The figures
-
I am trying to write a grep search for the first instance of a word in a paragraph.
How can I identify only the first instance of 'FREE' in a paragraph and apply a style to it, without also styling the 2nd or more instance of the word? Thanks
-
? about Flip Horizontal w/ paths
I'm a bit of a newbie and had a question. I'm learning how to use the drawing tools in Photoshop. I've drawn a simple path, and select it with the Path Selection tool. The problem is when I go to Edit > Transform Path, the Flip Horizontal, Flip Verti