Robert Treat <rtreat@webmd.net> writes:
> strDelete := ''DELETE FROM ''
> || quote_ident(arrTables.table_name)
> || '' WHERE timestamp < now() - ((''''''
> || arrTables.historysize
> || '' days'''' )::interval) '';
> EXECUTE strDelete;
> Note that no "quote_foo" function was needed on the second variable
> since I had to enclose it along with other text within my own quotes.
Seems like it'd be better to use quote_literal, viz
strDelete := ''DELETE FROM ''
|| quote_ident(arrTables.table_name)
|| '' WHERE timestamp < now() - ''
|| quote_literal(arrTables.historysize || '' days'')
|| ''::interval'';
EXECUTE strDelete;
regards, tom lane