Passing Timestamp value to sql server

  • Thread starter Thread starter Beth
  • Start date Start date
B

Beth

Hello,

To resolve concurrency issues, I am retrieving sql
timestamp value and with every update passing the value
back and raising an error if the timestamp has changed. My
problem is that I don't know what data type to pass in the
CreateParamater method. I am using ADP and created a
stored procedure.

A related question is what other method can I use to check
for updates if I don't have direct table permissions. I
cannot use SELECT statements. I can only access stored
procedures.

Thanks.
 
Can't you use a Trigger to check for updates?

Create Trigger PasswordTable_Trigger1

On dbo.PasswordTable

For /* Insert, Update, Delete */

As

/* If Update (column_name) ...*/

hth,

bob mcclellan
 
I still need to pass the value back to the server.

Basically, I have a form that connects to the server, gets
the data, then release the connection. If the user updates
something, then I need to check to see if the data has
been updated before I do an update. If I was connected all
the time to the server, then the solution is simple -- I
let the server handle it. Yet, I need the value of the
timestamp to compare but I don't know what datatype to
store or pass back so a stored procedure can process it.

All this is of course done in ADP.

If you have any other ideas please post. Thanks.
-----Original Message-----
Can't you use a Trigger to check for updates?

Create Trigger PasswordTable_Trigger1

On dbo.PasswordTable

For /* Insert, Update, Delete */

As

/* If Update (column_name) ...*/

hth,

bob mcclellan



"Beth" <[email protected]> wrote in
message news:[email protected]...
 
First, the following example cast the timestamp to a data type of datetime:

http://arcobjectsonline.esri.com/Ar...laneous Tips/Reading_NTEXT-TIMESTAMP_flds.htm

You can also cast it to another type. Surely you can find a lot of other
examples by making a search on the internet.

Second, unless you are using a table lock, you must not check if the data
has been updated before you make the update but at the same time; otherwise
you can hit a race course condition. This can easily be easily achieved by
putting all the tests in the same WHERE condition as the UPDATE query.

S. L.
 
Thanks Sylvain. I used a Double datatype to get a unique string from the
timestamp so I can compare.

I didn't quite understand your warning about checking before an update. I
would check the row based on a primary key (NOT the timestamp) in the where
clause of an UPDATE statement and see if the timestamp matches. If it does,
then no one has updated the row, if it doesn't, then someone updated the row.
Is there a flaw in this logic? Remember, I am connecting to the server only
 
Beth,
Sorry for the delay in this reply...
After reading the thread, the first thing I thought of was a flag field or
an additional flag table
that you can join to when you need to check for updated records. On the
table that you need
to check, create a trigger for UpDate that sets the flag for the record to
updated = 1. Then
after you do your check later, set the flag back to 0.

Unless I'm missing the objective,
this should work.

hth,
bob.
 
John316 said:
Beth,
Sorry for the delay in this reply...
After reading the thread, the first thing I thought of was a flag field or
an additional flag table
that you can join to when you need to check for updated records. On the
table that you need
to check, create a trigger for UpDate that sets the flag for the record to
updated = 1. Then
after you do your check later, set the flag back to 0.

Unless I'm missing the objective,
this should work.

hth,
bob.
 
Back
Top