Brad Berens wrote:
First, thanks everyone for the responses. Unfortunately I'm trying to add derby support to a previously existing open source app and I'd like to not have to rewrite the entire deployment code to do this. As a workaround, is it possible to force a particular return from derby so that it won't throw an exception? Could I get the effect I'm looking for using a CASE WHEN?
Hello Brad,

What exactly are your requirements?
Can you for instance create a stored procedure to thandle the logic for you? This would require that you use a CallableStatement instead of a PreparedStatement (or a Statement), and that you install the stored procedure into the database. This is not a solution if you are looking for a portable way of doing this... The portable way would probably be to use the metadata calls, as already mentioned by Dyre.
I am not aware of any way to force Derby to not throw an exception.

When it comes to CASE WHEN, I don't think you can issue DDL operations as part of it.

I personally think handling the issue in the application is the easiest way of dealing with this, but maybe someone else has some smart ideas?


regards,
--
Kristian




On Dec 17, 2007 12:21 PM, Raymond Kroeker <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    If your ultimate goal it to start over with a new schema; an
    option is to rename/delete the directory within which the db exists.

    Raymond Kroeker


    On Dec 17, 2007 1:42 AM, < [EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>> wrote:

        Brad Berens < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
        writes:

        > I've googled for this but all I can find is create
        statements so I'm hoping
        > someone can just give me a quick answer.  I'm trying to
        write some db
        > creation scripts.  Normally in MSSQL I would use an if
        exists from the
        > system tables to check whether or not to run a drop before
        creating the
        > table.  I found the sys.systables info about derby, but I
        can't seem to get
        > the if clause working for that.
        >
        >
        > IF EXISTS (SELECT * FROM sys.systables WHERE
        tablename='[tablename]') DROP
        > TABLE [tablename];

        IF EXISTS is a non-std extension AFAICT. You can do this
        portably by
        using DatabaseMetaData.getTables(...). It is a bit more work
        so you might
        want to wrap it in a java method.

        --
        dt




-- --------------------------------------------------------- Raymond Kroeker


Reply via email to