<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffcc" text="#000000">
    Hi Feiyi,<br>
    <br>
    Thanks... but that's not quite it. :-(&nbsp; Bob suggested this as well
    but that is not the same thing as idempotent at least not w.r.t. the
    scenario I have in mind.... If I have a table that is already there
    and is populated with stuff, I don't want to drop the table, I just
    want the create not to happen.&nbsp; Same thing for schema creation.&nbsp;
    Especially in the latter case, I don't want to drop me schema if it
    applies to a larger set of tables than then sql script in question
    is written to address.&nbsp; Basically you should be able to run this
    script over and over and over, and each time after the first, it
    doesn't bomb telling you things already exist.<br>
    <br>
    I can't be the only person in the world that wants this... H2
    figured this out, is there anything that I can do to get
    functionality I am looking for from postgres?&nbsp; Grrrr... postgres...
    su#@$%&amp;<br>
    <br>
    Help!?<br>
    <br>
    On 2/4/11 10:11 AM, Wang, Feiyi wrote:
    <blockquote cite="mid:FD7641AD-EAA9-4585-87F3-817B2DB9668B@ornl.gov"
      type="cite">
      <pre wrap="">For postgres, I think you can do:

if table exists, drop the table first
otherwise create.

Feiyi


On Feb 4, 2011, at 12:53 PM, Gavin M. Bell wrote:

Hi,

:-(
I tried that... it doesn't work for postgres :-|.
I am trying to find the analogous command for postgres.

(maybe we should just use H2...) ;-).


On 2/4/11 9:50 AM, Cinquini, Luca (3880) wrote:
Hi Gavin,
this kind of statements worked for Java H2DB - not sure about postgres...

-- WORKFLOW INSTANCE TYPE
CREATE TABLE IF NOT EXISTS WORKFLOW_INSTANCE_TYPE (
TYPE INT PRIMARY KEY NOT NULL,
DESCRIPTION VARCHAR(200) NOT NULL
);
MERGE INTO WORKFLOW_INSTANCE_TYPE (TYPE, DESCRIPTION ) VALUES (1, 'DESDynI Standard');

Luca

On Feb 4, 2011, at 10:45 AM, Gavin M. Bell wrote:

Hey SQL Mavens...

Does anyone know how to create idempotent SQL scripts?
If something is there already, then don't create it...
If it is not, then do so.
(the pithier the better)

Thanks

--
Gavin M. Bell
Lawrence Livermore National Labs
--

 "Never mistake a clear view for a short distance."
               -Paul Saffo

(GPG Key - <a class="moz-txt-link-freetext" href="http://rainbow.llnl.gov/dist/keys/gavin.asc">http://rainbow.llnl.gov/dist/keys/gavin.asc</a>)

 A796 CE39 9C31 68A4 52A7  1F6B 66B7 B250 21D5 6D3E


_______________________________________________
GO-ESSP-TECH mailing list
<a class="moz-txt-link-abbreviated" href="mailto:GO-ESSP-TECH@ucar.edu">GO-ESSP-TECH@ucar.edu</a><a class="moz-txt-link-rfc2396E" href="mailto:GO-ESSP-TECH@ucar.edu">&lt;mailto:GO-ESSP-TECH@ucar.edu&gt;</a>
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/go-essp-tech">http://mailman.ucar.edu/mailman/listinfo/go-essp-tech</a>



--
Gavin M. Bell
Lawrence Livermore National Labs
--

 "Never mistake a clear view for a short distance."
               -Paul Saffo

(GPG Key - <a class="moz-txt-link-freetext" href="http://rainbow.llnl.gov/dist/keys/gavin.asc">http://rainbow.llnl.gov/dist/keys/gavin.asc</a>)

 A796 CE39 9C31 68A4 52A7  1F6B 66B7 B250 21D5 6D3E


_______________________________________________
GO-ESSP-TECH mailing list
<a class="moz-txt-link-abbreviated" href="mailto:GO-ESSP-TECH@ucar.edu">GO-ESSP-TECH@ucar.edu</a><a class="moz-txt-link-rfc2396E" href="mailto:GO-ESSP-TECH@ucar.edu">&lt;mailto:GO-ESSP-TECH@ucar.edu&gt;</a>
<a class="moz-txt-link-freetext" href="http://mailman.ucar.edu/mailman/listinfo/go-essp-tech">http://mailman.ucar.edu/mailman/listinfo/go-essp-tech</a>

</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Gavin M. Bell
Lawrence Livermore National Labs
--

 "Never mistake a clear view for a short distance."
                      -Paul Saffo

(GPG Key - <a class="moz-txt-link-freetext" href="http://rainbow.llnl.gov/dist/keys/gavin.asc">http://rainbow.llnl.gov/dist/keys/gavin.asc</a>)

 A796 CE39 9C31 68A4 52A7  1F6B 66B7 B250 21D5 6D3E
</pre>
  </body>
</html>