Tuesday, January 18, 2011

Oracle - EXECUTE IMMEDIATE



DECLARE

    SQL_QRY VARCHAR2(100);
BEGIN

    SQL_QRY := 'INSERT INTO TEMPDEPT VALUES (SEQ1.NEXTVAL,''ON-SITE DEPT'')';
   
    EXECUTE IMMEDIATE SQL_QRY;
   
        DBMS_OUTPUT.PUT_LINE ('RECORD INSERTED');
        COMMIT;       
   EXCEPTION
   WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SQLERRM);  
END;

No comments:

Post a Comment