Header Ads

Header ADS

Example of a Sample FOR LOOP In PLSQL

Example of a Sample FOR LOOP In PLSQL

Topic Introduction: This tutorial will give an Example of a Sample FOR LOOP In PLSQL.




Table Create For Data Insert

CREATE TABLE test_data_insert
(
    data_type VARCHAR2 (40),
    insert_date DATE,
    insert_year VARCHAR2 (4),
    insert_slno NUMBER,
    remarks VARCHAR2 (500)
);



FOR LOOP Example

BEGIN
    FOR i IN 1 .. 10
    LOOP
        INSERT INTO test_data_insert (data_type,
                                      insert_date,
                                      insert_year,
                                      insert_slno,
                                      remarks)
             VALUES ('FORLOOP',
                     SYSDATE,
                     TO_CHAR (SYSDATE, 'RRRR'),
                     i,
                     'FORLOOP' || TO_CHAR (SYSDATE, 'RRRR') || i);
    END LOOP;

    COMMIT;
END;
/


Check Inserted Data 

SELECT * FROM test_data_insert;






No comments

Theme images by Deejpilot. Powered by Blogger.