Error in ref cursor coding
Error in refcursor
Edited by: josh1612 on Feb 18, 2010 8:40 PM
The code of that procedure is
tId;
Edited by: josh1612 on Feb 18, 2010 8:41 PM
Similar Messages
-
Hi all,
I have a package, and I am using the ref Cursor in my procedure. Here it is .....
CREATE OR REPLACE PACKAGE BLABLA_PKG AS
TYPE OUT_CURSOR IS REF CURSOR;
PROCEDURE BLABLA_VIEW_PROCEDURE (BUS_ID IN VARCHAR2,
XML_OUTPUT_CURSOR OUT OUT_CURSOR);
END BLABLA_PKG;
CREATE OR REPLACE PACKAGE BODY BLABLA_PKG AS
PROCEDURE BLABLA_VIEW_PROCEDURE (BUS_ID IN VARCHAR2,
XML_OUTPUT_CURSOR OUT OUT_CURSOR)
IS
V_CURSOR OUT_CURSOR;
BEGIN
OPEN V_CURSOR FOR
SELECT SYS.XMLTYPE.getClobVal(OBJECT_VALUE)
FROM MBR_VIEW
WHERE extractValue(OBJECT_VALUE, '/BLABLA_TYPE/BUS/BUS_ID') = 456451232;
END V_CURSOR;
END BLABLA_PKG;
WHEN I try to run the procedure its throwing an error as...
Error(12,9): PLS-00113: END identifier 'V_CURSOR' must match BLABLA_VIEW_PROCEDURE' at line 2, column 16
Can anyone help me out from this please??Thank you Bakker and sorry for my ignorance.
And I have modified my packagage and compiled. Now i would like to execute the package. How would i do that?
CREATE OR REPLACE PACKAGE BLABLA_PKG AS
PROCEDURE BLABLA_VIEW_PROCEDURE (BLABLA_XML_RS OUT SYS_REFCURSOR, BUS_ID IN VARCHAR2
END BLABLA_PKG;
CREATE OR REPLACE PACKAGE BODY BLABLA_PKG AS
PROCEDURE BLABLA_VIEW_PROCEDURE (BLABLA_XML_RS OUT SYS_REFCURSOR, BUS_ID IN VARCHAR2
IS
BEGIN
OPEN BLABLA_XML_RS FOR
SELECT SYS.XMLTYPE.getClobVal(OBJECT_VALUE)
FROM BLABLA_VIEW
WHERE extractValue(OBJECT_VALUE, '/BLABLA_TYPE/BUS/BUS_ID') = BUS_ID;
END BLABLA_VIEW_PROCEDURE;
END BLABLA_PKG;
I am trying to execute it in the fallowing way, which is not working
Execute BLABLA_PKG.BLABLA_VIEW_PROCEDURE(1111222, BLABLA_XML_RS);
Could you please help me out.... -
Hi,
I have a problem retrieving a ResultSet from a REF CURSOR. I am using and OCI driver and Oracle 9i.
Mi Code is like this:
public static void main(String[] args) throws ClassNotFoundException,
SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(
"jdbc:oracle:oci:@XXXXX", "login", "password");
CallableStatement cs = conn.prepareCall("{?=call package.name(P_CODIGO => ?)}");
cs.registerOutParameter(1,OracleTypes.CURSOR);
cs.setInt(2,16782);
cs.executeQuery();
ResultSet result = ((OracleCallableStatement)cs).getCursor(1);
result.next();
ResultSetMetaData rsmd = result.getMetaData();
for(int i = 0; i < rsmd.getColumnCount();i++){
System.out.println(rsmd.getColumnName(i) + ": " + (result.getObject(i)).toString());
cs.close();
conn.close();
Whe I try to get the ResultSet:
ResultSet result = ((OracleCallableStatement)cs).getCursor(1);
I receive an error like this:
java.lang.UnsatisfiedLinkError: make_statement
at oracle.jdbc.oci8.OCIDBAccess.make_statement(Native Method)
at oracle.jdbc.oci8.OCIDBAccess.RefCursorBytesToDBStatement(OCIDBAccess.java:2401)
at oracle.jdbc.driver.OracleStatement.getCursorValue(OracleStatement.java:3865)
at oracle.jdbc.driver.OracleCallableStatement.getCursor(OracleCallableStatement.java:793)
at pruebas.Callable.main(Callable.java:44)
Exception in thread "main"
In the web I found some examples but using a thin driver. In my case I must use the OCI driver.
If somebody have any idea about the cause of this problem, please, tell me.
regards,
Alvarohi,
Mine is a standalone class which just calls a stored procedure which returns a REF CURSOR. When i try using getObject() method, i am getting the same error. i understand this is more of a configuration issue rather than a code issue. i have also called some other procedures from my class, which do some updates, etc and which are working fine. The error is as follows:-
Exception in thread "main" java.lang.UnsatisfiedLinkError: make_statement
at oracle.jdbc.oci8.OCIDBAccess.make_statement(Native Method)
at oracle.jdbc.oci8.OCIDBAccess.RefCursorBytesToDBStatement(OCIDBAccess.java:2419)
at oracle.jdbc.driver.OracleStatement.getCursorValue(OracleStatement.java:3836)
at oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:6039)
at oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:5827)
at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:698)
at com.fmr.fims.common.StagingDatabaseHandler.getBatchListForStatus(StagingDatabaseHandler.java:160)
at com.fmr.fims.common.StagingDatabaseHandler.main(StagingDatabaseHandler.java:39)
i am unable to get to any solution to this issue. Trying not to use ResulSet wont work because the cursor does have a variable number of records which need to be retrieved one by one.
Somebody please help. This is urgent.
My code snippet is :-
Connection conn = getConnection();
CallableStatement stmt = conn.prepareCall("{call FEBCHK_ACTIONS.SP_GET_FAILED_BATCH_DOCS(?)}");
stmt.registerOutParameter(1,oracle.jdbc.OracleTypes.CURSOR);
boolean exec = stmt.execute();
if(exec){
ResultSet rs = (ResultSet)stmt.getObject(1);
while(rs.next()){.......
The line
ResultSet rs = (ResultSet)stmt.getObject(1);
gives the error. -
I'm trying to return a REF CURSOR from a function and get the following error:
ORA-00932: inconsistent datatypes: expected CURSER got NUMBER
ORA-06512: at "CERTS.JIMMY", line 17
ORA-06512: at line 10
Here is my function:
CREATE OR REPLACE PACKAGE jimmy
AS
TYPE refc IS REF CURSOR
RETURN equipment%rowtype;
FUNCTION getresults(p_ssan_in IN equipment.ssan%TYPE,
p_type_in IN equipment.equip_type%TYPE)
RETURN refc;
END jimmy;
CREATE OR REPLACE PACKAGE BODY jimmy
AS
FUNCTION getresults( p_ssan_in IN equipment.ssan%TYPE,
p_type_in IN equipment.equip_type%TYPE)
RETURN refc
IS
l_cursor refc;
isretired equipment.retired%TYPE := 'N';
qry varchar2(100) := 'SELECT * ' ||
'FROM equipment ' ||
'WHERE ssan = :b1 ' ||
'AND equip_type = :b2 ' ||
'AND retired = :b3';
BEGIN
EXECUTE IMMEDIATE qry
INTO l_cursor
USING p_ssan_in, p_type_in, isretired;
RETURN l_cursor;
END getresults;
END jimmy;
The data types for the parameters are all varchar2. I don't know why it says it is returning a number.I tried your suggestion:
BEGIN
OPEN l_cursor
FOR qry
USING p_ssan_in, p_type_in, isretired;
RETURN l_cursor;
END getresults;
But I get an error:
PLS-00455: cursor 'L_CURSOR' cannot be used in dynamic SQL OPEN statement -
How to clear the run time error in ref cursor
good morning every one,
the code as follows
create or replace
procedure Country_sel(key in varchar2)
as
cc Res_RelcountryLan.countrycode%type;
len Res_Language.langname_en%type;
lid Res_Language.langid%type;
ab Res_Language.Abrivation%type;
type refcursorr is ref cursor;
cur refcursorr;
d_stmt varchar2(100);
begin
d_stmt := 'select RCL.countrycode,RL.langid,RL.langname_'||key||',
RL.Abrivation from Res_RelCountryLan RCL inner join Res_Language RL ON RCL.LangId = RL.LangId';
open cur for d_stmt;
loop
fetch cur into cc,lid,len,ab;
if cur%found then
dbms_output.put_line(cc||lid||len||ab);
else
exit;
end if;
end loop;
close cur;
commit;
end Country_sel;when i am running this code im getting
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
ORA-06512: at "RASOOL.COUNTRY_SEL", line 11
ORA-06512: at line 6can you please help me in getting rid of this problem.
thanking you,
prakashd_stmt varchar2(100); Increase the size of d_stmt. Your a assigning a larger string
d_stmt := 'select RCL.countrycode,RL.langid,RL.langname_'||key||',RL.Abrivation from Res_RelCountryLan RCL inner join Res_Language RL ON RCL.LangId = RL.LangId'; The size of the above string is more than 100 characters. -
Invalid SQL error using REF CURSOR
I'm getting an "invalid SQL statement" in my function that is returning a REF CURSOR. I have tested this function in SQL*Plus and it works fine.
-- package level variable
TYPE t_cursor IS REF CURSOR;
Function find_patient
p_ssan IN varchar2,
p_patient_details OUT t_cursor
RETURN t_cursor
IS
v_cursor t_cursor;
BEGIN
OPEN v_cursor FOR
SELECT name,sex,pay_grade,
FLOOR(MONTHS_BETWEEN(sysdate,birthdate) / 12) AS age,
patient_num
FROM patient
WHERE ssan = p_ssan;
p_patient_details := v_cursor;
RETURN p_patient_details;
END find_patient;
-- C# code
OracleParameter ssan_in = new OracleParameter("p_ssan",OracleDbType.Varchar2);
OracleParameter cursor_out = new OracleParameter("p_patient_details",OracleDbType.RefCursor);
cmd.Parameters.Add(ssan_in).Direction = ParameterDirection.Input;
cmd.Parameters.Add(cursor_out).Direction = ParameterDirection.Output;
ssan_in.Value = "555555555";
OracleRefCursor cur = (OracleRefCursor) cursor_out.Value;
try
dbconn.Open();
OracleDataReader dr = cmd.ExecuteReader();
while (dr.Read())
pat_name.Text = dr["NAME"].ToString();
age.Text = dr["AGE"].ToString();
rank.Text = dr["PAY_GRADE"].ToString();
gender.Text = dr["SEX"].ToString();
pat_num.Text = dr["PATIENT_NUM"].ToString();
Any suggestions?First, you have an output parameter of type ref cursor and a return value. You shouldn't have both.
Second, try CommandType.Text and a CommandText like:
"begin :rc := find_patient(:ssan); end;"
It's easier to see how to bind the parameters like that. Bind first a OracleRefCursor output parameter, then an ssan%type InputParameter.
David -
Odd error while opening a ref cursor
Hi.
I have a procedure in a package that has both in and out parameters. One of those out parameters is a ref cursor. The procedure creates a dynamic query and then executes it, then it opens the cursor:
PROCEDURE PROC(
A IN VARCHAR2,
B IN VARCHAR2,
C OUT TYPES.cursorType; --(TYPES is a package whose only use is to declare a cursor type)
) IS
--DECLARATIONS
OPEN C FOR 'SELECT A, B, C, D...';
END;
When I execute the package in an anonymous block it throws the error:
ORA-00938: not enough arguments for function, just in the line where the cursor is being opened.
Any ideas?is everything defined correctly?
create or replace package types as
type cursorType is ref cursor;
end types;
SQL> set serveroutput on
SQL> declare
2
3 ref_C types.cursorType;
4
5 v_a varchar2(1);
6 v_b varchar2(1);
7 v_c varchar2(1);
8 v_d varchar2(1);
9
10 procedure Proc (a in varchar2
11 ,b in varchar2
12 ,C out types.cursorType) as
13
14 begin
15 open C for 'select :1, :2, ''c'', ''d'' from dual' using a, b;
16 end Proc;
17 begin
18
19
20 Proc('a', 'b', ref_C);
21
22 fetch ref_C into v_a, v_b, v_c, v_d;
23 if (ref_C%found) then
24 dbms_output.put_line(v_a);
25 dbms_output.put_line(v_b);
26 dbms_output.put_line(v_c);
27 dbms_output.put_line(v_d);
28 end if;
29
30
31 end;
32 /
a
b
c
dP;
Edited by: bluefrog on Feb 18, 2010 6:07 PM -
Error while working with ref cursor
Hi I tried the following but getting the err
DECLARE
TYPE ref_nm IS REF CURSOR;
vref REF_NM;
vemp emp%rowtype;
BEGIN
OPEN vref FOR SELECT ename ,sal FROM EMP;
LOOP
FETCH vref INTO vemp;
EXIT WHEN vref%NOTFOUND;
DBMS_OUTPUT.PUT_LINE ( vemp.ename ||','||vemp.sal );
END LOOP;
CLOSE vref;
END;Error is
ORA-06504: PL/SQL: Return types of Result Set variables or query do not matchSyntactically correct - but a horrible approach performance wise if you only need specific columns.
The basic problem here is using the wrong tool. A ref cursor. Why? There's no reason in this code for using a ref cursor. Using a standard cursor data type addresses the requirement a lot better.
As you can define the cursor:
cursor myCursor is select c1, c2 from tab1;
You can define an array data type for fetching that cursors data - and thus definition does not need to be touched when you change the cursor itself to include/exclude columns:
type TMyCursorBuffer is table of myCursor%RowType;
And finally you can define a bulk collection buffer for bulk processing the output of the cursor:
myBuffer TMyCursorBuffer; -
XSQL ERROR with bind-params in ref-cursor-function
Hi Steve
I always get the error
ORA-01006 bind variable does not exist
when using a bind variable in a <xsql:ref-cursor-function> action element.
when I replace the bind variable with a @ - parameter substitution, all works fine.
My configuration:
XSQL 1.0.4.1 on Win200Pro ,Apache + Jserv + DB from ORA 8.1.7 installation
My Source
<xsql:ref-cursor-function
dbconn="ekat"
eblike="%"
list="a0"
bind-params="eblike"
include-schema="no"
null-indicator="no"
id-attribute=""
fetch-size="500"
>
{@dbconn}o.ekatkategcv.open_cv_ebh ('{@list}', :1)
</xsql:ref-cursor-function>
( dbconn selects my schema, not changed often, which contains package ekatkategcv with
function open_cv_ebh returning a cursor)
Any fix would be appreciated to avoid reparsing on each call.
BTW, is it right, that a ref-cursor funtion is reparsed whenever the content of
a parameter used with @ changes?
Best regards
H.Buschmann ([email protected])
nullI have tried it using ? instead of :1, this method works fine.
I haven't tried the name method (:bindvar) yet.
Until now, I only used xsl:query and xsql:ref-cursor-function, so I didn't check
the other action handlers with bind variables like :1
null -
In Ref cursor, user defined functions give "invalid column" error in EJB.
Hello,
I have written PL/SQL stored procedures/functions in Oracle 8i. They return the result set as a ref cursor.
These procedures are accessed by EJB (weblogic) using Type 4 (100% Java) JDBC Driver.
My problem is - if I use a user defined function to fetch a value in the select statement of the reference cursor, the EJB gives an error msg - invalid column name.
If instead of using the function I get the value directly from the table, it works fine. Refer the code below :
//In the PL/SQL function -
//instead of writing :
Open rc for
Select empcode, empname
from emp ;
//If I write :
Open rc for
Select empcode, mypack.getempname(empcode)
from emp ;
//getempname(empcode) is a function in
//in a package named 'mypack'
//and returns name for empcode.
//The java code gives error
//error : invalid column name
//While both are working fine and
//returning currect result in SQL Navigator.
Help me solve this mystery ?
Thanks in advance.
Swati.
nullHi:
When use inline Function to simplify the SQL statements, there is one thing that one should conside--Purity Level.
if you create standalone stored pl/sql function. Oracle implicitly determines the PURITY level during compilation of the stored objects or at execution of an anonymous pl/sql block.
if you implement Package inline Function( in your case),unlike standalone stored pl/sql functions, the PL?SQL Engine does not determine the purity level of package functions. Therefore, you must explicity assign the correct purity levels for the function to be called inline.
the code like:
create or replace package mypack is
function getempname(empcode emp%empid%type)
return varchar2;
PRAGMA RESTRICT_REFERENCES(getempname,WNDS,WNPS,RNPS);
end mypack;
I think it can solve your problem if you use enough "pure"to be called inline function. Or you can create the standalone function to do it.
good luck!
Yali
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Swati Agrawal ([email protected]):
Hello,
I have written PL/SQL stored procedures/functions in Oracle 8i. They return the result set as a ref cursor.
These procedures are accessed by EJB (weblogic) using Type 4 (100% Java) JDBC Driver.
My problem is - if I use a user defined function to fetch a value in the select statement of the reference cursor, the EJB gives an error msg - invalid column name.
If instead of using the function I get the value directly from the table, it works fine. Refer the code below :
//In the PL/SQL function -
//instead of writing :
Open rc for
Select empcode, empname
from emp ;
//If I write :
Open rc for
Select empcode, mypack.getempname(empcode)
from emp ;
//getempname(empcode) is a function in
//in a package named 'mypack'
//and returns name for empcode.
//The java code gives error
//error : invalid column name
//While both are working fine and
//returning currect result in SQL Navigator.
Help me solve this mystery ?
Thanks in advance.
Swati.
<HR></BLOCKQUOTE>
null -
Different error messages from different env while fetching ref cursor
Hi<br>
I have a package where i need to call one of the procedure.I this <br>
procedure i am returning a refcursor as out parameter.Before returning refcursor i <br>
am doing i am checking a condition if it is satisfied then I am saying return or else<br>
it will proceed and refcursor is assigned for out parameter.So i am speakig about <br>
the condition where i am exiting from procedure before refcursor parameter is <br>
assigned .And later i am tring to fetch from that cursor .So i am getting different <br>
kinds of errors which i described as follows <br>
<br>
<br>
So If execute that procedure from sqlplus uing <br>
<br>
<br>
var m ref cursor<br>
DECLARE<br>
Y NUMBER;<br>
Z NUMBER;<br>
A NUMBER;<br>
BEGIN<br>
A:=campa.dtl_inq(2,100070875,'R',Y,Z,:M);<br>
END;<br>
<br>
Then if say<br>
Print m<br>
It gives <br>
<br>
ORA-24338: statement handle not executed<br>
<br>
And if i execute this using vb application <br>
<br>
I am getting following error <br>
<br>
ORA-01023: Cursor context not found (Invalid cursor number)<br>
<br>
So i am serching the reason for different errors<br>
<br>
Regards<br>
vamsi krishna<br>The error depends on exactly what OCI calls the client software makes in accessing this invalid (null) ref cursor variable.
It would seem that SQL*Plus makes different calls than what your code and Visual Basic does - thus the different error messages returned by the two applications. -
hi
i tried the following but getting the error.. Could you help me in this please
SQL> create or replace package curpack as
2 type T_CUR is ref cursor;
3 procedure CHECKDYNREF (io_cur out T_CUR);
4 end curpack;
5 /
Package created.
SQL>
SQL> create or replace package body curpack as
2 procedure CHECKDYNREF (io_cur out T_CUR);
3 is
4 begin
5 open io_cur for 'SELECT * FROM EMP';
6 end;
7 end curpack;
8 /
Warning: Package Body created with compilation errors.
SQL> sho err
Errors for PACKAGE BODY CURPACK:
LINE/COL ERROR
3/3 PLS-00103: Encountered the symbol "IS" when expecting one of the
following:
begin end function package pragma procedure subtype type use
<an identifier> <a double-quoted delimited-identifier> form
current cursor
7/1 PLS-00103: Encountered the symbol "END"Thanks...
Edited by: josh1612 on Jan 24, 2010 9:05 PMHi,
There should not be a ';' (semi colon ) after the declaration of procedure in package body
SQL> create or replace package body curpack as
procedure CHECKDYNREF (io_cur out T_CUR);
is
begin
open io_cur for 'SELECT * FROM EMP';
end;
end curpack;
/ Something like above
Regards -
Hi,
I have written a jdbc application which return a ref cursor. I use ResultSet rset = ((OracleCallableStatement)call).getCursor (1); to get the result set according to jdbc user guide. Compilation is ok but when I run it, the error is:
Exception in thread "main" java.sql.SQLException: Ref cursor is invalid
at java.lang.Throwable.fillInStackTrace(Native Method)
at java.lang.Throwable.fillInStackTrace(Compiled Code)
at java.lang.Throwable.<init>(Compiled Code)
at java.lang.Exception.<init>(Exception.java:42)
at java.sql.SQLException.<init>(SQLException.java:43)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:219)
at oracle.jdbc.driver.OracleStatement.getCursorValue(OracleStatement.java:2544)
at oracle.jdbc.driver.OracleCallableStatement.getCursor(OracleCallableStatement.java:583)
at useCursor.main(useCursor.java:41)
I attach the code for ur reference. Pls point out to me what's wrong.
import oracle.sql.*;
import oracle.jdbc.oracore.Util;
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
class useCursor{
private static final String Server = "job.comp.edu.au:1521:testing";
private static final String Username = "user";
private static final String Password = "org";
public static void main (String args [])
throws SQLException
// Connect to the database
// You can put a database name after the @ sign in the connection URL.
Connection conn = getConnection ();
String elements[] = new String[1];
elements[0] = "select * from product";
// Create the stored procedure
init (conn);
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("STR_VARRAY3", conn);
ARRAY newArray = new ARRAY(desc, conn, elements);
// Prepare a PL/SQL call
CallableStatement call =
conn.prepareCall ("{ ? = call java_refcursor.job_listing (?)}");
// Find out all the SALES person
call.registerOutParameter (1, OracleTypes.CURSOR);
((OraclePreparedStatement)call).setARRAY(2, newArray);
call.execute ();
ResultSet rset = ((OracleCallableStatement)call).getCursor (1);
// Dump the cursor
while (rset.next ())
System.out.println (rset.getString ("AUTHOR"));
// Utility function to create the stored procedure
static void init (Connection conn)
throws SQLException
Statement stmt = conn.createStatement ();
try
stmt.execute ("DROP TYPE str_varray3");
catch (SQLException e)
// the above drop statements will throw exceptions
// if the types and tables did not exist before. Just ingore it.
stmt.execute ("CREATE TYPE str_varray3 AS VARRAY(10) OF VARCHAR2(50)");
stmt.execute ("create or replace package java_refcursor as " +
" type myrctype is ref cursor; "+
" function job_listing (sa str_varray3) return myrctype; " +
"end java_refcursor;");
stmt.execute ("create or replace package body java_refcursor as " +
" function job_listing (sa str_varray3) return myrctype is " +
" rc myrctype; " +
" i number; " +
" begin " +
" while sa.COUNT >= i" +
" loop " +
" open rc for sa(1);" +
" exit when rc%NOTFOUND; " +
" i := i + 1; " +
" end loop; " +
" return rc; " +
" end; " +
"end java_refcursor;");
public static Connection getConnection(){
Connection con = null;
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
catch (SQLException sqlex ) {
System.err.println("Unable register Oracle driver");
sqlex.printStackTrace();
try {
con = DriverManager.getConnection("jdbc:oracle:thin:@" + Server, Username, Password);
catch (SQLException sqlex) {
System.err.println("Unable to connect");
sqlex.printStackTrace();
return con;
Please advise me. Thank you very much.
nulli have found out my mistake
it lacks of i := 0;
my mind was not so ok then.. :) -
Cast error message when discovering ref cursor parameter from stored proced
We are today using Microsoft's Oracle provider with some code from the old Data Application Block (from MSDN) to discover parameters from the stored procedures. This code uses the OracleCommandBuilder.DeriveParameters to get the parameters from the stored procedure and command.Parameters.CopyTo copies the discovered parameters into the command object.
If I test with a simple function returning a ref cursor I get one parameter with type refCursor and ParameterDirection.OutPut. This is working fine as long we where using Microsoft's Oracle provider. But using Oracle ODP .NET I get the following error message on datadapter.Fill (I fill a dataset with the result from the reference cursor)
Unable to cast object of Type 'Oracle.DataAccess.Client.OracleDataReader' to type 'Oracle.DataAccess.Types.OracleRefCursor.
If I create a ref parameter manualy like this:
OracleParameter myrefCursor = new OracleParameter();
myrefCursor .OracleDbType = OracleDbType.RefCursor;
myrefCursor .ParameterName = "myParameterName";
myrefCursor .Direction = ParameterDirection.ReturnValue;
and add it to the command object this is working OK. So it seems to be a problem with discovering ref cursor parameters from the database, other parameter types is OK.. I have compared the properties of my manual ref cursor parameter with the one discovered from the stored procedure, but I cannot see any difference. (I see the Value property has some values for the discovered one, but I have set this to DBNull.Value without any result)
Any ideas why I get this error code? Is there any other code blocks I can use to discover the parameters? We send in params object[] with the different values into the helper class and the value is added to the parameter. (Se I don't need to set the data type etc for each parameter, I just need to have the correct order of the parameters)For accuracy's sake, just wanted to let everyone know that this is actually a bug. The correct bug number is 8423178.
Christian
Mark_Williams wrote:
Just to follow-up on this issue...
The bug has been closed as "not a bug" as it seems undocumented behavior was relied upon for this to work in earlier releases.
Note from the documentation on DeriveParameters:
"The output values of derived parameters return as .NET Types by default. To obtain output parameters as provider types, the OracleDbType property of the parameter must be set explicitly by the application to override this default behavior. One quick way to do this is to set the OracleDbType to itself for all output parameters that should be returned as provider types." (emphasis added)
The issue, as you might already know, is that there is no corresponding .NET Framework Type for an Oracle Ref Cursor and the type is, therefore, set to Object. So, explicitly setting the type to OracleDbType.RefCursor should work.
Regards,
Mark -
Hi ,
I use a REF CURSOR when we want to execute a dynamic select statement causes to retrieve more than one record.
We can pass Ref cursor result as a out parameter which can be used in other subprograms right.
I want to pass a coloumn name and get coloumn values as out parameter.This can be used in other stored procedure.
This is my code.
CREATE OR REPLACE PROCEDURE pasval(pColName IN VARCHAR2, pResultSet OUT SYS_REFCURSOR) IS
l_sql VARCHAR2(2000);
--l_ret SYS_REFCURSOR;
--l_val VARCHAR2(1000);
BEGIN
l_sql := 'SELECT DISTINCT ' || pColName || 'into pResultSet FROM TABLE_NAME' ;
execute immediate l_sql;
end;
I am gettingthe errror like this
ORA-00904: "ACCT_TYPE_CODEINTO": invalid identifier
ORA-06512: at "PMA.PAS_TEST", line 7
ORA-06512: at line 9
ORA-00904: "pcc_type_no": invalid identifier --even though the pcc_type_no is coloumn in table_name Table
Thanks,I still didn't get and remains the same,
How to pass l_sql values into OUT parameter.
CREATE OR REPLACE PROCEDURE pasval(pColName IN VARCHAR2, pResultSet OUT SYS_REFCURSOR) IS
l_sql VARCHAR2(2000);
--l_ret SYS_REFCURSOR;
--l_val VARCHAR2(1000);
BEGIN
l_sql := 'SELECT DISTINCT ' || pColName || 'into pResultSet FROM TABLE_NAME' ;
execute immediate l_sql;
end;
I am gettingthe errror like this
ORA-00904: "PCC_TYPE_NOINTO": invalid identifier
ORA-06512: at "PMA.PAS_TEST", line 7
ORA-06512: at line 9
ORA-00904: "pcc_type_no": invalid identifier --even though the pcc_type_no is coloumn in table_name Table
Maybe you are looking for
-
Error in installing CE 7.1 SP3 on Windows Server / XP
I am trying to install CE 7.1 on Windows Server 2003 (version 5.2), SP1 but it fails the pre-requisite analysis giving the message: Windows XP SP2 or higher and Windows Vista are the supported operating systems. The current version is: Version 5.
-
My MacBook Pro 13.3 MAC OS X v10.7 laptop will not come up. Blank screen comes up, no color/desktop, etc., only an icon of a folder in the middle of the screen with a question mark on the folder. Laptop making a clicking noise. Suggestions? Thanks
-
Posting from one jsp to another gives HTTP 405 "method not allowed"
I have a servlet filter that authenticates all requests for resources in my web app. This works fine when HTTP GET requests are being used, but I notice I get a HTTP 405 "Method not allowed" when a HTTP POST is issued. Even a simple JSP page that pos
-
Everytime I open a new site a little vibrating box of ad opens on the right bottom corner of the page. It says "you can win etc." and I can't get rid of this box. When I click this box a web page opens: [http://weeklygiftwinner.com/winner/?sid=cp-2&s
-
Why no PCI Slots 1 & 5 ? ?
A common thread throughout this board is to tell users not to use PCI slots 1 or 5. I find this perplexing - whats the point of MSI building mobos with 5 slots and then you telling us not to use 2 of them? Can anybody from MSI give me a good and cohe