Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2008
    Posts
    16

    Unanswered: whats wrong with this?

    Here i have two tables
    1> attendenace--column-->empid,indate,outdate..............
    2> employees--column---> empid..........

    i AM required to insert all the employee id's(frm employee table) into attendance table that are not present attendace table for given indate(date)
    as other column for the newly inserted empid will be allocated with nulls i have to convert them to 0's

    Now the problem is if i run this trigger after the first insert all the other employees are set to zeros so i probably have to run a time based trigger which i am not aware of can u help me:

    i have come this far please make the correction for the code:

    ---------------------------------------------------------------------------
    CODE
    ----------------------------------------------------------------------------
    CREATE TRIGGER test AFTER INSERT on attendance
    FOR EACH ROW
    BEGIN

    insert into attendance(empid,indate) values(employee.empid,sysdate) where empid= (select empid from employee where empid not in(select empid from attendence where indate=sysdate)) ;

    UPDATE table attendance SET field=0 WHERE field IS NULL;

    end;
    ------------------------------------------------------------------------------------
    Last edited by skarri; 06-24-09 at 13:02.
    "TALK SENSE TO FOOL. HE CALLS U FOOLISH"

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Nope, you are not required to do that.
    Employees who do not exist for a given time period can easily be identified by the fact that they do not have a record in the table!
    George
    Home | Blog

Posting Permissions

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