我正在尝试创建和编译以下函数有什么问题?
我收到此错误代码,我不确定它究竟出了什么问题。
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;
答案 0 :(得分:2)
错误不言而喻:
错误(4,1):PLS-00103:遇到符号&#34; AS&#34;当期待一个 以下内容:return
删除AS并定义函数RETURN
create or replace FUNCTION BOD_FM_FSCS_A_Data(
-- Add the parameters for the function here
p_ExclusionsOnly NUMBER DEFAULT 0 )
RETURN NUMBER....
以下是docs
的示例CREATE FUNCTION get_bal(acc_no IN NUMBER)
RETURN NUMBER
IS acc_bal NUMBER(11,2);
BEGIN
SELECT order_total
INTO acc_bal
FROM orders
WHERE customer_id = acc_no;
RETURN(acc_bal);
END;
/