Home All Groups Group Topic Archive Search About

using command to pass old and new values

Author
18 Jan 2006 11:04 PM
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

Author
19 Jan 2006 11:48 AM
Bart Mermuys
Hi,

<anonym***@gmail.com> wrote in message
Show quote
news:1137625451.919152.263390@o13g2000cwo.googlegroups.com...
> 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


Show quote
>
> ---------SNIP ----------------
>
>
> Thanks in advance,
> Mike
>
Author
19 Jan 2006 2:33 PM
anonymike
Thanks Bart... Looks like that did it ;)

AddThis Social Bookmark Button