I'm glad to hear you got it working.
In explanation to my response:
the pg_class internal table lists all the
relationships in the database.
relkind='r' means that the relation you are looking
for is a table (relation), I believe that will also find views.
relname is the name of the object if your table is
called parts
select * from pg_class where relkind='r' and
relname='parts' will give you the pg_class record for the table if it exists and
nothing if it doesn't.
you could also do a select count(*) or select 1 In
any case if there is a resultset the table exists and if there is no resultset
the the table does not.
Using the pg_tables view is a better idea in any
case, as it is cleaner.
Sim
|
Title: RE: [GENERAL] pl sql to check if table of table_name exists