I have a simple function (tested on Postgres 9.4) that I need to implement on Postgres 8.4. The error I get is that function format does not exist. I've been trying to find resources but 8.4 is 6 years old at this stage and it's hard to find relevant information apart from the docs!
CREATE OR REPLACE FUNCTION create_table() RETURNS void AS $BODY$ DECLARE rows RECORD; BEGIN FOR rows IN SELECT column as tablename from table LOOP EXECUTE format(' CREATE TABLE IF NOT EXISTS %I ( date date, number integer )', rows.tablename); END LOOP ; RETURN; END; $BODY$ LANGUAGE plpgsql VOLATILE;
Here's the error message:
ERROR: function format(unknown, text) does not exist LINE 1: SELECT format(' ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Any suggestions would be greatly appreciated!
EDIT: I've amended the loop in my function to this:
LOOP EXECUTE 'CREATE TABLE IF NOT EXISTS ' || rows || ' ( date date, number integer )', rows.tablename; END LOOP ;
However now I'm getting this error on quote_ident():
ERROR: function quote_ident(record) does not exist