powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / ROLLBACK в триггере и процедуры
4 сообщений из 4, страница 1 из 1
ROLLBACK в триггере и процедуры
    #32071353
Цунцуяби
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Хочется чтобы ROLLBACK TRAN в триггере не прекращало выполнение batch или процедуры.

Можно ли ? SQL7 .. 2000
...
Рейтинг: 0 / 0
ROLLBACK в триггере и процедуры
    #32071362
Фотография alexeyvg
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
нет
...
Рейтинг: 0 / 0
ROLLBACK в триггере и процедуры
    #32071370
Genady
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Можно, если отсеивать ошибочные изменения самому, что то типа этого:


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.

...
Рейтинг: 0 / 0
ROLLBACK в триггере и процедуры
    #32071372
Цунцуяби
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
А эмулировать ? SAVE TRAN, буферные таблицы и все такое ?

Целостность зашита в триггеры, но данные необходимо закачивать в цикле, через интерфейсную процедуру.
Закачка сваливается если чего не так. Поддерживать отдельную процедуру проверки - копию из триггеров - можно, но сами понимаете ...
...
Рейтинг: 0 / 0
4 сообщений из 4, страница 1 из 1
Форумы / Microsoft SQL Server [игнор отключен] [закрыт для гостей] / ROLLBACK в триггере и процедуры
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]