Hello, you are not logged in.  Login or sign up
Community >> Quest Experts' Blogs
 Search
Single quotes and CLOBs in 10.2.0.3
 
Location: Blogs Steven Feuerstein's Blog    
 StevenFeuersteinTW Wednesday, December 19, 2007 5:41 PM

I usually write about best practice principles and general issues.

Today I thought I would share a bit of my pain with you on a very specific topic: single quotes and CLOBs, and specifically on Oracle 10.2.0.3.

I figure that I lost an hour or two of my life to this one, and would like to pass on the warning to you all.

In Quest Code Tester, we store in put and expected values that you provide in your test definition as CLOBs. We maintain "internal" and "external" values – the external value is a string that is ready to be concatenated directly into the generated test code.

Thus, if the input value is one single quote, we save it in the external_value column as

''''

That is, four single quotes – which evaluate to a single quote. Got it so far, right?

When we generate test code, those four single quotes need to be treated as NULL, so we wrote this function to tell us if a CLOB is really to be considered as NULL:

 

And it worked just fine in all sorts of situations, but then we got a support issue logged by a user. He was getting the wrong test results: Quest Code Tester was showing that he had provided a NULL value when he had instead entered the single quote character!

What the heck was going on?

Well, it took quite a while to narrow things down. The error did not occur on Oracle9i, Oracle11g, on Oracle 10g 10.2.0.1. It only seems to happen on 10.2.0.3.

And after a while of testing and experimenting, I discovered that on this version of Oracle, you get some very strange behavior when performing a test like:

value_in = ''''''

It's easy to see; you can try it yourself. Copy and paste the following block of code into Toad and run it:

You should see this output:

FOUR QUOTES
FOUR QUOTES

And that is wrong, so wrong. It looks like it doesn't matter how many single quote characters you put inside two single quotes; that equality check will always return TRUE.

Ugh.

So I built the following workaround:

And that seems to work reasonably well – though I would much rather NOT have to do this.

Now you know and hopefully you will never run into this issue – but if you do, you have been warned!

Copyright ©2007 Quest Software Inc.
Permalink |  Trackback

Comments (3)   Add Comment
By RussW on Thursday, December 20, 2007 4:28 PM
Is it just me, or is there some reason that copy and paste won't work on this code sample?

By RussW on Thursday, December 20, 2007 4:30 PM
Ah...it's actually a png file.

By zauberberg on Thursday, January 24, 2008 10:01 AM
the latest patch mus have fixed this because I get the expected answer from the original stored proc.
four quotes
not four quotes


Comment:
Add Comment   Cancel 
Search Blog Entries
 
Copyright 2008 by Quest Software  | Terms Of Use | Privacy Statement | Contact Us