Is it possible to move an Oracle null input parameter to a stored procedure

I have a stored procedure taking 3 inputs and 1 output of donne. I use the Oracle parameter to add all the input parameters 3 as follows:

OracleParameter = cmd inobj. Parameters.Add ("wid", OracleDbType.Int32, 50);
inobj. Direction = ParameterDirection.Input;
inobj. Value = _employeeID;

and the addition of the setting of output as follows:

OracleParameter outobj is _cmd. Parameters.Add ("w_first", OracleDbType.Varchar2, 50);
outobj. Direction = ParameterDirection.Output;

On the side of the user interface, the user has the option of providing 1 entry or all inputs or any 2 based on his interest. Stored proc looks like this:
SP (inp1 in parameter, inp2 in inp3 in parameter, parameter, out parameter output1)

If I just get 1 or 2 entries of the user, it is very good query output data using the same stored procedure or do I create stored procedures for each scenario (combination of different entries)?

I get an error in pl/sql which indicates the invalid number of arguments?

Maybe I can be more clear with c# code. :)

void SaveSomethingInOracle(int param1, string param2 = null, decimal? param3 = null)
{
// Set up your oracle connection and query here
OracleParameter inobj = _cmd.Parameters.Add("w_id", OracleDbType.Int32,50);
inobj.Direction = ParameterDirection.Input;
inobj.Value = param1;

OracleParameter inobj2 = _cmd.Parameters.Add("name", OracleDbType.Varchar2,50);
inobj2.Direction = ParameterDirection.Input;
inobj2.Value = param2;

OracleParameter inobj3 = _cmd.Parameters.Add("quantity", OracleDbType.Decimal,50);
inobj3.Direction = ParameterDirection.Input;
if (param3.HasValue)
{
inobj3.Value = param3.Value;
}
else
{
inobj3.Value = null;
}
}

This c# method takes 3 parameters. The first is necessary, the other two are optional. If you do not set them, they take the value default null and passing it to the database. If you want to set the first and third only, you can still pass null as the other. If you have this piece of code to call the stored procedure any combination of parameters that you use, and the proc will get values or NULL values properly.

Hope he says. You need only one together code to do what you want to do. :)

Published by: Tridus on December 19, 2012 12:10

Tags: Database

Similar Questions

Maybe you are looking for

  • iTunes can't sync music only after that I have change my id

    iTunes can't sync music only after that I have change my ID?

  • ESD anti-static bracelet

    I have a laptop Acer Aspire 5738ZG and need to clean the fan. Where I connect the ESD wrist strap to the land of my self and avoid damage to the computer inside.

  • Example: Pavilion s5123w: update information

    Ive updated my HP Slimline s5123w-card mother m2n68 - la. With a 380 Watt power supply - 4 GHz Ram - AMD Athlon64x2 7850 Kuma 2.80 GHz Dual Core Black edition processor. And my os is win.10 64 bit does anyone know if I can install 8 GHz of Ram and ge

  • Tags Sony Nfc NT1

    I have 4 Sony Nfc tags but unfortunately, I was with another Nfc tag application and by mistake one of the tag (tag car) has been removed and now it is not detected by Sony smart app. Is it possible to reprogram the default settings of Sony tag Nfc p

  • Lost all files in Windows, do I need to reinstall Windows?

    I have performed in a bad way, as backup of the laptop and I lost all files in windows. Any program of Microsoft works. just internet. Is there a way to recover these files or do I have to re - install windows 7? Thank you.