我試圖從2個獨立的模式中收集數據。由於單個查詢的複雜性會獲得所有的數據會導致數據庫服務器崩潰,所以我製作了單獨的表格並填充了我需要的所有數據。現在我只需要合併數據並匹配列,以便以後可以刪除任何重複的行。以下是我創建的兩個查詢,用於返回我正在查找的結果。我的問題是,當我運行第二個查詢,我得到以下錯誤:在Oracle中合併和匹配數據
Error at Command Line:7 Column:4
Error report:
SQL Error: ORA-00904: "BOF_FOR_CHUCKSIMPSON"."BATCH_ID": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action
有人可以幫助我瞭解是怎麼回事?
查詢1
CREATE TABLE BOF_FOR_CHUCKSIMPSON AS
SELECT
bbp.SUBCAR "Treadwell", HMM.LADLE "BOTTLE CAR",
bbp.BATCH_ID "Batch ID",
TO_CHAR(bbp.START_POUR, 'yyyy/mm/dd hh24:MI:ss') "Start Pour Time",
TO_CHAR(bbp.END_POUR, 'yyyy/mm/dd hh24:MI:ss') "End Pour Time",
TO_CHAR(hmm.sched_cast_date, 'yyyy/mm/dd hh24:MI:ss') "Sched Cast Date"
FROM bof_batch_pour bbp, [email protected] hmm
WHERE bbp.subcar=hmm.ladle
AND TO_CHAR(hmm.sched_cast_DATE, 'yyyymmddhh24MIss') = TO_CHAR(bbp.SCHED_CAST_DATE, 'yyyymmddhh24MIss')
AND bbp.START_POUR>='25-MAY-11';
CREATE TABLE BOF_FOR_CHUCKSIMPSON2 AS
SELECT bofcs.BATCH_ID "Batch ID", bofcs.sample_time "Sample Time",
bcs.SILICON "Si", bcs.SULPHUR S, bcs.MANGANESE "Mn", bcs.PHOSPHORUS P,
bofcs.TEMPERATURE "Temperature"
FROM bof_chem_sample bcs, bof_celox_sample bofcs
WHERE bofcs.SAMPLE_CODE = bcs.SAMPLE_CODE
AND bofcs.BATCH_ID = bcs.BATCH_ID
AND bofcs.TEMPERATURE > 0
AND bcs.SAMPLE_CODE = 'D1'
AND bofcs.SAMPLE_CODE = bcs.SAMPLE_CODE
AND bofcs.sample_time>'25-may-11'
AND bofcs.sample_time<sysdate
查詢2
merge into bof_FOR_cHUCKSIMPSON2
using bof_FOR_cHUCKSIMPSON
on (bof_FOR_cHUCKSIMPSON.batch_id=bof_FOR_cHUCKSIMPSON2.batch_id)
when matched
then
update
SET bof_FOR_cHUCKSIMPSON.BATCH_ID = bof_FOR_cHUCKSIMPSON2.bATCH_ID
WHEN NOT MATCHED
THEN
INSERT (bof_FOR_cHUCKSIMPSON2.bATCH_ID
VALUES (99999);
嘗試刪除查詢1中Batch_Id的別名.. – StevieG 2011-06-03 14:19:50