I try using XMLType column in my table and ODP.NET.
any full sample source code using ODP.NET and XMLTYPE out parameter?
My procedure:
PROCEDURE GET_DATA_DEPLOY(pPROYECT IN VARCHAR2,
pETIQ IN VARCHAR2 DEFAULT NULL,
pMOMENT OUT TIMESTAMP,
pDATA OUT XMLTYPE)
And for testing: function and procedure.
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;
View in https://entlib.codeplex.com/discussions/454750
I get "connection is closed" errors
Only, I've found this sample, but without OUT parameters.
/*
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);
}
}
}
}
Update:
Alex Keh from Oracle, The below works for me.
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);
Any version source code using Enterprise Library?
References: https://entlib.codeplex.com/discussions/454750