if (select...) = x then create table command doesn't work Oracle 10g - please assist

I am trying to create a new table when the status in another table = Yes and need help making this work.  Your assistance is appreciated.

(if select status from desaim_status where project_file_id = 2993;) = 'Yes';) then
create table desaim2993 as select * from inven_items_tracking where project_file_id = 2993;
LVL 1
gritscbsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
gnovakhs2nConnect With a Mentor Commented:
you cannot do a create table directly in PL/SQL, but you can use dynamic SQL:


declare v_status varchar2(100);
BEGIN
select max(status) into v_status from desaim_status where project_file_id = 2993;
if v_status= 'Yes' then
execute immediate 'create table desaim2993 as select * from inven_items_tracking where project_file_id = 2993';
end if;
END;

Open in new window

0
All Courses

From novice to tech pro — start learning today.