Solved

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

Posted on 2009-04-09
2
667 Views
Last Modified: 2012-05-06
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;
0
Comment
Question by:gritscbs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
gnovakhs2n earned 500 total points
ID: 24110147
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Merge two rows in SQL 4 33
IIF in access query 19 41
SQL Select Query help 1 38
TSQL Assignining CTE column in to a variable 3 12
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question