using command to pass old and new values

  • Thread starter Thread starter anonymike
  • Start date Start date
A

anonymike

Hello,

I'm trying to find an example of using oracle command utilizing both
the original and new values of a dataset (datatable) to pass into a
stored procedure.

For example,

---------SNIP ----------------
OracleCommand updateCommand = new
OracleCommand("UpdateLocations",conn);

updateCommand.commandType = commandType.storedProcedure;

updateCommand.Parameters.Add("p_loc_id", OracleType.Number,4,"LOC_ID");
updateCommand.Parameters.Add("p_address",OracleType.Varchar,100,"ADDR");

da.UpdateCommand = updateCommand;

---------SNIP ----------------

This proc will update the address for the loc_id. I want to be able to
pass in one more variable, the "old address" to compare and make sure
that the address in the database hasn't changed since I originally
retrieved the row (kind of like using the last rowupdate timestamp to
ensure the data hasn't changed)

How can I add specify this in another parameter for the call...
something like:

---------SNIP ----------------
updateCommand.Parameters.Add("p_address_old",OracleType.Varchar,100
........)

---------SNIP ----------------


Thanks in advance,
Mike
 
Hi,

Hello,

I'm trying to find an example of using oracle command utilizing both
the original and new values of a dataset (datatable) to pass into a
stored procedure.

For example,

---------SNIP ----------------
OracleCommand updateCommand = new
OracleCommand("UpdateLocations",conn);

updateCommand.commandType = commandType.storedProcedure;

updateCommand.Parameters.Add("p_loc_id", OracleType.Number,4,"LOC_ID");
updateCommand.Parameters.Add("p_address",OracleType.Varchar,100,"ADDR");

da.UpdateCommand = updateCommand;

---------SNIP ----------------

This proc will update the address for the loc_id. I want to be able to
pass in one more variable, the "old address" to compare and make sure
that the address in the database hasn't changed since I originally
retrieved the row (kind of like using the last rowupdate timestamp to
ensure the data hasn't changed)

How can I add specify this in another parameter for the call...
something like:

---------SNIP ----------------

Change the SourceVersion on the Parameter:

OracleParameter p =
updateCommand.Parameters.Add("p_address_old",OracleType.Varchar,100,
"ADDR");

p.SourceVersion = DataRowVersion.Original;

HTH,
Greetings
 
Back
Top