Maybe I am doing this the wrong way, but how do I check if a table exist?

This works from psql:

select
  relname
from
  pg_class
where
  relname = 'tablename'


But if I try to do the same from a PL/PGSQL stored procedure I get the 
following error message:

ERROR:  unexpected SELECT query in exec_stmt_execsql()

Isn't select's allowed from stored procedures?

Is there a more simple way to check if a table exists?

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to