Maximiliano:
este envio tendria que empezar con el wav de windows TADAAAA !
TE LO ENCONTRE ...
hay un equivalente de Derive.Parameters en OleDB - pero no ve los SP de
Oracle !
OleDbCommandBuilder.DeriveParameters
ejemplo de codigo
OleDbCommandBuilder.DeriveParameters error | PC Review
http://www.pcreview.co.uk/threads/oledbcommandbuilder-deriveparameters-error.1249291/
Tenes que usar ODP.NET y tenes que usar version 10 xq antes no existe !
Ahora - podes usar ODP.NET v10 con bases 9 ( sie fuera el caso )
Detalles:
ODP.NET OracleCommandBuilder.DeriveParameters
v9 NO
v10 SI -> ODP.NET 10.1.0.3
- You can use the 10g data provider installed into an
Oracle10g Home to access an Oracle9i database.
- You can not install the Oracle10g data provider
into a previous version (i.e. 9i or 8i) Home.
Atte
AP
==========================================================
2) The DeriveParameters Function in C#
==========================================================
public void DeriveParameters(OracleCommand cmd, OracleConnection con)
{
OracleParameter param, param1;
Oracle.DataAccess.Types.OracleString oString;
ArrayList tParameters;
object obj;
OracleCommand cmdDP;
string[] sArrParametros;
string[] sArrParamInfo;
byte bDireccion;
//verifico el tipo de command que pasaron
if(cmd.CommandType!=CommandType.StoredProcedure)
throw new ArgumentException("Invalid Command Type");
//Verifico si el cache de parámetros ya fue creado
//Si no fue creado lo creo
if(msParametersCache==null)
msParametersCache = new Hashtable();
//asigno BindByName al command
cmd.BindByName = true;
//Verifico si los parámetros para el Procedure del command
están ya en el Cache
if(msParametersCache.Contains(cmd.CommandText))
{
//Obtengo una lista temporaria de parámetros
tParameters = (ArrayList)msParametersCache[cmd.CommandText];
//limpio la lista de parámtros del command, por las dudas
cmd.Parameters.Clear();
for(int i=0;i<tParameters.Count;i++)
{
//Obtengo un objeto OracleParameter
param = (OracleParameter)tParameters;
//Lo copio a un segundo objeto ya que un parámetro
//no puede permanecer a dos colecciones al mismo tiempo
param1 = (OracleParameter)param.Clone();
//Agrego el parámetro copiado a la colección
//de parámetros del command
cmd.Parameters.Add(param1);
}
}
else
{
try
{
//Los parámetros no han sido ingresados al cache aún
//busco los parámetros, los agrego al cache, y a
//la colección de parametros del command.
//Creo el command para ejecutar el procedure que
describe los parámetros
cmdDP = new
OracleCommand("PKG_DECLARE.DESCRIBE_PROCEDURE", con);
cmdDP.CommandType = CommandType.StoredProcedure;
//Creo los parámetros del procedure
param = cmdDP.Parameters.Add("P_PROCEDURE_NAME",
OracleDbType.Varchar2, ParameterDirection.Input);
param.Value = cmd.CommandText;
param = cmdDP.Parameters.Add("P_RESULT",
OracleDbType.Varchar2, ParameterDirection.Output);
param.Size = 1500;
//Marco un labeled statement
Execution:
try
{
//Ejecuto el Procedure
obj = cmdDP.ExecuteScalar();
}
catch(OracleException oraEx)
{
if(oraEx.Number==-25408)
goto Execution;
else
throw new OracleDatosException("An Oracle
exception was detected while trying to DeriveParameters. Exception thrown was:
" + oraEx.Message, oraEx);
}
tParameters = new ArrayList(20);
//obtengo el OracleString devuelto como resultado.
oString =
(Oracle.DataAccess.Types.OracleString)cmdDP.Parameters["P_RESULT"].Value;
//Obtengo el array con las filas de información sobre
los parámetros
sArrParametros = oString.Value.Split('#');
//Recorro las filas de información
for(int i=0;i<sArrParametros.Length;i++)
{
//Obtengo los atributos de la info de los
parámetros
sArrParamInfo = sArrParametros[i].Split('¦');
//verifico que no haya llegado un error
if(sArrParamInfo.Length==1)
throw new OracleDatosException("An invalid
procedure information was passed to DerriveParameters for procedure
\""+cmd.CommandText+"\". \r\n"+sArrParamInfo[0]);
//Creo un nuevo parámetro
param = new OracleParameter();
//Asigno el nombre
param.ParameterName =
sArrParamInfo[ARGUMENT_NAME];
//Asigno el tipo
switch(Int32.Parse(sArrParamInfo[DATATYPE]))
{
case 1:
param.OracleDbType =
OracleDbType.Varchar2;
break;
case 2:
param.OracleDbType =
OracleDbType.Decimal;
break;
case 3:
param.OracleDbType = OracleDbType.Int32;
break;
case 8:
param.OracleDbType = OracleDbType.Long;
break;
case 12:
param.OracleDbType = OracleDbType.Date;
break;
case 23:
param.OracleDbType = OracleDbType.Raw;
break;
case 96:
param.OracleDbType = OracleDbType.Char;
break;
case 102:
param.OracleDbType =
OracleDbType.RefCursor;
break;
case 180:
param.OracleDbType =
OracleDbType.TimeStamp;
break;
default:
throw new Exception("Invalid Data Type
Detected (" + sArrParamInfo[DATATYPE] + ").");
}
//Asigno si el parámetro puede tener Default
Values
param.IsNullable =
(sArrParamInfo[DEFAULT_VALUE]=="1");
//Obtengo la dirección del parámetro
bDireccion = Byte.Parse(sArrParamInfo[IN_OUT]);
//Asigno la dirección del parámetro.
if(bDireccion==0)
param.Direction = ParameterDirection.Input;
if(bDireccion==1)
param.Direction = ParameterDirection.Output;
//if(bDireccion==2)
// param.Direction =
ParameterDirection.InputOutput;
//Asigno el tamaño
//param.Size = Int32.Parse(sArrParamInfo[LENGTH]);
//param.Precision =
Int32.Parse(sArrParamInfo[PRECISION])
//param.Scale = Int32.Parse(sArrParamInfo[SCALE])
tParameters.Add(param);
}
//Reverifico que el procedure no esté en el cache
//Añado la lista de parámetros al cache
if(!msParametersCache.ContainsKey(cmd.CommandText))
msParametersCache.Add(cmd.CommandText,
tParameters);
//Limpio la lista de parámtros del command, por las
dudas
cmd.Parameters.Clear();
//Recorro la lista de parámetros
for(int i=0;i<tParameters.Count;i++)
{
//Obtengo un objeto OracleParameter
param = (OracleParameter)tParameters[i];
//Lo copio a un segundo objeto ya que un
parámetro
//no puede permanecer a dos colecciones al mismo
tiempo
param1 = (OracleParameter)param.Clone();
//Agrego el parámetro copiado a la colección
//de parámetros del command
cmd.Parameters.Add(param1);
}
}
catch(OracleException oraEx)
{
throw new OracleDatosException("An OracleException was
detected by OracleDatos. Exception was: "+ oraEx.Message, oraEx);
}
catch(Exception ex)
{
throw new OracleDatosException("An unknown exception
was detected. Exception was: "+ ex.Message, ex);
}
}
}
=========================================================
3) CONSTANTS AND MEMBER VARIABLES
=========================================================
private static Hashtable msParametersCache;
private const int ARGUMENT_NAME = 0, OVERLOAD = 1, POSITION = 2,
LEVEL = 3, DATATYPE = 4, DEFAULT_VALUE = 5, IN_OUT = 6, LENGTH = 7, PRECISION =
8, SCALE = 9, RADIX = 10, SPARE = 11;
==========================================================