无法在HANA Studio中调用过程中的过程

时间:2014-06-09 06:12:24

标签: sql stored-procedures hana hana-studio

我试图在新程序中调用我之前制作的程序。无论我尝试什么,我都会在同一条线上出错。 我原来的路线是:

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;

由于

3 个答案:

答案 0 :(得分: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;

答案 1 :(得分:0)

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

call "_SYS_BIC"."PAYROLLDBTEST/ABS_GetEmployeeHistoryDetail"(:EmpID)

答案 2 :(得分:0)

您无法在CALL声明的FROM部分内执行SELECT

你的程序应该是这样的:

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

SELECT fields
FROM (
  SELECT fields, case1, case2
  FROM ( SELECT * FROM :TEMP ) InnerQuery
) OuterQuery
WHERE (conditions);