Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Lock ORACLE table from SQL Server using a view


Lock ORACLE table from SQL Server using a view

Author
Message
oscarbolso
oscarbolso
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 24
Hi. I have a view defined in SQL Server 2008 R2 and that view "is looking" a table in Oracle 10g using linked server.
I need to do this (using a SqlServer-side Store Procedure):

1- get a numerator from the view.
2- do some things affecting SQL Server tables.
3- update the numerator in the view.

This takes a small time, but I want to lock the oracle table during all my process because other programs may use the table.

So.. what I want to do is something like this:

1- lock the oracle table
2- get a numerator from the view.
3- do some things affecting SQL Server tables.
3- update the numerator in the view.
4- release the lock

I don´t know how to do steps 1 and 4.

Tks for the help
Jo Pattyn
Jo Pattyn
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1595 Visits: 9733
There is a command to lock an entire table LOCK TABLE employees IN EXCLUSIVE MODE NOWAIT; , but haven't tried this from MSSQL. Perhaps through openquery.

Not sure why you need the lock, as it won't prevent querying.
oscarbolso
oscarbolso
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 24
Yes, I don´t know how to do it... I mean, i´m not sure about the behavior of table locks if I use them with openqueries.
When I get the lock? when I release (or lost) the lock? ...if I use some code like:

openquery(linked_server,get_lock(a))
...
...
my process
...
...
openquery(linked_server,update_view(a))

I´m lost here... tks for the help Jo.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search