【发布时间】:2014-08-13 15:38:17
【问题描述】:
我有一个 Oracle 过程,它将复杂类型作为输出参数传递,我需要能够在 .NET 中使用该过程。我没有太多的运气找到一个很好的例子来说明如何制作这样的东西,所以我希望这里的一些人可能有答案或者已经做到了。
Oracle.manageddataAccess.dll 版本# 4.121.1.0
代码:
CREATE OR REPLACE TYPE APPS.gary_pol_tbl_type AS TABLE OF gary_pol_rec_type;
CREATE OR REPLACE PROCEDURE APPS.gary_pol_test3 ( x_gary_pol IN OUT apps.gary_pol_tbl_type ) AS
CURSOR c1 IS
SELECT org_id,
po_type,
po_header_id,
po_num,
po_release_id,
po_release_num,
vendor_id,
vendor_name,
vendor_site_num,
vendor_site_name,
pay_site_id,
currency_code,
po_amount,
po_date,
buyer_name,
shipment_num,
po_line_id,
line_num,
po_creation_date,
release_date,
item_num,
item_description,
uom,
po_qty,
received_qty,
unit_price,
taxable_flag,
closed_date,
entity,
branch,
planner_name,
attribute1,
attribute2,
batch_number,
processed_flag,
wm_uuid,
creation_date,
created_by,
last_update_date,
last_updated_by
FROM xxit.xxfin_ap_imagenow_pol_out
WHERE ROWNUM < 2001
ORDER BY org_id ASC NULLS LAST,
po_header_id ASC NULLS LAST,
po_release_id ASC NULLS LAST,
shipment_num ASC NULLS LAST,
po_line_id ASC NULLS LAST,
line_num ASC NULLS LAST;
BEGIN
FOR c1_rec IN c1 LOOP
x_gary_pol.EXTEND;
x_gary_pol ( x_gary_pol.LAST ) :=
apps.gary_pol_rec_type ( c1_rec.org_id,
c1_rec.po_type,
c1_rec.po_header_id,
c1_rec.po_num,
c1_rec.po_release_id,
c1_rec.po_release_num,
c1_rec.vendor_id,
c1_rec.vendor_name,
c1_rec.vendor_site_num,
c1_rec.vendor_site_name,
c1_rec.pay_site_id,
c1_rec.currency_code,
c1_rec.po_amount,
c1_rec.po_date,
c1_rec.buyer_name,
c1_rec.shipment_num,
c1_rec.po_line_id,
c1_rec.line_num,
c1_rec.po_creation_date,
c1_rec.release_date,
c1_rec.item_num,
c1_rec.item_description,
c1_rec.uom,
c1_rec.po_qty,
c1_rec.received_qty,
c1_rec.unit_price,
c1_rec.taxable_flag,
c1_rec.closed_date,
c1_rec.entity,
c1_rec.branch,
c1_rec.planner_name,
c1_rec.attribute1,
c1_rec.attribute2,
c1_rec.batch_number,
c1_rec.processed_flag,
c1_rec.wm_uuid,
c1_rec.creation_date,
c1_rec.created_by,
c1_rec.last_update_date,
c1_rec.last_updated_by );
END LOOP;
apps.gary_pol_tbl_type ) );
END gary_pol_test3;
我在搜索中看到了一些引用,我通过将 oracleDBType.... 设置为对象或数组来完成,但我没有这些选项。我可以看到对象可能是我正在寻找的东西。
这是我在 C# 中尝试阅读的代码。
public static DataTable test2()
{
DataTable dt = new DataTable();
try
{
using (OracleConnection cn = BSIC_DAL.OracleHelpers.createOracleConnection())
{
OracleDataAdapter da = new OracleDataAdapter();
OracleCommand cmd = new OracleCommand();
cmd.Connection = cn;
cmd.CommandText = "apps.gary_pol_test3";
cmd.CommandType = CommandType.StoredProcedure;
//cmd.Parameters.Add("p_batch_number", OracleDbType.Int16).Value = 133;
cmd.Parameters.Add("x_gary_pol", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
da.SelectCommand = cmd;
da.Fill(dt);
return dt;
}
}
catch (Exception ex)
{
return null;
throw ex;
}
}
我如何在 .Net 中使用上述 Oracle 复杂类型?
感谢您的帮助
【问题讨论】: