Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Friday, December 21, 2018

Mass Update and Insert in Oracle

UPDATE tab1 t1 SET col_1 = (SELECT col_1 FROM tab2 t2 WHERE t1.id=t2.id);

INSERT INTO table1 SELECT * FROM table2 WHERE ...

INSERT INTO table1 (col_1, col_2) SELECT col_1, col_2 FROM table2 WHERE ... 

Oracle triggers

Oracle trigger can be used to modify data before update or insert in the same table.

Oracle update trigger:

CREATE OR REPLACE TRIGGER update_time_col
  BEFORE
    UPDATE OF col_1, col_2
  ON tab
  FOR EACH ROW
BEGIN
  CASE
    WHEN UPDATING('col_1') THEN
      :new.time_col := SYSTIMESTAMP - INTERVAL '1' DAY;
      :new.col_1 := 'updated ' || :old.col_1;
    WHEN UPDATING('col_2') THEN
      :new.time_col := SYSTIMESTAMP + INTERVAL '1' DAY;
      :new.col_2 := 'updated ' || :old.col_2;    
  END CASE;
END;
/

Oracle insert trigger:

CREATE OR REPLACE TRIGGER insert_time_col
  BEFORE
    INSERT
  ON tab
  FOR EACH ROW
BEGIN
  :new.time_col := SYSTIMESTAMP + INTERVAL '10' DAY;
  :new.col_1 := 'insert ' || :new.col_1;  
  :new.col_2 := 'insert ' || :new.col_2;
END;
/




Sunday, September 27, 2015

Upgrade and Update Ubuntu Linux

On Ubuntu you can perform following updates:
sudo apt-get update      
sudo apt-get upgrade       
sudo apt-get dist-upgrade  
If you want install newer version of operating system for example you want to migrate from 14.04 to 14.10
sudo do-release-upgrade  
for troubleshooting visit https://help.ubuntu.com/community/Upgrades#Upgrade_policy