PL/SQL Cursor 5 – Create Global Temporary Table

Create a PL/SQL table containing instructorid, firstname, lastname of instructor table and insert values into the table.


    cursor cur1 is select * from empp_a5518;
    emp_row cur1%rowtype;
    ch varchar2(20):=1;
    select upper(tname) into ch from tab where tname like upper('instructor_a5518');

    if(ch=upper('instructor_a5518')) then
        dbms_output.put_line('instructor_a5518 table already created !!');
        execute immediate 'CREATE GLOBAL TEMPORARY TABLE instructor_a5518 ( id  NUMBER,fname VARCHAR2(20), lname  VARCHAR2(20) ) ON COMMIT PRESERVE ROWS';
    end if;


    open cur1;
        fetch cur1 into emp_row;
        exit when cur1%notfound;
        insert into instructor_a5518 values (emp_row.empno,emp_row.empfname,emp_row.emplname);
    end loop;
    close cur1;




You can leave a response, or trackback from your own site.

One Response to “PL/SQL Cursor 5 – Create Global Temporary Table”

  1. I do consider all the ideas you’ve offered on your post.
    They’re very convincing and can certainly work. Nonetheless,
    the posts are too quick for beginners. May you please extend
    them a bit from subsequent time? Thanks for the post.

Leave a Reply