pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedDatabase Upgrade scripts (AKA Conditional SQL execution)
2+ messages / 2 participants
[nested] [flat]
* Database Upgrade scripts (AKA Conditional SQL execution)
@ 2003-07-07 13:58 Richard Rowell <richard@bowmansystems.com>
0 siblings, 1 reply; 2+ messages in thread
From: Richard Rowell @ 2003-07-07 13:58 UTC (permalink / raw)
To: pgsql-sql
Moving to Postgres from MS SQL server wherever I can. When writing
database upgrade scripts, it is nice to construct the script so it will
run correctly even if run twice. In MS-SQL's TSQL I would do something
like this:
IF( SELECT COUNT(*) FROM sysobjects WHERE name = 'foo' AND type ='U' ) <
1 THEN
CREATE TABLE foo()
END
Can I accomplish this with postgresql without involving an external
process (like say perl)? I guess I could put the upgrade stuff into
PL/SQL functions and just drop the functions when I'm done, but I was
hoping for something a little "cleaner".
--
Richard Rowell <richard@bowmansystems.com>
Attachments:
signature.asc (application/pgp-signature, 188B) download
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Database Upgrade scripts (AKA Conditional SQL execution)
@ 2003-07-07 15:20 Joe Conway <mail@joeconway.com>
parent: Richard Rowell <richard@bowmansystems.com>
0 siblings, 0 replies; 2+ messages in thread
From: Joe Conway @ 2003-07-07 15:20 UTC (permalink / raw)
To: Richard Rowell <richard@bowmansystems.com>; +Cc: pgsql-sql
Richard Rowell wrote:
> Can I accomplish this with postgresql without involving an external
> process (like say perl)? I guess I could put the upgrade stuff into
> PL/SQL functions and just drop the functions when I'm done, but I was
> hoping for something a little "cleaner".
>
There is no way (currently at least) to do this without some kind of
function. I've done it in the past with PL/pgSQL. We've had brief
discussions in the past about how this could be supported, but nothing
conclusive, and no one has cared enough to scratch this particular itch.
Joe
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2003-07-07 15:20 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-07-07 13:58 Database Upgrade scripts (AKA Conditional SQL execution) Richard Rowell <richard@bowmansystems.com>
2003-07-07 15:20 ` Joe Conway <mail@joeconway.com>
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