I am creating function in postgresql to update table. when I ran single function it works fine but I use same query inside function it wont works.
update house1 SET calendar= 'H'||' '||house_num::text||' '||left(to_char(sdate, 'Mon'),2) ||' to ' || to_char(sdate, 'DD') ||to_char(rdate, 'Mon-DD') where id=1
Inside function I wrote following query
begin
execute
'UPDATE house1 SET calendar = '
||quote_nullable( 'H')||' '||house_num||' '||left(to_char(sdate, 'Mon'),2) ||' to ' || to_char(sdate, 'DD') ||to_char(rdate, 'Mon-DD')
|| ' WHERE' || 'stage'
'>=' || quote_nullable(0) ;
END
It generates following error
ERROR: column "house_num" does not exist.
Please help me
EXECUTE (...). Just try to insert the first UPDATE statement in your function body and share the result.format()to build dynamic SQL strings