Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Check if table exists



Even if I've been using Postgres for some years, I figure that this 
question fits best on this list:

How do I check if a table exists, eg. from a PLPGSQL function?

I've got a section of a function that only should be run if it's called 
from a certain context, that is if the temporary table 'tmp_sources' is 
found. But if I try with the line 

    IF EXISTS (SELECT * FROM tmp_sources) THEN

The function throws an error:

    ERROR: relation "tmp_sources" does not exist

Which is kind of off the mark in my context.
-- 
Leif Biberg Kristensen | Registered Linux User #338009
Me And My Database: http://solumslekt.org/blog/



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group