|
|
|
ROLLBACK в триггере и процедуры
|
|||
|---|---|---|---|
|
#18+
Хочется чтобы ROLLBACK TRAN в триггере не прекращало выполнение batch или процедуры. Можно ли ? SQL7 .. 2000 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 22.11.2002, 14:09:08 |
|
||
|
ROLLBACK в триггере и процедуры
|
|||
|---|---|---|---|
|
#18+
нет ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 22.11.2002, 14:21:22 |
|
||
|
ROLLBACK в триггере и процедуры
|
|||
|---|---|---|---|
|
#18+
Можно, если отсеивать ошибочные изменения самому, что то типа этого: Conditional INSERT Trigger A trigger rejects or accepts each data modification transaction as a whole. However, you do not have to roll back all data modifications simply because some of them are unacceptable. Using a correlated subquery in a trigger can force the trigger to examine the modified rows one by one. Examples A. Use an AFTER INSERT trigger The following example assumes the existence of a table called newsale in the pubs database. This the CREATE statement for newsale: CREATE TABLE newsale (stor_id char(4), ord_num varchar(20), date datetime, qty smallint, payterms varchar(12), title_id tid) If you want to examine each of the records you are trying to insert, the trigger conditionalinsert analyzes the insert row by row, and then deletes the rows that do not have a title_id in titles. CREATE TRIGGER conditionalinsert ON sales AFTER INSERT AS IF (SELECT COUNT(*) FROM titles, inserted WHERE titles.title_id = inserted.title_id) <> @@ROWCOUNT BEGIN DELETE sales FROM sales, inserted WHERE sales.title_id = inserted.title_id AND inserted.title_id NOT IN (SELECT title_id FROM titles) PRINT 'Only sales records with matching title_ids added.' END When unacceptable titles have been inserted, the transaction is not rolled back; instead, the trigger deletes the unwanted rows. This ability to delete rows that have been inserted relies on the order in which processing occurs when triggers are fired. First, rows are inserted into the sales table and the inserted table, and then the trigger fires. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 22.11.2002, 14:30:38 |
|
||
|
ROLLBACK в триггере и процедуры
|
|||
|---|---|---|---|
|
#18+
А эмулировать ? SAVE TRAN, буферные таблицы и все такое ? Целостность зашита в триггеры, но данные необходимо закачивать в цикле, через интерфейсную процедуру. Закачка сваливается если чего не так. Поддерживать отдельную процедуру проверки - копию из триггеров - можно, но сами понимаете ... ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 22.11.2002, 14:32:12 |
|
||
|
|

start [/forum/topic.php?fid=46&fpage=3371&tid=1818577]: |
0ms |
get settings: |
9ms |
get forum list: |
16ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
48ms |
get topic data: |
13ms |
get forum data: |
4ms |
get page messages: |
48ms |
get tp. blocked users: |
1ms |
| others: | 233ms |
| total: | 380ms |

| 0 / 0 |
