3

我正在尝试调用我之前在新程序中创建的程序。无论我尝试什么,我都会在同一行出现错误。我原来的线路是:

CALL "PAYROLLDBTEST"."ABS_GetEmployeeHistoryDetail"(:EmpID)

在此我收到错误“函数或过程的名称无效:ABS_GETEMPLOYEEHISTORYDETAILS:”

然后我尝试了 CALL "PAYROLLDBTEST/ABS_GetEmployeeHistoryDe​​tail"(EmpID) 我收到错误 "sql 语法错误:"(":" 附近的语法不正确

所以请让我知道出了什么问题。

编辑:继承人整个过程:

CREATE PROCEDURE "PAYROLLDBTEST".GetEmploymentHistoryFunction 
(IN EmpID integer, IN StartDate timestamp, IN EndDate timestamp,OUT RETURNVALUE   NVARCHAR) 
LANGUAGE SQLSCRIPT 
AS 

BEGIN 
SELECT *, DAYS_BETWEEN("FromDate", "ToDate") + 1 AS "DaysCount" 
 FROM (SELECT "Code", "Name", "U_LineID", "U_empID", "U_Status", 
        CASE 
            WHEN ("ToDate" < :StartDate) THEN NULL 
            WHEN ("FromDate" > :EndDate) THEN NULL 
            WHEN ("FromDate" < :StartDate AND ("ToDate" BETWEEN :StartDate AND :EndDate)) THEN :StartDate 
            WHEN ("FromDate" < :StartDate AND "ToDate" > :EndDate) THEN :StartDate 
            WHEN (("FromDate" BETWEEN :StartDate AND :EndDate) AND
             ("ToDate" BETWEEN :StartDate AND :EndDate)) THEN "FromDate" 
            WHEN (("FromDate" BETWEEN :StartDate AND :EndDate) AND "ToDate" > :EndDate) THEN "FromDate" 
            WHEN ("ToDate" IS NULL AND "FromDate" < :StartDate) THEN :StartDate 
            WHEN ("ToDate" IS NULL AND ("FromDate" BETWEEN :StartDate AND :EndDate)) THEN "FromDate" 
        END AS "FromDate", 
        CASE 
            WHEN ("ToDate" < :StartDate) THEN NULL 
            WHEN ("FromDate" > :EndDate) THEN NULL 
            WHEN ("FromDate" < :StartDate AND ("ToDate" BETWEEN :StartDate AND :EndDate)) THEN "ToDate" 
            WHEN (("FromDate" BETWEEN :StartDate AND :EndDate) AND
             ("ToDate" BETWEEN :StartDate AND :EndDate)) THEN "ToDate" 
            WHEN ("FromDate" < :StartDate AND "ToDate" > :EndDate) THEN :EndDate 
            WHEN (("FromDate" BETWEEN :StartDate AND :EndDate) AND "ToDate" > :EndDate) THEN :EndDate 
            WHEN ("ToDate" IS NULL AND "FromDate" < :StartDate) THEN :EndDate 
            WHEN ("ToDate" IS NULL AND ("FromDate" BETWEEN :StartDate AND :EndDate)) THEN :EndDate 
        END AS "ToDate", "U_Position", "U_Project", "U_Sponsorship" 
    FROM (
    --select * from ABS_GetEmployeeHistoryDetails WHERE ("EmpID" IN (:EmpID))
  --select * from "PAYROLLDBTEST"."ABS_GetEmployeeHistoryDetails" WHERE ("EmpID" IN (:EmpID))
  CALL "PAYROLLDBTEST"."ABS_GetEmployeeHistoryDetails"(:EmpID,:RETURNVALUE);

 ) InnerQuery
 ) OuterQuery
 WHERE ("FromDate" between :StartDate and :EndDate OR "ToDate" between :StartDate and    :EndDate);


END;

谢谢

4

3 回答 3

2

首先,确保您的过程确实位于您尝试调用的模式中(在您的情况下为 PAYROLLDBTEST)。

您可以通过查看 HANA Studio 中的目录来检查 - 打开目录,然后打开您的架构PAYROLLDBTEST,然后打开文件夹Procedures。您的程序应位于此文件夹中。如果没有,请尝试刷新此文件夹。如果该过程仍然不存在,那么它肯定存储在另一个模式中。

其次,确保使用正确数量的参数调用过程

您提到的过程似乎只有一个参数EmpID,它似乎是一个输入参数。您的过程的名称是GetEmployeeHistoryDe​​tail,因此我假设您至少有一个输出参数作为第二个参数(以获取员工历史记录的详细信息)。如果是这种情况,您应该像这样调用该过程(假设您在另一个过程中并且想要在标量或表变量中使用内部过程的输出):

declare someOutputVariable bigint;
CALL "PAYROLLDBTEST"."ABS_GetEmployeeHistoryDetail" (:EmpID, :someOutputVariable);

或者,如果您的 out 参数是表变量。someTableVariable也可以直接作为外部过程的输出参数:

PROCEDURE "SOMESCHEMA"."yourProcedure" (
      in someInputParameter1 NVARCHAR(255),
      in someInputParameter2 BIGINT,
      out someOutputParameter1 BIGINT,
      out yourSubProcedureOutputParameter "SOMESCHEMA"."some_tabletype") 
   LANGUAGE SQLSCRIPT
   SQL SECURITY INVOKER AS
BEGIN
    // ... (other code logic)
    CALL "PAYROLLDBTEST"."ABS_GetEmployeeHistoryDetail" (:EmpID, :yourSubProcedureOutputParameter);
END;
于 2014-06-09T12:38:27.843 回答
0

您不能在语句的部分执行CALL内部操作。FROMSELECT

您的程序应该像这样工作:

CALL "PAYROLLDBTEST"."ABS_GetEmployeeHistoryDetails"(:EmpID,:TEMP);

SELECT fields
FROM (
  SELECT fields, case1, case2
  FROM ( SELECT * FROM :TEMP ) InnerQuery
) OuterQuery
WHERE (conditions);
于 2015-03-17T09:50:51.987 回答
0

应从 _SYS_BIC 模式调用程序,请尝试以下调用:

call "_SYS_BIC"."PAYROLLDBTEST/ABS_GetEmployeeHistoryDetail"(:EmpID)
于 2014-06-09T08:40:52.437 回答