Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Posts
    2

    Unanswered: How i can automatic insert?

    I use oracle for the database.
    and have 2 tables. one for issue_record and the other for log_record

    Then, How i can automatic insert the log_record table when issue date less than current date by system (Oracle).


    Anyone please give me the solution of this. Thanks a lot.

  2. #2
    Join Date
    Nov 2002
    Posts
    833
    write a trigger

  3. #3
    Join Date
    Mar 2004
    Posts
    2
    Thanks alot
    but after i try to find the solution by trigger. i still not understand.

    Can you have any example to write it?

    I need to add the log table when the record date in the one table less than current date of system.

    Thanks for your help.

  4. #4
    Join Date
    Nov 2003
    Location
    Dhaka,Bangladesh
    Posts
    86

    Cool Re: How i can automatic insert?

    Hello lucifer_191

    Here is mahfuz want to help you.I'm giving you a very easy example of trigger for automatic Insert into a table.

    Suppose here we want to make a log table on Dept table under scott/tiger.Just follow the step----


    1) First create the log table log_dept

    create table log_dept
    (Deptno number(10) primary key,
    Dname varchar2(10),
    Loc varchar2(10),
    Log_date date
    );

    2) Now just create this simple Trigger named tr_dept

    create or Replace trigger tr_dept
    After Insert
    On Dept
    For Each Row
    Declare
    v_Deptno dept.deptno%type;
    v_Dname dept.Dname%type;
    v_Loc dept.Loc%type;
    v_Log_date date;
    Begin
    v_Deptno := :new.deptno;
    v_Dname := :new.Dname;
    v_Loc := :new.Loc;
    Insert into log_dept
    values(v_Deptno,v_Dname,v_Loc,sysdate);
    End tr_dept;

    Now when u issue any insert command in dept table just do it
    and later just issue - "Select * from log_dept" to show ur Log table.
    Hope you will enjoy.For nay kind of help :mahfuz288@hotmail.com.
    Thanks!

    Mahfuz
    hello

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •