我想在oracle中創建一個過程,從PL SQL塊中調用後,將在數據庫中創建一個視圖,從中查詢報表的數據。我是Oracle新手,需要此代碼的幫助。在Oracle中創建一個過程來創建視圖
CREATE OR REPLACE PROCEDURE CREATE_VIEW
(
TO_DT IN Date
) AS
BEGIN
Create or Replace view BORR_DUR As
SELECT e."Deal_No", (Select "DeskName" From MM_S_DESK Where e."DeskCode" = MM_S_DESK."DeskCode") Facility, e."Remarks" Counterparty,
m."MaturityDate", m."PriRedem" Principal,
(select MAX("INTEREST_RATE") from MM_BOR_PLA_PAR d
WHERE e."Deal_No" = d."DEAL_NO" and "INTERESTINPUTDATE" <= to_dt)/100 yield, (m."MaturityDate" - To_date(to_dt,'dd/mm/yyyy')) Days_to_Mat,
Round(((m."MaturityDate" - To_date(to_dt,'dd/mm/yyyy'))/365)/ (1+((select MAX("INTEREST_RATE") from MM_BOR_PLA_PAR d
WHERE e."Deal_No" = d."DEAL_NO" and "INTERESTINPUTDATE" <= to_dt)/100)),4) MDURATION
FROM MM_T_BORROWING e, MM_T_BORROWING_PM_DETAIL m
Where e."DeskCode" in ('10','11','12','13') and e."Value_Date" <= to_dt and e."Maturity_Date" > to_dt and e."Status" not in ('C', 'D', 'Z', '0','X')
and e."Deal_No" = m."Deal_No" and "PriRedem" > '0' and m."MaturityDate" > to_dt;
END CREATE_VIEW;
在編譯時,我得到PLS00103錯誤,說
遇到的符號 「創建」 期待 之一以下....
解決這個任何幫助時問題將不勝感激。
你需要做的像'EXECUTE IMMEDIATE「創建或替換.....」'全該聲明立即執行。 –
你爲什麼要這樣做?通過編寫一個過程而不是僅僅運行CREATE VIEW語句,你會獲得什麼? –
我寧願運行一個語句,但發現很難直接在PL SQL中運行,Execute Immediate在6i中不可用,並且簡單的執行或執行查詢aint並不適用於我。 –