#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    2
    Rep Power
    0

    Trouble trying to insert new rows into a table from Forms Developer


    I have two datablocks (student and course_section). The premise is to update a detail table, Enrollment with a student id#(s_id), course section id#(c_sec_id) and a NULL value for Grade. I have a Save button with the following code behind it:

    insert into enrollment values
    (:student.s_id, :course_section.c_sec_id, NULL);
    commit;

    I recieve the following error - FRM-40600: Record has already been inserted. I have tried various combinations of student id's and section id's that I know do not exist in the table and I continually recieve this message. Any thoughts?

    Thanks
  2. #2
  3. No Profile Picture
    Senior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Canada
    Posts
    308
    Rep Power
    12
    I want to add a default employee in the each department if there is no employee in the department. I typed the following pl/sql behind the button and it works.
    commit_form;

    DECLARE
    count integer;

    BEGIN

    SELECT count(*) INTO count FROM emp
    WHERE deptno = :dept.deptno;

    if count=0 then
    insert into emp (empno,ename,sal,deptno)
    values(9000,'Default',0,:dept.deptno));
    end if;

    END;

    I dont know what is the problem in your form. can you please send me little bit more detail, like what is the relatioship beetween your table and how many constraints each table has?

    Regards

IMN logo majestic logo threadwatch logo seochat tools logo