我创建了一个存储过程,函数已经成功创建。但是当我调用函数时出现了错误。我该如何解决这个问题?
错误信息如下:
ERROR: 未识别的转换类型说明符“a” CONTEXT: PL/pgSQL 函数 dwgcould.updatescale(integer,integer) 的第6行 EXECUTE 语句 ********** 错误 ********** ERROR: 未识别的转换类型说明符“a” SQL 状态: 22023 上下文:PL/pgSQL 函数 dwgcould.updatescale(integer,integer) 的第6行 EXECUTE 语句
CREATE OR REPLACE FUNCTION scale(IN id integer, IN scale integer) RETURNS integer
AS $$
DECLARE
result int;
BEGIN
IF (SELECT COUNT(*) FROM pg_tables where tablename = format('table_%s_id',id)) > 0 then
EXECUTE format('update table_%s_id set geom = ST_Scale(geom, %a, %a',id, scale, scale) using id, scale;
EXECUTE format('update table_&s_id2 set geom = ST_Scale(geom, %a, %a',id, scale, scale) using id, scale;
IF FOUND THEN
result:= 1;
return result;
ELSE
result:=0;
return result;
END IF;
ELSE
result:=2;
return result;
END IF;
END;
$$ LANGUAGE plpgsql;
%s
。 - Patrickresult
变量是无用的。你可以直接使用return 1;
或者return 0;
。 - user330315