Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 $$

    RETURN EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = $1 AND column_name = $2);

$$LANGUAGE plpgsql;
share|improve this question
Can you paste the lines before and after the error is thrown? – DrColossos May 10 '11 at 7:25
Can you run the script in psql? The syntax all looks good as far as I can see - is it possible there are non-visible characters in the script that are causing the error? – Jack Douglas May 10 '11 at 10:50
Maybe an escaping issue? As already mentioned, the syntax is fine, is there any unsecaped " or ' that may be breaking the script or is a " or ' missing? – DrColossos May 10 '11 at 14:38
Shouldn't be an escaping issue or a non-visible script because if I run the statements individually then it seems to be fine. I even tried removing statements one by one starting from the end but it still hits the same error at the same line. – Fung May 11 '11 at 3:48
When you remove the comment is the error still at the same line or has it moved? Have you tried importing it via the command line? – DrColossos May 12 '11 at 13:09
up vote 2 down vote accepted

Per the comment by Fung: was actually some non-visible character at the beginning of each comment. And the reason the statements still worked when run individually was because I was not running them with the comments

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.