此功能基于Oracle PL / SQL函数:
create or replace FUNCTION SP_ComputeEntity (P_ENTITY NUMERIC, P_CAMPAIGN NUMERIC, P_COMPLETE_IF NUMERIC, P_COMPUTE_MODE NUMERIC ) RETURNS VOID AS $$
DECLARE
[..]
-- This is the list of the entity's subordinates
[..]
-- This is the list of the entity's questionnaires
[..]
BEGIN
-- If the entity must not be computed for this campaign stop
[..]
-- Check if already computed .
[..]
-- If not already computed compute it now .
IF V_EXISTS = 0 THEN
-- Loop on subordinates to check if already computed
OPEN ENTITY_COLUMNS;
LOOP
FETCH ENTITY_COLUMNS INTO V_COLUMN_ID;
EXIT WHEN ENTITY_COLUMNS%NOTFOUND;
SP_ComputeEntity(V_COLUMN_ID, P_CAMPAIGN, P_COMPLETE_IF, P_COMPUTE_MODE);
END LOOP;
CLOSE ENTITY_COLUMNS;
[..]
END;
$$
LANGUAGE plpgsql;
我的问题是pgAdmin III给了我 错误:“SP_ComputeEntity”或附近的语法错误 SQL状态:42601 性格:1773 而且我不知道为什么。可以吗?有人可以在函数中调用postgresql中的相同函数吗?
答案 0 :(得分:1)
如果您不需要查询结果,可以使用Perform
PERFORM SP_ComputeEntity(V_COLUMN_ID, P_CAMPAIGN, P_COMPLETE_IF, P_COMPUTE_MODE);
答案 1 :(得分:0)
执行SP_ComputeEntity程序,如
SELECT SP_ComputeEntity(V_COLUMN_ID, P_CAMPAIGN, P_COMPLETE_IF, P_COMPUTE_MODE);
答案 2 :(得分:0)
您也可以像选择和检索变量中的结果一样使用您的函数。
仅举例:
SELECT INTO myvar myres FROM myfunction(param1, param2);