devxlogo

Avoid Java Null Pointer Exceptions with SQL-J

Avoid Java Null Pointer Exceptions with SQL-J

Direct access of a NULL in a column does not cause any problems in SQL-J. If you use that value as a parameter in a Java method or as a method receiver, you will get a Java Null Pointer Exception. The conditional expression is useful for avoiding Java-caused null pointer exceptions:

 SELECT empSurname.toUpperCase()FROM Actors-- If empSurname has any nulls, you'll get a null pointer exception SELECT (empSurname IS NULL) ?(empFirstname||'*') :empSurname.toUpperCase()FROM Actors 

devx-admin

Share the Post: