【发布时间】:2017-08-09 03:44:45
【问题描述】:
我尝试创建和编译的以下函数有什么问题?
我收到此错误代码,但我不确定它到底出了什么问题。
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" -
这不是导致错误的原因
-
函数在 CREATE 语句中需要一个 RETURN 子句(在顶部)。
-
所以在我提供了解决第一个问题所需的帮助之后,你改变了问题......玩得很好
-
您可以细化一个问题,但不能完全改变问题的方向——这个站点并不是真正打算成为一个迭代调试助手。您粘贴的代码在顶部看起来也很错误 - 您可能需要修复它。
标签: oracle