postgresql - how to circumvent missing record type on insert -


i'd make copy of row in 1 table addressed field in table, this:

create or replace function f_ins_up_vorb() returns trigger $$ declare     dienst      dienst%rowtype;     account     record;  begin     -- ...     execute format('select * %s id=$1',dienst.tabelle)     using new.id account;     execute 'insert ' || dienst.tabelle || 'shadow select ($1).*, now(), $2' using account, jobid;     return new; end $$ language plpgsql; 

but yields:

error:  record type has not been registered context:  sql statement "insert accountadshadow select ($1).*, now(), $2" pl/pgsql function f_ins_up_vorb() line 30 @ execute statement 

the tables addressed dienst.tabelle have no common type target table (dienst.tabelle || 'shadow') superset of source table. should work (and does work in trigger function, use new, seems have record type).

is there way around this?

try like:

create or replace function f_ins_up_vorb() returns trigger $$ declare     dienst      dienst%rowtype; begin     -- ...     execute 'insert '||dienst.tabelle||'shadow              select *, now(), $2              '||dienst.tabelle||'               id=$1'     using new.id, jobid;     return new; end $$ language plpgsql; 

if trying create kind of log trigger - read this page first.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -