Statement « derby « Java Database Q&A

1. conditional statements in derby

It looks like derby doesn't support conditional statements [IF]. How do we write

if exists (select 1 from customers where name='somename') 
    update customers ...

2. Is NULL not allowed is SQL delete statement (for Derby)?

Hello Does anyone know why the following query fails in Derby?

delete from MyTable
((null = null) or (col1 = null)) OR
((102 = null) or (col2 = 102)))
I get the following error:
Error: Syntax error: ...

3. Error in SQL statement for Derby database

I'm havin an error while trying to execute this piece of sql code... The error I'm getting is:

Encountered "(" at line 1, column 45
The piece of code is:

4. how to use 'BETWEEN' condetion two times in one sql statement for same column or diffrent columns

this is sql statement give only one value

SELECT count(pn1) FROM pledges
WHERE date1
BETWEEN '2011-05-05' AND '2011-06-06'
i want use "between" more than one time for same column or for different columns in same ...

5. How to optimize this sql delete statement

I have 3 tables, the first one, table1, has as primary key the id column, the second table (table2) has a column table1_id that refer as foreign key to the, ...

6. Can I close statements in a transaction before committing it in Derby (JDBC)?

Basically I have (ignoring exception handling, etc.):


Statement statement1 = connection.createStatement();

Statement statement2 = connection.createStatement();

If I understand correctly it shouldn't have any impact because all it really does is free the resources for ...

7. I Need Help With a Derby SQL Join Statement

I have the following Derby SQL statement which is embedded in my Java code and is executed via JDBC. It works, but it gives me all service dates. What I need is to refine this query so that it only gives me a tuple with the most-recent service-date. Can someone help me with this? Thank you for the time to read ...