我正在開發一個項目,並且需要編寫存儲過程而不是SQL查詢。我從來沒有這樣做過,我現在通過將寫入的sql轉換爲過程來嘗試。但是,我無法獲得這個錯誤並且無法正常工作。從你們這些人的任何建議是非常有幫助的解決這個..SQL到存儲過程
SQL:
create or replace
PROCEDURE MS_TST_PROC AS
BEGIN
DECLARE
l_organization varchar2(40);
l_framework varchar2(10);
l_sub_category_code varchar2(20);
l_sub_category varchar2(20);
l_TST_function varchar2(20);
l_questionnaire_name varchar2(20);
l_responded_on varchar2(20);
l_overall_score number(10);
l_target_score number(10);
l_maturity number(10,2);
l_full_name varchar2(20);
cursor c_get_details
is
select
ts.organization_name,
q.framework,
q.sub_category_code,
q.sub_category,
tst.tst_function,
q.questionnaire_name,
resp.responded_on ,
resp.overall_score,
ts.target_score,
Round((resp.overall_score/ts.target_score)*100,2) as Maturity,
users.first_name || ' ' || users.last_name as full_name
into
l_organization,
l_framework,
l_sub_category_code,
l_sub_category,
l_tst_function,
l_questionnaire_name,
l_responded_on,
l_overall_score,
l_target_score,
l_maturity,
l_full_name
from MS_CMM_QUESTIONNAIRE q
INNER JOIN MS_CMM_TARGET_SCORE ts
on q.sub_category_code = ts.sub_category_code
INNER JOIN MS_CMM_CSF_FUNCTIONS tst
on tst.sub_category_code = q.sub_category_code
INNER JOIN MS_QSM_QUESTIONNAIRE qsm
on q.QUESTIONNAIRE_NAME = qsm.QUE_NAME
INNER JOIN MS_QSM_QUESTNR_RESP resp
on resp.QUESTIONNAIRE_ID = qsm.QUE_ID
and resp.applies_to_object = ts.organization_name
INNER JOIN SI_USERS_T users
on users.user_name = resp.respondent;
END MS_TST_PROC;
和編譯錯誤說:
Error(60,1): PLS-00103: Encountered the symbol "END" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior
你確定你是使用SQL Server的工作?在sql server中沒有創建或替換(還)。而你的錯誤信息來自Oracle。 –
對不起,你說的對,讓我改變我的標籤。 – samuelebe
@SeanLange我在想同樣的事情。 – Mike