PL/SQL MOve data from table to another 151117

Hello experts,

We have a table called WRK_COMP_FLIP_REQ and a table called CCM_FLIP_COMPONENT_HIST.
We need to move the data newer than 11-OCT-2015 from WRK_COMP_FLIP_REQ to CCM_FLIP_COMPONENT_HIST.
Table attached shows tables names, Columns names and datatypes.
Pretty simple. Have written script, copied herewith below, that (I think) will do the job.

The only fly in the ointment is we want to insert the record named WRK_COMP_FLIP_REQ .FLIP_DATE into
CCM_FLIP_COMPONENT_HIST. FLIP_START_TIME and CCM_FLIP_COMPONENT_HIST.FLIP_END_TIME.

The script written just selects WRK_COMP_FLIP_REQ .FLIP_DATE twice and inserts it the targe table according
to the sequence of columns. Will this work?

Thanks.

Allen in Dallas


INSERT INTO CCM.CCM_FLIP_COMPONENT_HIST
(CCM_FLIP_COMPONENT_HIST.OLD_COMPONENT_ID, CCM_FLIP_COMPONENT_HIST.NEW_COMPONENT_ID, CCM_FLIP_COMPONENT_HIST.FLIP_START_TIME, CCM_FLIP_COMPONENT_HIST.FLIP_INITIATED_BY)
SELECT
(WRK_COMP_FLIP_REQ.OLD_COMPONENT_ID, WRK_COMP_FLIP_REQ.NEW_COMPONENT_ID, WRK_COMP_FLIP_REQ.FLIP_DATE, WRK_COMP_FLIP_REQ.FLIP_DATE, WRK_COMP_FLIP_REQ.FLIP_USER)
FROM CCM.WRK_COMP_FLIP_REQ
where CCM_FLIP_COMPONENT_HIST.FLIP_START_TIME < '11-OCT-15';
CCM-2675-SQL_dev.xlsx
LVL 1
Allen PittsBusiness analystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
Always to explicit date conversions:

...
CCM_FLIP_COMPONENT_HIST.FLIP_START_TIME < to_date('11-OCT-15','DD-MON-YY');

>>The script written just selects WRK_COMP_FLIP_REQ .FLIP_DATE twice and inserts it the targe table according
 to the sequence of columns. Will this work?

I don't know what you are trying to do here but I don't think it will work.

The insert into select needs the columns to match 1 to 1 and in the same order.

I see 4 columns in the TO table.  You need 4 columns in the select.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
awking00Information Technology SpecialistCommented:
Also, this won't work -
SELECT ...
 FROM CCM.WRK_COMP_FLIP_REQ
 where CCM_FLIP_COMPONENT_HIST.FLIP_START_TIME < '11-OCT-15';
You can't select from one table with a where condition from another table (at least not without a join). Please provide some sample data for the two tables (just enough records to demonstrate the issue) and what you expect the results to after the inserts.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.