1

Topic: Error by a call in a function body of other function

Hello, I had a following problem:
There is function ValidateCalibrationHistBuffer:

CREATE OR REPLACE FUNCTION "ValidateCalibrationHistBuffer" ()
RETURNS VOID AS $$
DECLARE v_curD DATE; v_stD DATE; v_minD DATE;
DECLARE v_table SMALLINT; v_mark SMALLINT;
DECLARE err_days SMALLINT;
BEGIN
err_days = (SELECT "GetRefErrDays" ());
v_table=1;
v_curD = CURRENT_DATE;
SELECT "ERS_Get_Table_Mark" (v_table, v_minD, v_stD, v_mark); <---- Function invocation
--Other commands using values of variables v_minD, v_stD, v_mark
END;
$$ LANGUAGE plpgsql;

In which the call of the following function is carried out:

CREATE OR REPLACE FUNCTION "ERS_Get_Table_Mark" (v_table SMALLINT, OUT v_date_min DATE, OUT v_date DATE, OUT v_mark SMALLINT)
AS $$
DECLARE v_stD date;
DECLARE v_minD date;
DECLARE v_opt varchar (80);
BEGIN
SELECT START_DATE INTO v_stD FROM ERS_PERIODS_START WHERE TABLE_ID=v_table;
IF v_stD IS NULL THEN
v_date=CURRENT_DATE + integer ' 1 ';
v_date_min=v_date;
v_mark=2;
ELSE
SELECT VALUE INTO v_opt FROM CONFIGURATION WHERE NAME ='ERS_Load_Old ';
SELECT MIN (START_DATE) INTO v_minD FROM ERS_PERIODS WHERE TABLE_ID=v_table;
v_date=v_stD;
v_date_min=v_minD;
v_mark=CASE WHEN v_opt = ' 0 ' THEN 19 ELSE 18 END;
END IF;
END;
$$ LANGUAGE plpgsql;

At performance of the following command:

select "ValidateCalibrationHistBuffer" ();

There is a following error:

 ERROR: the ERROR: function ERS_Get_Table_Mark (smallint, date, date, smallint) does not exist
LINE 1: SELECT "ERS_Get_Table_Mark" (v_table, v_minD, v_stD, v_mark)
^
HINT: Function by a dataful name and types of arguments is not found. Probably, you should add explicit coercions of types.
QUERY: SELECT "ERS_Get_Table_Mark" (v_table, v_minD, v_stD, v_mark)
CONTEXT: function PL/pgSQL "ValidateCalibrationHistBuffer" (), a line 10, the operator a SQL statement
SQL-condition: 42883 

The Question : how it to eliminate?

2

Re: Error by a call in a function body of other function

ASukhov1986;
Though output parameters also it is described in function parameters, to address with them as with parameters it is impossible.
Use syntax select. into...:

SELECT v_date_min, v_date, v_mark into v_minD, v_stD, v_mark
from "ERS_Get_Table_Mark" (v_table);

3

Re: Error by a call in a function body of other function

Melkij;
Yes I and made thanks:

CREATE OR REPLACE FUNCTION "ValidateCalibrationHistBuffer" ()
RETURNS VOID AS $$
DECLARE v_curD DATE; v_stD DATE; v_minD DATE;
DECLARE v_table SMALLINT; v_mark SMALLINT;
DECLARE err_days SMALLINT;
BEGIN
err_days = (SELECT "GetRefErrDays" ());
v_table=1;
v_curD = CURRENT_DATE;
SELECT * FROM "ERS_Get_Table_Mark" (v_table) INTO v_minD, v_stD, v_mark;
....
END;
$$ LANGUAGE plpgsql;