pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kovacs Baldvin <kb136@hszk.bme.hu>
To: Josh Berkus <josh@agliodbs.com>
Cc: Julester <cubalibr@optonline.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Checking for table existence
Date: Tue, 18 Sep 2001 16:41:30 +0200 (MEST)
Message-ID: <Pine.GSO.4.33.0109181624330.21724-100000@ural2> (raw)
In-Reply-To: <web-120865@davinci.ethosmedia.com>

>
> 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@agliodbs.com
>    and data management solutions       (415) 565-7293
>   for law firms, small businesses        fax 621-2533
>     and non-profit organizations.      San Francisco
>

Üdv,
Baldvin





view thread (7+ messages)

Message-ID: <Pine.GSO.4.33.0109181624330.21724-100000@ural2>
Permalink:  ../Pine.GSO.4.33.0109181624330.21724-100000@ural2/
Also on:    postgresql.org/message-id/Pine.GSO.4.33.0109181624330.21724-100000@ural2

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: kb136@hszk.bme.hu, josh@agliodbs.com, cubalibr@optonline.net
  Subject: Re: Checking for table existence
  In-Reply-To: <Pine.GSO.4.33.0109181624330.21724-100000@ural2>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox