传递 Oracle 参数类型 PLSQLAssociativeArray 时出现 VB.NET 错误
Posted
技术标签:
【中文标题】传递 Oracle 参数类型 PLSQLAssociativeArray 时出现 VB.NET 错误【英文标题】:VB.NET erroring when passing Oracle Parameter Type PLSQLAssociativeArray 【发布时间】:2012-01-03 17:53:53 【问题描述】:我有一个如下所示的 oracle 存储过程:
PROCEDURE GET_PART_CHARACTERISTICS (v_catalog_nos_ IN CatalogNos,
Parts_Char_Cursor out sys_refcursor) AS
BEGIN
OPEN Parts_Char_Cursor FOR
SELECT catalog_no, characteristic_code, unit_meas, attr_value
FROM IFSAPP.SALES_PART_CHARACTERISTIC
WHERE CATALOG_NO IN (select * from table(v_catalog_nos_));
END GET_PART_CHARACTERISTICS;
然后通过 VB.NET 调用:
Dim cmd As New Oracle.DataAccess.Client.OracleCommand()
cmd.Connection = conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "dci_sales_group_part_api.get_part_characteristics"
Dim CatalogNosParam As New Oracle.DataAccess.Client.OracleParameter()
CatalogNosParam.ParameterName = "v_catalog_nos_"
CatalogNosParam.Direction = ParameterDirection.Input
CatalogNosParam.OracleDbType = Oracle.DataAccess.Client.OracleDbType.Varchar2
CatalogNosParam.Size = 100
Dim CatalogNoArr(0) As String
CatalogNoArr(0) = .Item("catalog_no")
CatalogNosParam.Value = CatalogNoArr
CatalogNosParam.CollectionType = Oracle.DataAccess.Client.OracleCollectionType.PLSQLAssociativeArray
cmd.Parameters.Add(CatalogNosParam)
Dim partscharParam As New Oracle.DataAccess.Client.OracleParameter()
partscharParam.ParameterName = "Parts_Char_Cursor"
partscharParam.Direction = ParameterDirection.Output
partscharParam.OracleDbType = Oracle.DataAccess.Client.OracleDbType.RefCursor
cmd.Parameters.Add(partscharParam)
Dim da As New Oracle.DataAccess.Client.OracleDataAdapter(cmd)
da.Fill(dsPartCharacteristics, "PartCharacteristics")
我收到一条错误消息:“ORA-06550:第 1 行,第 7 列: PLS-00306:调用“GET_PART_CHARACTERISTICS”时参数的数量或类型错误 ORA-06550:第 1 行,第 7 列: PL/SQL:语句被忽略"
CatalogNos 类型声明为:
`create or replace TYPE CATALOGNOS AS TABLE OF VARCHAR2(100);`
我不确定为什么这不起作用。
【问题讨论】:
【参考方案1】:不确定 DataAccess,但如果您在参数名称中省略冒号 (:),OracleClient 不喜欢它。
例如:CatalogNosParam.ParameterName = ":v_catalog_nos_"
【讨论】:
以上是关于传递 Oracle 参数类型 PLSQLAssociativeArray 时出现 VB.NET 错误的主要内容,如果未能解决你的问题,请参考以下文章
传递 Oracle 参数类型 PLSQLAssociativeArray 时出现 VB.NET 错误
java 实现往oracle存储过程中传递array数组类型的参数