-6
我想創建和編譯以下函數有什麼問題?錯誤(4,1):PLS-00103:遇到符號「AS」
我得到這個錯誤代碼,我不確定它到底出了什麼問題。
Error(4,1): PLS-00103: Encountered the symbol "AS" when expecting one of the following: return
代碼:
create or replace FUNCTION BOD_FM_FSCS_A_Data(
-- Add the parameters for the function here
p_ExclusionsOnly NUMBER DEFAULT 0)
AS
IS
BEGIN
INSERT INTO @ATable
SELECT DISTINCT SCVID,
Title,
Forename1,
Forename2,
Forename3,
CASE
WHEN CompanyName IS NULL
OR CompanyName =''
THEN Surname
ELSE CompanyName
END AS Surname ,
PreviousName,
NI_No,
PassportNo,
OtherNational_ID,
OtherNational_ID_No ,
CompanyNo,
DateOfBirth
FROM DIM_FM_FSCS_Customer customer
INNER JOIN DIM_FM_FSCS_CustomerAccLink cal
ON cal.FSCSCustomerLink=customer.ID
INNER JOIN DIM_FM_FSCS_Account acc
ON acc.ID =cal.FSCSAccountLink
AND ((p_ExclusionsOnly=1
AND acc.ExclusionCode <>'')
OR (p_ExclusionsOnly =0
AND acc.ExclusionCode = ''));
RETURN
END;
'一個例子@ ATable'是無效的表名。您需要雙引號:'「@ATable」' –
這不是什麼導致錯誤 – Azhari
函數需要在CREATE語句中的RETURN子句(在頂部)。 – BriteSponge