Mike Matrigali wrote:
tbrazao wrote:
Hi,
i'm a new user of derby.
My question is about the ideia of sql : "drop table if exists ...".
I read some explanations in this forum, but i didn´t find answers to
work in
sql line commander.
I know that derby doens't support this job, but i want to ensure that
if an
table exists it is dropped. So i think we can use something like...
select count(*) from SYS.SYSTABLES where TABLENAME = tableName,
where tableName could be an arg for an procedure,
but i don´t know how to relate this with an drop call. It was simple
if we
have one "if" clause.
The problem is that i need to do this without java sintax, i know
that seems
strange, but life it's strange and nobody cares about it...
If anyone could help, Thanks!
Why not just drop the table and let derby return an error if it did
not exist?
And sorry my English!
You will need to use the Derby API (Java) to perform conditional
processing like you describe. The java code can be hidden from the
end-users and invoked using IJ by storing it in the database and
defining it as a procedure. The procedure would take the table name,
drop the table - it would catch and discard the exception thrown if the
table does not exist.
Example Java code that does something similar to this (checks for
existance based on a select statement) can be found in the 10.2 Derby
distribution in the method 'wwdChk4Table' defined in 'WwdUtils.java' in
the folder: <DERBY_INSTALL>\demo\programs\workingwithderby.
HTH