Search code examples
sqloraclesql-insertplsqldeveloper

PL/SQL Developer Can't See Results Of Insert Statement


As the title says - when I perform an "INSERT" statement, I can't see the results unless I re-open PL/SQL Developer.

To make things a bit more clear: After I perform this statement on the empty table "worker_temp" -

insert into worker_temp
select * from worker_b

I see that 100 records have been inserted: enter image description here
But when I try to see the results using this query:

select * from worker_temp;

I still see an empty table:

enter image description here

But only after I quit PL/SQL Developer and re-open it, I can see the records that I inserted earlier:

enter image description here

Is there a way to see the changes without closing and re-opening PL/SQL Developer?

What I've tried so far:

I've tried to refresh the table using right click on it:

enter image description here

And I've also tried to refresh the whole tables folder:

enter image description here

I also tried committing -

commit;

But I'm not sure what that even is.


Solution

  • Tool agnostic way:

    begin
    insert into worker_temp
    select * from worker_b;
    commit;
    end;
    

    Judging by all the screenshots you are likely getting separate database sessions in 'each' tab you are using - which is a good thing. You have to issue the commit on the same session that performed the insert. Another way of understanding this:

    begin
      insert into worker_temp select * from worker_b;
      DBMS_OUTPUT.PUT_LINE('Rows inserted but not committed ' || SQL%ROWCOUNT);
      -- 'undo' the insert by rolling back the insert instead of commit.
      rollback;
    end;