Passionate Development From Journeyman to Master

CFQuery LIKE on NULL values

I’ve got this query of query: [code=”sql”] SELECT * FROM qSectionArticles WHERE displays LIKE ‘%publications%’ [/code]

This code was returning a CF error:

The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.

Null Pointers are another name for undefined values.

....

Stack Trace

java.lang.NullPointerException
	at org.apache.oro.text.regex.Perl5Matcher.matches(Unknown Source)
	at coldfusion.sql.imq.rttExprCondLike.evaluate(rttExprCond.java:543)
	at coldfusion.sql.imq.rttExprCondTest.evaluate(rttExprCond.java:273)
	at coldfusion.sql.imq.rttSelectExprSpec.evaluateWhere(rttSelectExprSpec.java:245)
	at coldfusion.sql.imq.rttSelectExprSpec.evaluate(rttSelectExprSpec.java:184)
	at coldfusion.sql.imq.rttSelectStmt.evaluate(rttSelectStmt.java:61)
	at coldfusion.sql.imq.jdbcStatement.fetchResult(jdbcStatement.java:539)
	at coldfusion.sql.imq.jdbcStatement.execute(jdbcStatement.java:131)
	at coldfusion.sql.imq.jdbcPreparedStatement.execute(jdbcPreparedStatement.java:96)
	at coldfusion.sql.Executive.executeQuery(Executive.java:1202)
	at coldfusion.sql.SqlImpl.execute(SqlImpl.java:329)
	at coldfusion.tagext.sql.QueryTag.executeQuery(QueryTag.java:831)
	at coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:521)
...

It turns out the problem was that I the column that I am querying for (displays column) has a NULL value assigned to it, luckily there are only 5 or so entries in this table, so I can just quickly fill them with values and change the field to not allowing NULL as well as giving it a default value (the database is SQL Server 2000 by the way)

coldfusion