1

I have a SQL script that sets up a database. One of the operations is creating a PostGIS geometry column:

...
SELECT AddGeometryColumn('table', 'column', 4326, 'POINT', 2);
...

However, this results in the following output:

               addgeometrycolumn                
------------------------------------------------
 public.table.column SRID:4326 TYPE:POINT DIMS:2

This clutters the output of the rest of the operations I'm doing. How can I supress this output?

2 Answers 2

2

You can call the function in FROM clause and add WHERE with a false condition, e.g.:

select res
from AddGeometryColumn('table', 'column', 4326, 'POINT', 2) res
where res isnull;

The function will be executed, the query returning no rows.

You can also try an anonymous code block:

do $$ begin 
perform AddGeometryColumn('table', 'column', 4326, 'POINT', 2); 
end $$;
Sign up to request clarification or add additional context in comments.

Comments

2

In PostgreSQL 9.4 and above, you can simply do the following.

SELECT 
WHERE EXISTS (AddGeometryColumn('table', 'column', 4326, 'POINT', 2));

Interestingly, the manual says that SELECT without an output column is perfectly legal!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.