0

Создаю триггер

CREATE TRIGGER InsertInOrderProducts
ON OrderProducts FOR INSERT
AS

BEGIN
    IF ((SELECT inserted.quantity FROM inserted) > (SELECT Products.balance FROM Products WHERE Products.id = inserted.product_id))
    BEGIN
        ROLLBACK TRAN
        PRINT 'Нет требуемого колличества товара'
    END
END

Ошибка

Не удалось привязать составной идентификатор "inserted.product_id". Что делаю не так?

1 ответ 1

1
ALTER TRIGGER InsertInOrderProducts
ON OrderProducts FOR INSERT
AS

BEGIN
    IF ((SELECT inserted.quantity FROM inserted) > (SELECT Products.balance FROM Products, inserted WHERE Products.id = inserted.product_id))
    BEGIN
        ROLLBACK TRAN
        PRINT 'Нет требуемого колличества товара'
    END
END

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.