Hub Of Geekz

  • Home
  • About Me
  • Contact Us
  • Home
  • Languages
    • C++
    • Java
    • Perl
    • Prolog
    • Bootstrap
  • Database
    • SQL
    • PL/SQL
  • Study
    • Java
      • Java Collection
      • Java Concurrency
      • Java Interview Questions
      • Java Networking
    • Number System
  • Kavita
  • Entertainment
    • Hinglish Cafe
    • Videos
    • Jokes
  • Windows Tricks
  • How To

Sunday, 28 April 2013

Write a PL/SQL code to implement after row trigger.

 Earthcare Foundation NGO     22:45     PL/SQL     4 comments   

Experiment-15

Object: Write a PL/SQL code to implement after row trigger. Create two tables as student_master and audit_student.
Requirement: Windows XP, Oracle 9i.

Program Code:
SQL> create table student_master(rollno number(2), name varchar2(20), age number(2
),city varchar2(20));

Table created.

SQL> drop table student_audit;

Table dropped.

SQL> create table student_audit(rollno number(2), name varchar2(20), operation var
pdate date);

Table created.

SQL> insert into student_master values(1,'sharad',20,9818923723,'delhi');

1 row created.

SQL>  insert into student_master values(2,'abhi',21,9775645621,'haryana');

1 row created.

SQL>  create or replace trigger mytrigger
  2   after update or delete on student_master
  3   for each row
  4   declare
  5   operation varchar2(10);
  6   roll_no number(10);
  7   name varchar2(20);
  8   begin
  9   if updating then
 10   operation:='update';
 11   end if;
 12   if deleting then
 13   operation:='delete';
 14   end if;
 15   roll_no:=:old.roll_no;
 16   name:=:old.name;
 17   insert into audit_student values(roll_no,name,operation,sysdate);
 18   end;

Output:
STUDENT_MASTER
FIELD NAME       DATA TYPE          SIZE
----- -------------------- --------- --------- --------- ---------
RollNo                 Number               2
Name                   Varchar2             20
Age                      Number               2
Phone                  Number               10    
City                      Varchar2             20




STUDENT_AUDIT
FIELD NAME                 TYPE           SIZE
----- -------------------- --------- --------- --------- ---------
Tot_Num             Number               10
Tot_Age               Number               6
OUTPUT AS RESULT :
Tot_Age(20)
1 row created.
Tot_Age(41)
1 row created.








Result: The program to create a trigger has been executed successfully.

  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Email ThisBlogThis!Share to XShare to Facebook
Newer Post Older Post Home

4 comments:

  1. Unknown25 March 2015 at 14:16

    This blog is very useful one.
    Informative...

    ReplyDelete
    Replies
      Reply
  2. Unknown25 March 2015 at 14:17

    This blog is very useful one.
    Informative...

    ReplyDelete
    Replies
      Reply
  3. Unknown25 March 2015 at 14:18

    This comment has been removed by the author.

    ReplyDelete
    Replies
      Reply
  4. Unknown4 October 2015 at 06:54

    Thanks.If you want any kind of improvements at this blog which will make it better just mail me or comment here.

    ReplyDelete
    Replies
      Reply
Add comment
Load more...

Ad


Jobsmag.inIndian Education BlogThingsGuide

Subscribe

Do you want fresh and hot updates about us? Then subscribe to our Feeds.

Total Pageviews

Popular Posts

  • Write a program in PL/SQL to print the factorial of a number.
    In this post I will explain how to get the factorial of any given number. For that first you need to know what is the procedure to find ...
  • To find the GCD of two numbers in PROLOG.
    gcd(X,Y):-X=Y,write('GCD of two numbers is '),write(X); X=0,write('GCD of two numbers is '),write(Y); Y=0,write('G...
  • Write a PL/SQL code to get the Fibonacci Sequence
    First, I will explain what is Fibonacci Sequence and how to get this series. So, Fibonacci Sequence is a series of numbers 0,1,1,2,3,5,8,1...

Label

All Articles Best Resources Blogging Boost Traffic Bootstrap C Plus Plus Collection Comedy Comedy Posts Comedy Videos Concurrency creative commons website Education Employee Entertainment Fibonacci Sequence free images GirlFriend Hinglish Cafe How To Image Websites Inspirational Java Java Interview Questions Java Networking Kavita Sangrah Life Lock Sreen Love Number System Patterns Perl Picture PL/SQL Plastic Engineering Programming Prolog public domain SEO Servlet Short Story Shortcut Keys Social Media Social Services SQL SuVichar Thread Traffic True Events Ultimate Guide Windows Tricks Windows8.1 WordPress

Blog Archive

  • ►  2020 (43)
    • ►  September (41)
    • ►  August (2)
  • ►  2019 (1)
    • ►  July (1)
  • ►  2018 (9)
    • ►  September (7)
    • ►  July (1)
    • ►  May (1)
  • ►  2017 (8)
    • ►  June (3)
    • ►  May (3)
    • ►  March (1)
    • ►  January (1)
  • ►  2016 (2)
    • ►  September (1)
    • ►  January (1)
  • ►  2015 (91)
    • ►  December (1)
    • ►  November (1)
    • ►  October (6)
    • ►  May (10)
    • ►  March (20)
    • ►  February (50)
    • ►  January (3)
  • ►  2014 (339)
    • ►  December (1)
    • ►  October (55)
    • ►  September (58)
    • ►  August (94)
    • ►  July (64)
    • ►  June (67)
  • ▼  2013 (34)
    • ►  August (5)
    • ▼  April (29)
      • Write a PL/SQL code to find the greatest number am...
      • Write a PL/SQL code to create and use process.
      • Write a PL/SQL code to get the Fibonacci Sequence
      • Write a PL/SQL code to implement after row trigger.
      • Write a PL/SQL code to calculate total sal of emp ...
      • Cursor in PL/SQL.
      • Write a program in PL/SQL to print the following p...
      • Write a program in PL/SQL to print the factorial o...
      • To calculate the areas of circles of given radius ...
      • To perform mathematical operation of two numbers u...
      • To perform the string function in simple database ...
      • To perform the numeric function in simple database...
      • To perform logical operations in simple database t...
      • To perform the group function in simple database T...
      • To create the simple relationship between two tabl...
      • To create a set of operation in simple database ta...
      • To alter table of a simple database using CREATE,A...
      • To create a database table using Create, Desc, Ins...
      • To write program in PROLOG to implement Tower in ...
      • To find the sum of given list in PROLOG
      • To create relations in PROLOG
      • To find the largest of three numbers in PROLOG.
      • To find the largest of three numbers in PROLOG.
      • To find the larger of two numbers in PROLOG.
      • To find the GCD of two numbers in PROLOG.
      • To find the factorial of given number in PROLOG.
      • To count the number of elements in a list in PROLOG.
      • To construct a binary tree in PROLOG
      • To perform arithmetic operations in PROLOG
  • ►  2012 (20)
    • ►  November (1)
    • ►  October (15)
    • ►  September (4)

Author

  • Earthcare Foundation NGO
  • Kavita house
  • Unknown
  • Unknown

Info

Copyright © Hub Of Geekz | Powered by Blogger
Design by Hardeep Asrani | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates