Update in PL / SQL

1

Given two tables, product and order tables, I'm trying to update the product description of the products table when the product status is 'INATIVE' and the status of the orders table is 'CLOSED'

create table PEDIDOS
(
  CLIENTE_ID NUMBER not null,
  PRODUTO_ID NUMBER not null,
  DT_INSTAL  DATE not null,
  STATUS     VARCHAR2(40),
  PEDIDO_ID  NUMBER not null
)

create table PRODUTOS
(
  PRODUTO_ID NUMBER not null,
  DESCRICAO  VARCHAR2(40) not null,
  VALOR      VARCHAR2(13) not null,
  STATUS     VARCHAR2(13) not null,
  TIPO       VARCHAR2(1)
)

For example, I have a product of id 1 and description 'television', if this television is inactive and the table requests (according to the id) is closed, I want to change the description to any other name. How do I join two tables in the UPDATE command? I can not do it, if anyone can help, thank you.

    
asked by anonymous 03.11.2017 / 20:08

1 answer

0

The update command can only be applied to one table at a time. If you want to ensure that the two will occur together, you can use one transaction. Or you can trigger a trigger that after the first update, check its condition and perform the second update.

    
03.11.2017 / 20:17