oracle06564,OracleCommandBuilder.DeriveParameters() throws OracleException: ORA-06564: object does n...

博主使用.NET Framework中ADO.NET的OracleClient调用OracleCommandBuilder.DeriveParameters()方法时,出现ORA-06564错误。文中给出了存储过程的SQL代码和测试代码,回答指出问题在于创建存储过程时使用了双引号,建议重新创建不使用双引号的过程或严格使用双引号引用对象。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题

Using the OracleClient that comes with ADO.NET in .NET Framework, I'm trying to call OracleCommandBuilder.DeriveParameters() method on a procedure in the database, but I keep getting an OracleException with the message: ORA-06564: object CustOrdersOrders does not exist, even though I created the procedure successfully. I'm more familiar with SQL Server, so perhaps I'm missing something here.

SQL

file 1.sql:

create or replace PACKAGE PKGENTLIB_ARCHITECTURE

IS

TYPE CURENTLIB_ARCHITECTURE IS REF CURSOR;

END PKGENTLIB_ARCHITECTURE;

/

file 2.prc:

CREATE OR REPLACE PROCEDURE "CustOrdersOrders"(VCUSTOMERID IN Orders.CustomerID%TYPE := 1, CUR_OUT OUT PKGENTLIB_ARCHITECTURE.CURENTLIB_ARCHITECTURE)

AS

BEGIN

OPEN cur_OUT FOR

SELECT

OrderID,

OrderDate,

RequiredDate,

ShippedDate

FROM Orders

WHERE CustomerID = vCustomerId;

END;

/

file 3.prc

CREATE OR REPLACE PROCEDURE ADDCOUNTRY

(vCountryCode IN Country.CountryCode%TYPE,

vCountryName IN Country.CountryName%TYPE

)

AS

BEGIN

INSERT INTO Country (CountryCode,CountryName)

VALUES (vCountryCode,vCountryName);

END;

/

All of these files were executed in SQL*Plus as @"path\to\file1.sql".

App.config

Code

private DbConnection connection;

private OracleCommand command;

[TestInitialize]

public void Initialize()

{

String connectionString = ConfigurationManager.ConnectionStrings["OracleTest"].ConnectionString;

connection = new OracleConnection(connectionString);

command = connection.CreateCommand() as OracleCommand;

command.CommandType = CommandType.StoredProcedure;

connection.Open();

}

[TestMethod]

public void DeriveParametersWithoutUserDefinedTypes()

{

command.CommandText = "AddCountry";

OracleCommandBuilder.DeriveParameters(command);

Assert.AreEqual(2, command.Parameters.Count); // fails because Count = 0

}

[TestMethod]

public void DeriveParametersWithUserDefinedTypes()

{

command.CommandText = "CustOrdersOrders";

OracleCommandBuilder.DeriveParameters(command); //throws 'ORA-06564: object CustOrdersOrders does not exist\nORA-06512: at "SYS.DBMS_UTILITY", line 156\nORA-06512: at line 1'

Assert.AreEqual(2, command.Parameters.Count);

}

[TestCleanup]

public void Cleanup()

{

connection?.Dispose();

}

More Details

This is happening in a fork I made for the Enterprise Library Data Access Application Block here in an attempt to revive this library. That's why it's using the System.Data.OracleClient and not the ODP.NET.

The tests are running on an Oracle Database XE I installed locally.

回答1:

From my Oracle-ish point of view, this was your huge mistake:

CREATE OR REPLACE PROCEDURE "CustOrdersOrders"

- -

these double quotes

Because, by default Oracle stores all object names into the dictionary in upper case, but you can reference it any way you want, e.g. custordersorders, CUSTordERsordERS, CUSTORDERSORDERS, CustOrdersOrders - no problem. But, if you enclose any name (procedure, table, column, ...) into double quotes, you must use double quotes any time you reference that object, enclosed into same double quotes and matching letter case exactly as you used it when creating that object.

So: either recreate the procedure as CREATE OR REPLACE PROCEDURE CustOrdersOrders (which is what I'd suggest), or use double quotes.

来源:https://stackoverflow.com/questions/62732305/oraclecommandbuilder-deriveparameters-throws-oracleexception-ora-06564-objec

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值