I'm very new to PostgreSql and still learning the ropes.
I have a really long script for setting up a new copy of my database. It creates functions, runs them, does some inserts and a bunch of other stuff. When I try to run this entire script in the pgAdminIII Query Tool, it throws an error that doesn't seem to make sense.
ERROR: syntax error at or near ""
LINE 18: /*
^
This error gets thrown right after the first alter function owner statement which is after the first create function statement.
If I take each statement out and run them individually then everything runs OK. What gives?
Lines before error:
ALTER FUNCTION table_exists(text) OWNER TO postgres;
Lines at error:
/*
-- Function : column_exists(text, text)
-- Function output : true / false
*/
Lines after error:
CREATE FUNCTION column_exists(tablename text, columnname text)
RETURNS boolean AS $$
BEGIN
RETURN EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = $1 AND column_name = $2);
END;
$$LANGUAGE plpgsql;
Best Answer
Per the comment by Fung: