What I'm trying to do is create table if not exists and then insert data in it. The script works fine when I only create the table, but not when I add an insert in the script (Error : table or view does not exists for the insert statement). I'm new in Oracle, what am I doing wrong ?
declare
v_table_exists number;
begin
select count(*)
into v_table_exists
from user_tables
where table_name = upper('my_table');
if v_table_exists = 1
then
execute immediate 'drop table my_table';
end if;
execute immediate 'create table my_table
(my_ID int
my_column int
)';
insert into my_table
(my_ID,
my_column
)
values (1,2);
commit;
end;