SQL trigger Updates Stock

0

PRODUCT LIST

create table LISTA_DE_PRODUTOS (
   IDPRODUTO            numeric              identity,
   PRECO                money                null,
   DESIGNACAO           varchar(50)          null,
   ALCOOLICO            bit                  null,
   constraint PK_LISTA_DE_PRODUTOS primary key nonclustered (IDPRODUTO)

ITEMS

create table ITENS (
   IDTRANSACAO          numeric              not null,
   IDITEN               numeric              identity,
   IDPRODUTO            numeric              not null,
   QUANTIDADE           decimal(10,2)        null,
   constraint PK_ITENS primary key nonclustered (IDTRANSACAO, IDITEN)

TRANSACTIONS

create table TRANSACOES (
   IDTRANSACAO          numeric              identity,
   IDPULSEIRA           numeric              not null,
   IDPOS                numeric              not null,
   IDLOJA               numeric              not null,
   VALOR_TOTAL          money                null,
   DATA_DA_TRANSACCAO   datetime             null,
   constraint PK_TRANSACOES primary key nonclustered (IDTRANSACAO)

SHOPPING_PRODUCTS

create table LOJAS_PRODUTOS (
   IDLOJA               numeric              not null,
   IDPRODUTO            numeric              not null,
   STOCK_DISPONIVEL     float                null,
   constraint PK_LOJAS_PRODUTOS primary key (IDLOJA, IDPRODUTO)

How do I create a trigger to update inventory with these tables?

With the following details:

Each of the transaction items can only be acquired if there is enough stock in the store where the transaction is being made. If there is not enough stock of at least one of the products, the transaction and its items should not be loaded.

    
asked by anonymous 11.12.2018 / 02:01

0 answers