# ON_DELETE_REORDER

## Informazioni

- **Tabella**: TB_TIPI_MAT
- **Evento**: DELETE
- **Tipo**: AFTER EACH ROW
- **Stato**: DISABLED

## Codice Sorgente

```sql
TRIGGER "APOLLINARECATERINGPROD"."ON_DELETE_REORDER" 
after DELETE ON TB_TIPI_MAT 
FOR EACH ROW
BEGIN

  FOR TP IN (
    SELECT COD_TIPO, COD_STEP - 1 AS COD_STEP_NEW
    FROM TB_TIPI_MAT T
    WHERE COD_STEP > :OLD.COD_STEP
    AND COD_STEP NOT IN (-2, -1, 0, 9999999)
  )LOOP
    UPDATE TB_TIPI_MAT
    SET COD_STEP = TP.COD_STEP_NEW
    WHERE COD_TIPO = TP.COD_TIPO;
  END LOOP;

END;



```
