Friday, March 30, 2012

how to view data whilst in an uncompleted transaction, from outside the transaction?

Hi everyone, I was hioping to obtain some help with viewing sql data
whilst within a transaction, from OUTSIDE the transaction itself.
For example, if i do the following steps:
1)
-- Do this in Query Analyzer session 1 window
-- Note: there is no commit transaction below
begin transaction
use northwind
update customers
set postalcode = 2000
where customerid = 'BLONP'
2)
-- Do this in Query Analyzer session 2 window
-- This is where I want to view the modified data
-- prior to commiting the transaction
use northwind
select postalcode from customers
where customerid = 'BLONP'
3)
-- Do this in Query Analyzer session 1 window
-- Here I commit the transaction after reviewing
-- (via step 2) that the update statement is
-- producing the results that I want
commit transaction
The problem is that performing step 2 does not work as the transaction
in step 1 is obviously locking the customers table. I have looked into
setting isolation levels, but this doesn't seem to be working. The only
result that I am getting back from step 1 is that one row has been
modified. This is an obvious help as I know that not all rows have been
affected by my update, but tells me very little.
The reason I want to be able to do the 1-2-3 step oricess is sometimes
I need to do a complex update, and wish to review the results of my
update prior to commiting. I don't want to rely on updating "test" data
alone as a gauge to the correctness of my update statement.
Any help on this would be great!
cheers,
peterCan you not just do this all in one query window:?
Start Transaction
Issue modification statements
perform queries to validate the changes
Committ or rollback as desired
<mag1kus@.yahoo.com> wrote in message
news:1143076873.038566.151900@.j33g2000cwa.googlegroups.com...
> Hi everyone, I was hioping to obtain some help with viewing sql data
> whilst within a transaction, from OUTSIDE the transaction itself.
> For example, if i do the following steps:
> 1)
> -- Do this in Query Analyzer session 1 window
> -- Note: there is no commit transaction below
> begin transaction
> use northwind
> update customers
> set postalcode = 2000
> where customerid = 'BLONP'
> 2)
> -- Do this in Query Analyzer session 2 window
> -- This is where I want to view the modified data
> -- prior to commiting the transaction
> use northwind
> select postalcode from customers
> where customerid = 'BLONP'
> 3)
> -- Do this in Query Analyzer session 1 window
> -- Here I commit the transaction after reviewing
> -- (via step 2) that the update statement is
> -- producing the results that I want
> commit transaction
>
> The problem is that performing step 2 does not work as the transaction
> in step 1 is obviously locking the customers table. I have looked into
> setting isolation levels, but this doesn't seem to be working. The only
> result that I am getting back from step 1 is that one row has been
> modified. This is an obvious help as I know that not all rows have been
> affected by my update, but tells me very little.
> The reason I want to be able to do the 1-2-3 step oricess is sometimes
> I need to do a complex update, and wish to review the results of my
> update prior to commiting. I don't want to rely on updating "test" data
> alone as a gauge to the correctness of my update statement.
> Any help on this would be great!
> cheers,
> peter
>

No comments:

Post a Comment