Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Interfaces Jdbc > Re: Issue with ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 1908 of 2010
Post > Topic >>

Re: Issue with NULL varchars

by craig@[EMAIL PROTECTED] (Craig Ringer) Mar 25, 2008 at 07:25 PM

antony baxter wrote:

>       // Retrieve that Locale's ID by its Data:
>       p = c.prepareStatement("SELECT COUNT(*) FROM testing WHERE variant
= ?");

To avoid conditionally rewriting your query to use IS NULL / IS NOT NULL
instead of equality, you could also use IS DISTINCT FROM. Instead of:

	where variant = ?

try using:

	where not (variant is distinct from ?)


craig=# \pset null '<null>'
Null display is "<null>".

craig=# select null = null;
 ?column?
----------
 <null>
(1 row)

craig=# select not( null is distinct from null );
 ?column?
----------
 t
(1 row)

craig=# select not (1 is distinct from 1);
 ?column?
----------
 t
(1 row)

craig=# select not (1 is distinct from 2);
 ?column?
----------
 f
(1 row)

craig=# select not (null is distinct from 2);
 ?column?
----------
 f
(1 row)


See:

http://www.postgresql.org/docs/8.3/static/functions-comparison.html

--
Craig Ringer

-- 
Sent via pgsql-jdbc mailing list (pgsql-jdbc@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
 




 4 Posts in Topic:
Issue with NULL varchars
antony.baxter@[EMAIL PROT  2008-03-25 15:19:11 
Re: Issue with NULL varchars
craig@[EMAIL PROTECTED]   2008-03-25 19:00:40 
Re: Issue with NULL varchars
craig@[EMAIL PROTECTED]   2008-03-25 19:25:59 
Re: Issue with NULL varchars
laurenz.albe@[EMAIL PROTE  2008-03-25 15:46:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Aug 21 22:44:44 CDT 2008.