今天,我定义了一个函数,在循环中使用插入语句。但是HAWQ返回错误:
ERROR: could not serialize unrecognized node type: 43983632 (outfast.c:4742)
CONTEXT: SQL statement "insert into t(id,value) values(1,0.1)"
PL/pgSQL function "test_function" line 6 at SQL statement
我做了一些测试,发现当我在循环中使用'insert statements'时,会报错。如果我删除相关的“插入语句”,它可以正常运行。
下面是一个测试示例:
CREATE OR REPLACE FUNCTION test_function()
RETURNS int AS
$BODY$
declare
number int;
begin
number := 1;
while number <= 10 loop
insert into t(id,value) values(1,0.1);
number := number+1;
end loop;
return number;
end
$BODY$
LANGUAGE plpgsql ;
然后我使用'select test_function();' 调用该函数。它将返回上面提到的错误。
这是否意味着我不能在 plpgsql 循环中使用 SQL 语句?
谢谢。此致。