如何在另一个过程中调用存储过程,并在Postgresql的同一个过程中使用存储过程的结果?

如何在另一个过程中调用存储过程,并在Postgresql的同一个过程中使用存储过程的结果?,postgresql,plpgsql,Postgresql,Plpgsql,我希望在我的过程中使用inout返回,如下所示: do $$ declare film_count text; begin -- get the number of films CALL abc('999-M-120-20200906-E726265', '911120006710', '120', null); film_count = o_ricode; -- display a message raise notice 'The number of films is

我希望在我的过程中使用inout返回,如下所示:

do $$ 
declare
film_count text;
begin
-- get the number of films
 CALL abc('999-M-120-20200906-E726265', 
 '911120006710', '120', null);
  film_count = o_ricode;
   -- display a message
   raise notice 'The number of films is %', film_count;
end $$;
其中,
o_ricode
是程序“abc”的inout参数

错误:
过程参数“o_ricode”是一个输出参数,但相应的参数不可写上下文:PL/pgSQL函数内联代码块第6行在调用SQL状态:42601

分别调用
abc
过程给出预期结果,但调用另一个过程不起作用

CREATE OR REPLACE PROCEDURE abc(
INOUT o_ricode text)
LANGUAGE 'plpgsql'
 AS $BODY$
DECLARE

BEGIN
 o_ricode := 'SUCCESS';
END;
$BODY$;

消息是干净的-您只能在
INOUT
参数的位置上使用变量。过程不是函数,函数也不是过程

CREATE PROCEDURE proc(INOUT arg1 text)
AS $$
BEGIN
  RAISE NOTICE 'arg1 = %', arg1;
  arg1 := 'xxxx';
END;
$$ LANGUAGE plpgsql;

DO $$
DECLARE var text;
BEGIN
   -- CALL proc('AHOJ'); -- this is your issue
   var := 'AHOJ';
   -- procedure invocation and passing value by ref
   -- in this context, the procedure has not result,
   -- but it can have side effects (outer variables
   -- used as INOUT arguments can be changed)
   CALL proc(var);
   RAISE NOTICE 'var = %', var;
END;
$$;

NOTICE:  arg1 = AHOJ
NOTICE:  var = xxxx
DO
过程和函数(在Postgres中)传递
INOUT
变量的机制不同。对于过程,Postgres模拟通过引用传递值(这只是模拟)。函数的传递值(和获取结果)有很大不同

CREATE FUNCTION func(INOUT arg1 text)
AS $$
BEGIN
  RAISE NOTICE 'arg1 = %', arg1;
  arg1 := 'xxxx';
END;
$$ LANGUAGE plpgsql;

DO $$
DECLARE var text;
BEGIN
   -- function execution, argument is passed as value,
   -- and the variable has assigned the result of function
   var := func('AHOJ');
   RAISE NOTICE 'var = %', var;
END;
$$;

NOTICE:  arg1 = AHOJ
NOTICE:  var = xxxx
DO

这看起来不像是有效的SQL。@laurenzal需要更新代码…请有一个look@a_horse_with_no_name帮我把胶卷计数值贴在上面count@a_horse_with_no_name我已经更新了问题。请看一看