Sql trigger for updating one table from another

07 Jan

A computed column is a virtual column that is not physically stored in the table, unless the column is marked PERSISTED.

Without a column list, the trigger fires when any column of the associated table is updated.

For more information about the column list, see " CREATE OR REPLACE TRIGGER log_salary_increase AFTER UPDATE OF salary ON employees FOR EACH ROW BEGIN INSERT INTO Emp_log (Emp_id, Log_date, New_salary, Action) VALUES (: NEW.employee_id, SYSDATE, : NEW.salary, 'New Salary'); END; / DECLARE sal_diff NUMBER; BEGIN sal_diff := : NEW.salary - : OLD.salary; DBMS_OUTPUT. PUT('Old salary = '

By default, a trigger is created in the enabled state. When a trigger fires, tables that the trigger references might be undergoing changes made by SQL statements in other users' transactions.

; SELECT (column_nm,…..) FROM tablenm; Select empno,empnm from emp; SELECT * FROM tablename; Select * from emp; SELECT * FROM tablename WHERE conditions; Select * from emp where salary CREATE TABLE tablename(col_nm,col_nm…) AS SELECT col_nm,col_nm FROM tablename; EXAMPLEs: 1) CREATE TABLE emp_temp(eno,enm) AS SELECT emp_no,emp_nm FROM emp; 2) CREATE TABLE emp_temp AS SELECT emp_no,emp_nm FROM emp; 3) CREATE TABLE emp_temp AS SELECT * from emp; 4) CREATE TABLE emp_temp AS SELECT * FROM emp Where salary INSERT INTO tablename(col_nm,col_nm,….) SELECT col_nm,col_nm… insert into emp_copy(eno,enm) select eno,enm from emp; insert into emp_copy select * from emp; ALTER TABLE tablename ADD (new_colnm datatype(size),…..); ALTER TABLE tablename MODIFY(colnm new_datatype(new_size),…..); Eg.

Like a stored procedure, a trigger is a named PL/SQL unit that is stored in the database and can be invoked repeatedly.

The expression can be a noncomputed column name, constant, function, variable, and any combination of these connected by one or more operators.

The expression cannot be a subquery or contain alias data types.

PUT_LINE('Old value of CLOB column: '||: OLD.c1); DBMS_OUTPUT.

--Disk-Based CREATE TABLE Syntax CREATE TABLE [ database_name . For more information about File Tables, see File Tables (SQL Server).

sql trigger for updating one table from another-25