create table if does not exists - Mailing list pgsql-general

From Yan Cheng Cheok
Subject create table if does not exists
Date
Msg-id 823238.36974.qm@web65702.mail.ac4.yahoo.com
Whole thread Raw
Responses Re: create table if does not exists
List pgsql-general
I try to have the following stored procedure, to help me create tables, if the table does not exists (Is this a good
practiceby the way?) 


if not exists(select * from information_schema.tables where table_name = 'MYTABLE') then

RAISE NOTICE 'table not there yet.';

CREATE TABLE MYTABLE
(
  "value" text NOT NULL
);

end if;


When I run for the 2nd time, 'table not there yet.' still being printed out, al though I check through pgadmin, the
MYTABLEis there. 

May I know how I can fix this?

Thanks and Regards
Yan Cheng CHEOK





pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: A maybe-bug?
Next
From: Chris
Date:
Subject: Re: create table if does not exists