Giter Club home page Giter Club logo

ex-10-simulating-clustering-using-weka-data-mining-and-analysis-tool's Introduction

Ex. No: 10 Triggers

Date:

AIM: To create a Trigger using PL/SQL.

Steps:

  1. Create employee table with following attributes (empid NUMBER, empname VARCHAR(10), dept VARCHAR(10),salary NUMBER);
  2. Create salary_log table with following attributes (log_id NUMBER GENERATED ALWAYS AS IDENTITY, empid NUMBER,empname VARCHAR(10),old_salary NUMBER,new_salary NUMBER,update_date DATE);
  3. Create a trigger named as log_salary-update.
  4. Inside the trigger block, Insert the values into the salary_log table whenever the salary is updated.
  5. End the trigger.
  6. Update the salary of an employee in employee table.
  7. Whenever a salary is updated for the employee it must be logged into the salary_log table with old salary and new salary.
  8. Display the employee table, salary_log table.

Program:

Create employee table

CREATE TABLE employee(empid NUMBER, empname VARCHAR(10), dept VARCHAR(10),salary NUMBER);

Create salary_log table

CREATE TABLE salary_log(log_id NUMBER , empid NUMBER,empname VARCHAR(10),
                        old_salary NUMBER,new_salary NUMBER,update_date DATE);

PLSQL Trigger code

CREATE OR REPLACE TRIGGER log_salary_update
BEFORE UPDATE ON employee
FOR EACH ROW
DECLARE
    v_old_salary NUMBER;
    v_new_salary NUMBER;
BEGIN
    v_old_salary := :old.salary;
    v_new_salary := :new.salary;

    IF v_old_salary <> v_new_salary THEN
        INSERT INTO salary_log (empid, empname, old_salary, new_salary, update_date)
        VALUES (:old.empid, :old.empname, v_old_salary, v_new_salary, SYSDATE);
    END IF;
END;
/

Output:

Screenshot 2023-10-03 161552

Result:

Thus the trigger using pl/sql has been created sucessfully.

ex-10-simulating-clustering-using-weka-data-mining-and-analysis-tool's People

Contributors

bala291 avatar dineshgl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.