我试图通过使用HANA存储过程创建视图,但无法做到。"。"附近的语法错误。
我想用HANA存储过程创建视图,但是无法创建。"。"附近的语法错误。在
下面是我的代码:call "PAYROLLDBTEST". getempcodefrommemployeeid (EmpID,EmpCode) AS "EmpCode"
CREATE VIEW "@HourTransactionView" AS SELECT "@TRANSACTION_HOURS"."DocEntry","@TRANSACTION_HOURS"."DocNum",
"@TRANSACTION_HOURS"."U_EmpCode" AS "EmpID",
call "PAYROLLDBTEST".GetEmpCodeFromEmployeeID(EmpID,EmpCode) AS "EmpCode" ,
GetEmployeeFullName("@TRANSACTION_HOURS"."U_EmpCode") AS "FullName", "U_TransactionType" AS "TranCode",
GetHourTableName("U_TransactionType") AS "TableName", GetHourTransactionName("U_TransactionType") AS "TranName",
"U_FromDate", "U_ToDate", DAYS_BETWEEN("U_FromDate", "U_ToDate") + 1 AS "NoOfDays", "U_FromTime", "U_ToTime",
IFNULL("U_WorkHours", 0) AS "NoOfHours", IFNULL("U_OvertimeHours", 0) AS "OvertimeHours",
IFNULL("U_PaidDays", 0) AS "PaidDays", IFNULL("U_UnpaidDays", 0) AS "UnpaidDays",
IFNULL("U_WeekendsCount", 0) AS "Weekends", IFNULL("U_HolidaysCount", 0) AS "Holidays", "U_Remarks", "U_BatchNo",
"U_ProjectCode" AS "ProjectCode"
FROM "@TRANSACTION_HOURS"
INNER JOIN OHEM ON OHEM."empID" = "@TRANSACTION_HOURS"."U_EmpCode";
请帮助我找到解决方案。谢谢你。
根据Hana SQL参考,您不能在select语句中使用过程调用。
http://help.sap.com/saphelp_hanaplatform/helpdata/en/20/fcf24075191014a89e9dc7b8408b26/content.htm也许你可以尝试包装过程"PAYROLLDBTEST"。GetEmpCodeFromEmployeeID转换成一个函数。这可以使用procview来完成。
CREATE PROCEDURE GetEmpCodeFromEmployeeID(...)
LANGUAGE SQLSCRIPT
READS SQL DATA WITH RESULT VIEW ProcView AS
BEGIN
...
END;
Create Function GetEmpCodeFromEmployeeIDFunc(...)
Begin
return Select * from ProcView;
End;
参考:https://help.sap.com/saphelp_hanaplatform/helpdata/en/20/d467407519101484f190f545d54b24/content.htm