Showing PL/SQL ERROR : ORA-00947: not enough values

143 views Asked by At

Please help me, how to fill in the correct values? Because the value is always less, and showing ERR not enough values the error is in here

Here is my code :

CREATE OR REPLACE TRIGGER REGION_HILMI_TRIGGER_WARNING
AFTER INSERT OR UPDATE OR DELETE ON REGION_HILMI
FOR EACH ROW
DECLARE 
warning VARCHAR2(400);
BEGIN 
IF INSERTING THEN 
warning:='Terjadi penambahan data di tabel regions, dengan
nilai region_id='||:NEW.region_id||' dan 
region_name='||:NEW.region_name; 
ELSIF UPDATING THEN 
warning:='Terjadi perubahan data di tabel regions, dengan 
nilai lama region_id='||:OLD.region_id||', 
region_name='||:OLD.region_name||' nilai baru 
region_id='||:NEW.region_id||', region_name='||:NEW.region_name;
ELSIF DELETING THEN 
warning:='Terjadi penghapusan data di tabel regions untuk 
region_id='||:OLD.region_id||' dan region_name='||:OLD.region_name; 
END IF; 
INSERT INTO REGION_HILMI_HISTORY(OLD_REGION_ID,OLD_REGION_NAME,NEW_REGION_ID,NEW_REGION_NAME,CHANGE_TIME,DESCRIPTION)
    VALUES(REGION_HILMI_SEQUENCE.NEXTVAL,USER,TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS'),warning);
END; 
/
3

There are 3 answers

0
TenG On BEST ANSWER

Your INSERT statement shows only 4 items in the VALUES clause but 6 in the column name list. They must both match.

1
Hilmi Afifi On

thankss sir, @TenG solved with adding this scripts :

INSERT INTO REGION_HILMI_HISTORY(OLD_REGION_ID,OLD_REGION_NAME,NEW_REGION_ID,NEW_REGION_NAME,CHANGE_TIME,DESCRIPTION)

    
VALUES(REGION_HILMI_SEQUENCE.NEXTVAL,:OLD.REGION_NAME,:NEW.REGION_ID,:NEW.REGION_NAME,TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS'),warning);
0
Hilmi Afifi On

now then I tried to insert data into my primary table sir,

but it showing error like this appears, after i setting up the trigger

click to show image

now it solved.... problem on trigger,

i change (TO_CHAR) >>> (TO_DATE)

error :

VALUES(REGION_HILMI_SEQUENCE.NEXTVAL,:OLD.REGION_NAME,:NEW.REGION_ID,:NEW.REGION_NAME,TO_CHAR(SYSDATE,'DD-MON-YYYY HH24:MI:SS'),warning);

work :

VALUES(REGION_HILMI_SEQUENCE.NEXTVAL,:OLD.REGION_NAME,:NEW.REGION_ID,:NEW.REGION_NAME,TO_DATE(SYSDATE,'DD-MON-YYYY HH24:MI:SS'),warning);