UniParameter positional or not
Posted: Mon 10 Oct 2011 14:46
Hi,
in a test application I've called a sp with the following code
=========================================
Devart.Data.Universal.UniCommand uniCommand = new Devart.Data.Universal.UniCommand();
string connectionString =
"Provider=Oracle" +
//Username
";User Id=" + "elektra" +
//Password
";Password=" + "elektra" +
//Replace with your datasource value
";Data Source=" + "RISDB"; //+
UniMonitor um = new UniMonitor();
um.IsActive = true;
uniCommand.Connection = new Devart.Data.Universal.UniConnection(connectionString);
uniCommand.Connection.Open();
uniCommand.CommandText = "WS_AMWRK_BOO_DTASC_NOLAST";
uniCommand.CommandType = CommandType.StoredProcedure;
uniCommand.Parameters.Add(new UniParameter("v_RETURN_VALUE", UniDbType.Int, 4, ParameterDirection.Output, true, 10, 0, null, DataRowVersion.Current, null));
uniCommand.Parameters.Add(new UniParameter("v_STARTDATE", UniDbType.TimeStamp, 8));
uniCommand.Parameters.Add(new UniParameter("v_ENDDATE", UniDbType.TimeStamp, 8));
uniCommand.Parameters.Add(new UniParameter("v_CSVWEEKDAYS", UniDbType.NVarChar, 100));
uniCommand.Parameters.Add(new UniParameter("v_RADIOLOGISTCODE", UniDbType.NVarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_SITECODE", UniDbType.NVarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_ROOMCODE", UniDbType.NVarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_MODALITYCODE", UniDbType.NVarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_ORIGINTYPECODE", UniDbType.NVarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_PRIORITYCODE", UniDbType.VarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_STATUS", UniDbType.Int, 4));
uniCommand.Parameters["v_STARTDATE"].Value = new DateTime(2011, 7, 14, 0, 0, 0);
uniCommand.Parameters["v_ENDDATE"].Value = new DateTime(2011, 7, 14, 23, 59, 00);
uniCommand.Parameters["v_STATUS"].Value = 0;
uniCommand.Parameters["v_CSVWEEKDAYS"].Value = "0,1,2,3,4,5,6";
uniCommand.Parameters["v_RADIOLOGISTCODE"].Value = DBNull.Value;
uniCommand.Parameters["v_SITECODE"].Value = DBNull.Value;
uniCommand.Parameters["v_ROOMCODE"].Value = DBNull.Value;
uniCommand.Parameters["v_MODALITYCODE"].Value = DBNull.Value;
uniCommand.Parameters["v_ORIGINTYPECODE"].Value = DBNull.Value;
uniCommand.Parameters["v_PRIORITYCODE"].Value = DBNull.Value;
Devart.Data.Universal.UniDataReader dataReader = uniCommand.ExecuteReader();
object obj = null;
int recCount = 0;
if (dataReader.FieldCount > 0)
{
while (dataReader.Read())
{
for (int i = 0; i < dataReader.FieldCount; i++)
obj = dataReader.GetValue(i);
recCount++;
}
}
MessageBox.Show(recCount.ToString());
dataReader.Close();
uniCommand.Connection.Close();
============================================
The signature of the sp is
============================================
CREATE OR REPLACE PROCEDURE "WS_AMWRK_BOO_DTASC_NOLAST"(v_RETURN_VALUE OUT number,
v_STARTDATE IN TIMESTAMP DEFAULT NULL,
v_ENDDATE IN TIMESTAMP DEFAULT NULL,
v_CSVWEEKDAYS IN NVARCHAR2 DEFAULT NULL,
v_RADIOLOGISTCODE IN NVARCHAR2 DEFAULT NULL,
v_SITECODE IN NVARCHAR2 DEFAULT NULL,
v_ROOMCODE IN NVARCHAR2 DEFAULT NULL,
v_MODALITYCODE IN NVARCHAR2 DEFAULT NULL,
v_ORIGINTYPECODE IN NVARCHAR2 DEFAULT NULL,
v_PRIORITYCODE IN NVARCHAR2 DEFAULT NULL,
v_STATUS IN NUMBER DEFAULT NULL,
v_cur IN OUT Types.cursor_type
========================================
As you could see the last sp param has not been added explicitly
to the UniCommand.Parameters collection.
Launching the application the messagebox show 14 records found.
If I change in c# code the name of the parameters substituting v_ with @ (in all places, that is adding parameter and assigning values)
then the message box return 0 records. I've leave checkParameter to false (the default).
The question is: the parameter definition is positional or not?
Many thanks
Best Regards
Marco
in a test application I've called a sp with the following code
=========================================
Devart.Data.Universal.UniCommand uniCommand = new Devart.Data.Universal.UniCommand();
string connectionString =
"Provider=Oracle" +
//Username
";User Id=" + "elektra" +
//Password
";Password=" + "elektra" +
//Replace with your datasource value
";Data Source=" + "RISDB"; //+
UniMonitor um = new UniMonitor();
um.IsActive = true;
uniCommand.Connection = new Devart.Data.Universal.UniConnection(connectionString);
uniCommand.Connection.Open();
uniCommand.CommandText = "WS_AMWRK_BOO_DTASC_NOLAST";
uniCommand.CommandType = CommandType.StoredProcedure;
uniCommand.Parameters.Add(new UniParameter("v_RETURN_VALUE", UniDbType.Int, 4, ParameterDirection.Output, true, 10, 0, null, DataRowVersion.Current, null));
uniCommand.Parameters.Add(new UniParameter("v_STARTDATE", UniDbType.TimeStamp, 8));
uniCommand.Parameters.Add(new UniParameter("v_ENDDATE", UniDbType.TimeStamp, 8));
uniCommand.Parameters.Add(new UniParameter("v_CSVWEEKDAYS", UniDbType.NVarChar, 100));
uniCommand.Parameters.Add(new UniParameter("v_RADIOLOGISTCODE", UniDbType.NVarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_SITECODE", UniDbType.NVarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_ROOMCODE", UniDbType.NVarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_MODALITYCODE", UniDbType.NVarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_ORIGINTYPECODE", UniDbType.NVarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_PRIORITYCODE", UniDbType.VarChar, 10));
uniCommand.Parameters.Add(new UniParameter("v_STATUS", UniDbType.Int, 4));
uniCommand.Parameters["v_STARTDATE"].Value = new DateTime(2011, 7, 14, 0, 0, 0);
uniCommand.Parameters["v_ENDDATE"].Value = new DateTime(2011, 7, 14, 23, 59, 00);
uniCommand.Parameters["v_STATUS"].Value = 0;
uniCommand.Parameters["v_CSVWEEKDAYS"].Value = "0,1,2,3,4,5,6";
uniCommand.Parameters["v_RADIOLOGISTCODE"].Value = DBNull.Value;
uniCommand.Parameters["v_SITECODE"].Value = DBNull.Value;
uniCommand.Parameters["v_ROOMCODE"].Value = DBNull.Value;
uniCommand.Parameters["v_MODALITYCODE"].Value = DBNull.Value;
uniCommand.Parameters["v_ORIGINTYPECODE"].Value = DBNull.Value;
uniCommand.Parameters["v_PRIORITYCODE"].Value = DBNull.Value;
Devart.Data.Universal.UniDataReader dataReader = uniCommand.ExecuteReader();
object obj = null;
int recCount = 0;
if (dataReader.FieldCount > 0)
{
while (dataReader.Read())
{
for (int i = 0; i < dataReader.FieldCount; i++)
obj = dataReader.GetValue(i);
recCount++;
}
}
MessageBox.Show(recCount.ToString());
dataReader.Close();
uniCommand.Connection.Close();
============================================
The signature of the sp is
============================================
CREATE OR REPLACE PROCEDURE "WS_AMWRK_BOO_DTASC_NOLAST"(v_RETURN_VALUE OUT number,
v_STARTDATE IN TIMESTAMP DEFAULT NULL,
v_ENDDATE IN TIMESTAMP DEFAULT NULL,
v_CSVWEEKDAYS IN NVARCHAR2 DEFAULT NULL,
v_RADIOLOGISTCODE IN NVARCHAR2 DEFAULT NULL,
v_SITECODE IN NVARCHAR2 DEFAULT NULL,
v_ROOMCODE IN NVARCHAR2 DEFAULT NULL,
v_MODALITYCODE IN NVARCHAR2 DEFAULT NULL,
v_ORIGINTYPECODE IN NVARCHAR2 DEFAULT NULL,
v_PRIORITYCODE IN NVARCHAR2 DEFAULT NULL,
v_STATUS IN NUMBER DEFAULT NULL,
v_cur IN OUT Types.cursor_type
========================================
As you could see the last sp param has not been added explicitly
to the UniCommand.Parameters collection.
Launching the application the messagebox show 14 records found.
If I change in c# code the name of the parameters substituting v_ with @ (in all places, that is adding parameter and assigning values)
then the message box return 0 records. I've leave checkParameter to false (the default).
The question is: the parameter definition is positional or not?
Many thanks
Best Regards
Marco