这是我的简单匿名代码块:
do $$
declare foo varchar(50) := '';
begin
for a in
select a from (values('foo'), ('bar'), ('fooBar')) s(a)
loop
foo := a;
print foo;
end loop;
end;
$$;
当我运行它时:
psql -f test.sql
我收到此错误:
psql:test.sql:11: ERROR: loop variable of loop over rows must be a record or row variable or list of scalar variables
LINE 4: for a in
^