I'm trying to use a FOR loop:
create or replace function update_revisions() returns trigger as
$$
begin
declare col_name declare col_name information_schema.columns%ROWTYPE;
for col_name in
select column_name from information_schema.columns
where table_name='t'
loop
insert into debug_table values (col_name);
end loop;
end;
$$
language plpgsql;
But it always says:
syntax error at or near 'for'
Could someone please give me a hint what's wrong with it?
beginkeyword, not after, see general syntax here: postgresql.org/docs/9.3/static/plpgsql-structure.html and a few examples here: postgresql.org/docs/9.3/static/plpgsql-declarations.htmlINSERT INTO ... SELECT ...form of INSERT should be sufficient.