This function is based on a Oracle PL/SQL Function:
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;
My problem is that pgAdmin III gives me ERROR: syntax error at or near "SP_ComputeEntity" SQL state: 42601 Character: 1773 and I don't know why. Can it be done? Can someone call in a function the same function in postgresql?