Re: Checking for table existence

From: Kovacs Baldvin <kb136(at)hszk(dot)bme(dot)hu>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Julester <cubalibr(at)optonline(dot)net>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Checking for table existence
Date: 2001-09-18 14:41:30
Message-ID: Pine.GSO.4.33.0109181624330.21724-100000@ural2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

>
> CREATE FUNCTION my_function ( ...
>
> ....
> IF NOT table_exists(''my_table'') THEN
> CREATE TABLE ...
> END IF;
> ....
>
>
> Got the idea?

Not bad... Well, I am not the person questioned... But let me
share a few ideas about it.

The solution what I gave was a "more SQL way" of doing it. So after
creating the function qexec, you could write a long file, x.sql, like

... sql blabla...
... sql blabla...

CASE WHEN ...the table not exests... THEN qexec('the creator sql command')
END;

... sql blabla...

My experience is this is a quite universal style, if a company
would like to create an sql-database structure for a certain job.

Your solution is also based on functions, so the realization is quite
similar. But you have either write a function for every table creation,
or write an intelligent function, which gets HOW to create WHAT table...

My first idea was something like this, but later I thougth it is
"politically more correct" if I use only a very universal function,
what I called qexec.

Moreover, I can imagine that I would see happily this sql-executor
function in the base distribution, not only int the documentation,
as an example. It is quite a good example...

However, your solution is naturally a good and usable solution, please
do not treat this letter as an offensive letter. I only tried to argue
a bit for my way of thinking...

Thanks for reading this, if you reached this pont, :-))

Regads,

Baldvin

>
> -Josh
>
>
>
> ______AGLIO DATABASE SOLUTIONS___________________________
> Josh Berkus
> Complete information technology josh(at)agliodbs(dot)com
> and data management solutions (415) 565-7293
> for law firms, small businesses fax 621-2533
> and non-profit organizations. San Francisco
>

Üdv,
Baldvin

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Kovacs Baldvin 2001-09-18 14:45:33 Re: Out of free buffers... HELP!
Previous Message Tom Lane 2001-09-18 13:45:10 Re: Out of free buffers... HELP!