Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 21st, 2004, 08:03 PM
bullitenergy bullitenergy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 bullitenergy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool PreparedStatement with "? IS NULL"

Hello everyone!

Sorry if this question has already been asked... I could not find any answers in Google. This code breaks on the prepareStatement, probably because Jaybird or Firebird is unable to determine the type of the third parameter:

Code:
String DELETE_A =
	"DELETE FROM \"A\" WHERE \"id\" = ? AND"
	+ "(\"a\" = ? OR (\"a\" IS NULL AND ? IS NULL))";
PreparedStatement ps;
ps = connection.prepareStatement(DELETE_A); 
int index=1;
ps.setInt(index++, value.getId());
if(value.getA() == null) {
	ps.setNull(index++, Types.INTEGER);
	ps.setNull(index++, Types.INTEGER);
} else {
	ps.setInt(index++, value.getA().intValue());
	ps.setInt(index++, value.getA().intValue());
}
ps.executeUpdate();


Is this expected behavior? (This style of querying works in MS-SQL)
Is there some way to achieve the same effect?
I don't want to use 2 different SQL statements, because I have lots of more columns that can have NULL values.

Thank you for your answers!
Best regards!
Bullit Energy

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > PreparedStatement with "? IS NULL"


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway