Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Create a table only if the table doesn't exists

Re: Create a table only if the table doesn't exists

From: DA Morgan <damorgan_at_psoug.org>
Date: Mon, 26 Jun 2006 12:44:46 -0700
Message-ID: <1151351089.212990@bubbleator.drizzle.com>


bbulsara23_at_hotmail.com wrote:
> DA Morgan wrote:

>> Better but still a very bad idea. What is the business case for
>> implementing a known bad practice of creating tables with procedural
>> code?

>
> I don't know what his business case is, but I can tell you one of mine!
>
> In a test environment I recently came across a need to creating tables
> on the fly. I was developing a suite of unit tests based around
> Feuersteins' ut_plsql. The unit test setup and teardown procedures
> required that tables were created and torn down in package/procedural
> code, so the unit tests were performed against isolated controlled data
> known to and populated by the unit test package.
>
> In the setup code, a test table was procedurally created and populated.
> In the teardown code, the test table was dropped and remaining schema
> objects restored to their initial state. The unit tests used the known
> data populated in the table and tested it against expected results.
>
> This is a valid reason for wanting to create (and drop) tables on the
> fly, the business case being the assurance that the system behaves as
> designed and expected through thorough (automated unit) testing.
> Feuerstein even has examples (eg. testproc.html from the ut_plsql
> documentation) where he demonstrates creating tables on the fly, and
> why he does it.
>
> The OP doesn't give much detail, but perhaps, just perhaps, his
> business case is as valid as this.
>
> More information on ut_plsql can be found here:
> http://utplsql.sourceforge.net/
>
> Regards
> Barry

I rarely disagree with Steven but if he is advocating using PL/SQL to build schema objects I stand in opposition.

Populating tables with procedural code? Fine! Creating them? Absurd.

There is a wonderful piece of Oracle syntax called "CREATE SCHEMA" and it is the best way to build objects. Anything else should be done the way Oracle does it with all of the scripts in $ORACLE_HOME/rdbms/admin.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Mon Jun 26 2006 - 14:44:46 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US