HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMinor

pgAdmin Query Tool throws error when I try to run multiple statements

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
pgadminerrorrunstatementsquerythrowsmultiplewhentooltry

Problem

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;

Solution

Per the comment by Fung:


...it 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

Context

StackExchange Database Administrators Q#2620, answer score: 2

Revisions (0)

No revisions yet.