db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernt M. Johnsen" <Bernt.John...@Sun.COM>
Subject Re: DROP IF NOT EXISTS
Date Thu, 14 Sep 2006 23:55:30 GMT
yves pielusenet wrote:
> I wonder if there is something similare like :
> 'drop index id_index if not exists' ?
> I want to put a condition on a drop statement but it fails.
> how can I do ?
> 

You could do it like this:

try {
   stmt.executeUpdate("drop index id_index");
} catch (SQLException e) {
    if (!e.getSQLState().equals("xxxxx") {
        throw e;
    }
}


where xxxxx is the SQL State you get when trying to delete a
non-existing index.

> thanks ,
> 


-- 
Bernt Marius Johnsen, Database Technology Group,
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway

Mime
View raw message