我尝试在我的表和 ODP.NET 中使用 XMLType 列。
任何使用 ODP.NET 和 XMLTYPE out 参数的完整示例源代码?
我的程序:
PROCEDURE GET_DATA_DEPLOY(pPROYECT IN VARCHAR2,
pETIQ IN VARCHAR2 DEFAULT NULL,
pMOMENT OUT TIMESTAMP,
pDATA OUT XMLTYPE)
并用于测试:功能和程序。
FUNCTION FRKDATA_GET_XMLTYPE(num IN NUMBER, xml1 IN XMLTYPE) RETURN XMLTYPE IS
xmlout XMLTYPE;
BEGIN
SELECT XMLTYPE_COL
INTO xmlout
FROM POC_TEST_XML_TABLE
WHERE NUM_COL = num;
RETURN xmlout;
END FRKDATA_GET_XMLTYPE;
PROCEDURE FRKDATA_TESTXML(qry in VARCHAR2, rslt OUT XMLTYPE) AS
BEGIN
rslt := dbms_xmlgen.getxmltype(qry);
END FRKDATA_TESTXML;
在https://entlib.codeplex.com/discussions/454750查看
我收到“连接已关闭”错误
只是,我找到了这个示例,但没有 OUT 参数。
/*
create or replace function xmlproc(v1 in xmltype) return xmltype is
begin
return v1;
end;
/
*/
using System;
using System.Data;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
class Program
{
static void Main(string[] args)
{
using (OracleConnection con = new OracleConnection())
{
con.ConnectionString = "user id=scott;password=tiger;data source=orcl";
con.Open();
using (OracleCommand cmd = new OracleCommand("",con))
{
cmd.CommandText = "xmlproc";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new OracleParameter("return", OracleDbType.XmlType)).Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(new OracleParameter("v1", OracleDbType.XmlType)).Direction = ParameterDirection.Input;
cmd.Parameters["v1"].Value = "<a>b</a>";
cmd.ExecuteNonQuery();
Console.WriteLine(((OracleXmlType)cmd.Parameters["return"].Value).Value);
}
}
}
}
更新:
来自 Oracle 的 Alex Keh,以下内容对我有用。
PROCEDURE "XMLPROC" ( "PARAM1" OUT XMLTYPE) IS
BEGIN
PARAM1 := dbms_xmlgen.getxmltype('SELECT FIRST_NAME FROM EMPLOYEES WHERE EMPLOYEE_ID=100');
END;
OracleConnection con = new OracleConnection();
con.ConnectionString = conString;
con.Open();
OracleCommand cmd = con.CreateCommand();
cmd.CommandText = "xmlproc";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new OracleParameter("xmlout", OracleDbType.XmlType)).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
Console.WriteLine(((OracleXmlType)cmd.Parameters["xmlout"].Value).Value);
任何使用企业库的版本源代码?