What does this odd use of NVL in a comparison do?
The TOAD query optimizer recommended changing this test:
(NOT (sites.pay_site_flag = 'N' AND sites.purchasing_site_flag = 'Y'))
to this:
(sites.pay_site_flag <> NVL ('N', UID) OR sites.purchasing_sige_flag <> 'Y')
both sites.pay_site_flag and sites.purchasing_site_flag allow nulls, so the logical contrapositive is not valid.
Testing seems to show that the query optimizer test returns the same result as the original test, but why? I don't understand how NVL ('N', UID) can ever evaluate to anything but 'N', and how can that be useful in this comparison?
Edited by: Pete Hall on May 6, 2012 10:32 AM
Edited by: Pete Hall on May 6, 2012 11:12 AM
Edited by: Pete Hall on May 6, 2012 11:13 AM
>
That's true, and I did construct the truth table. It's equally true, if I substitute a literal 'N' in place of NVL ('N', UID), so what subtle difference does it make if the NVL function is used instead of the literal 'N'? I suppose it's possible that the TOAD optimizer just pulled that out of the air for no reason, but it seems unlikely.
>
For this example the use of NVL appears to be unnecessary. Can't tell for certain since the example that uses NVL also uses 'UID' which isn't explained anywhere; where did TOAD come up with 'UID'?
The most likely explanation is that the template that TOAD uses includes NVL to handle cases where the NVL actually is necessary. And for cases where NVL isn't needed, and doesn't alter the results, it doesn't matter if it is left in. That could allow TOAD to use one template for all use cases rather than add code to determine the use cases where NVL isn't needed.
Note that your original example
(NOT (sites.pay_site_flag = 'N' AND sites.purchasing_site_flag = 'Y'))is often misinterpreted as meaning the NEGATION of the inner AND condition but testing will show that it is not. You should always use a truth table and full testing to make sure you get exactly what you want.
Since there are two variables and they can each have three values there are nine possible combinations
with q as (SELECT 1 TEST, 'N' PFLAG, 'Y' SFLAG FROM DUAL
UNION ALL
SELECT 2 TEST, 'Y' PFLAG, 'Y' SFLAG FROM DUAL
UNION ALL
SELECT 3 TEST, NULL PFLAG, 'Y' SFLAG FROM DUAL
UNION ALL
SELECT 4 TEST, 'N' PFLAG, 'N' SFLAG FROM DUAL
UNION ALL
SELECT 5 TEST, 'Y' PFLAG, 'N' SFLAG FROM DUAL
UNION ALL
SELECT 6 TEST, NULL PFLAG, 'N' SFLAG FROM DUAL
UNION ALL
SELECT 7 TEST, 'N' PFLAG, NULL SFLAG FROM DUAL
UNION ALL
SELECT 8 TEST, 'Y' PFLAG, NULL SFLAG FROM DUAL
UNION ALL
SELECT 9 TEST, NULL PFLAG, NULL SFLAG FROM DUAL
SELECT * FROM Q WHERE
(NOT (PFLAG = 'N' AND SFLAG = 'Y'))
TEST,PFLAG,SFLAG
2,Y,Y
4,N,N
5,Y,N
6,,N
8,Y,
The inner AND condition
(PFLAG = 'N' AND SFLAG = 'Y')is TEST #1 of 9 possible combinations.
It is natural to think that if you negate that with the NOT condition that you should get records that correspond to the other 8 conditions.
But if you look at the above results you can see that you only get results matching tests 2, 4, 5, 6 and 8.
Those DO NOT include tests 3 (PFLAG IS NULL and SFLAG = 'Y'), 7 (PFLAG = 'N' but SFLAG IS NULL) or 9 (both flags are NULL).
That is the way NULLs can affect things.
If you really need the NEGATION of the inner AND condition you need to specifically code for the null value combinations.
to mean 'include all records with pay_site_flag IN (null, 'Y') OR purchasing_site_flag IN (null, 'N') but that is NOT what your condition does.
The example provides
If you did the truth table and testing
Similar Messages
-
what does this message mean: this apple ID has not yet been used in the iTunes store"? I cant connect using my iphone. But it works in iTunes on my laptop.
FAQ apple id http://support.apple.com/kb/HT5622?viewlocale=en_US
http://support.apple.com/kb/HT1311 -
What does this message mean? "itunes has detected an iPad in recovery mode. You must restore this iPad before it can be used with ITnes." How do I restore when every time I connect to my computer I get this message?
Perhaps the information in this Apple support article will help:
http://support.apple.com/kb/TS3694#error3004
Regards. -
The operation can’t be completed because the item “12b” is in use. What does this message mean. It appeared as I was attempting to clear my time machine backup?
Reboot your machine make sure Aperture doesn't start (as Lion is liable to do) and try it.
-
What does this message mean baring in mind we don't know who 'Lareib' is?: ''Lareibs phone' is now using (my number) for iMessage'
How would we users in this forum also know who Lareib is?
It means what is stated, that person is now using your number for imessage. -
Hi everyone,
My iphone and Ipad got stollen yesterday...
I registered my Ipad onto "my profile" but when I tried to register my Iphone 4 onto "My Profile" it says that the product has been registered under ANOTHER apple ID. What does this mean?! Does this mean that the thief is using my phone under a new apple ID?!
I am getitng abit paranoid because when I tried to download a new app onto my macbook pro, it says that someone had accessed my account from a new computer. I am so scared.. as I know that if they are able to access my apple ID account they can see my billing/card details. I tried to delete my billing address and card details on my apple ID account to prevent this from occuring but I can't. Please help
Many thanks,
KimYou should change your AppleID password NOW. And if it says it was registered under another AppleID, the thief has probably done it.
-
I received this error message when trying to use my time capsule. Macbook Air.sparsebundle already is use. What does this mean?
First, restart the MacBook Air and the Time Capsule. In most of the cases, this solves the problem.
If not, see > http://pondini.org/TM/C12.html -
When Installing Windows 7 using Bootcamp, I get message: "Need 64 bit Windows installation USB drive or DVD." What does this mean?
It means you need the 64 bit Version of Windows on a USB stick or DVD.
-
Given file name or path contains Unicode or double-byte characters. Retry using ASCII characters for filename and path
What does this mean? It is happening when I try to publish an OAM for Dreamweaver.
Also: How can I specify the browser in Edge Animate? It is just going wherever. Are there no Preferences for Edge Animate?
BTW. Just call it Edge. Seriously. Do you call it Illustrator Draw? Photoshop Retouching?No, my file name is mainContent.oam
My project name is mainContent.an
This error happens when I try to import into Dreamweaver. Sorry, I wasn't clear on that earlier.
I thought maybe it was because I had saved my image as a png. So re-saved as a svg, still get the error.
DO I have a setting is Dreamweaver CC that is wrong? Should I try this in Dreamweaver CS6? I might try that next.
Why is this program so difficult? I know Flash. I know After Effects. I can work the timeline part just great. It's always in the export that I have problems.
On a MacPro, 10.7.
Are you an Adobe person or just a nice helper? -
I have a Nikon D600 and D800 and I shoot everything in Raw. I use Photoshop Elements 9 for processing but I have been unable to convert any RAW files to open in PSE. Says unable to parse the file. What does this mean and how do I fix it?
Since pse 9 can only use up to camera raw 6.5 and the d600 needs at least 7.3 and the d800 needs at least 6.7, you can use the
8.6 adobe dng converter to convert those files to dng copies, which then pse 9 should open.
8.6 dng converter
windows
Adobe - Adobe Camera Raw and DNG Converter : For Windows : Adobe DNG Converter 8.6
mac
Adobe - Adobe Camera Raw and DNG Converter : For Macintosh : Adobe DNG Converter 8.6
Note:
If you have windows xp or vista or mac os x 10.6, then you'll need to use the 8.3 dng converter instead
windows
Adobe - Adobe Camera Raw and DNG Converter : For Windows : Adobe DNG Converter 8.3
mac
Adobe - Adobe Camera Raw and DNG Converter : For Macintosh : Adobe DNG Converter 8.3
how to use the dng converter
Camera Raw: How to use Adobe DNG Converter - YouTube
more info on supported cameras and camera raw plugins required
Camera Raw plug-in | Supported cameras
Camera Raw-compatible Adobe applications -
When I plug my iPod in my computer, "This iPod cannot be used because the Apple Mobile Device is not started" message pops up. What does this mean and how can I fix it?
Hello di_gitrdone,
Start with this article describing how to restart this service.
http://support.apple.com/kb/ts1567
B-rock -
When I try to sync my iPhone 4S with my computer, I get this message: "This iPhone cannot be used because the Apple mobile device service is not started" What does this mean, and how can I fix it?
means that apple mobile device service needs to be started try this article to get it turned back on
Restart apple mobile device service -
I cannot eject my new ipod classic after sync with i-tunes on my pc due, it states, to open files being used by another application. What does this mean? How can I get my ipod to eject?
If it's a one-time "glitch," you can try restarting your computer with the iPod still connected. Try ejecting again after the restart.
If the problem recurs, you may have a process running (other than iTunes) that is accessing the iPod's storage. When connected, the iPod's "disk" is like other mounted volumes. This process may be some type of utility that continously monitors your mounted volumes for security reasons, such as to prevent access by malware.
If you know of such a program that you have running in the background, there may be a setting to exclude your iPod's disk. -
I use picasa for my photos..currently there is a question mark imposed over the icon on the dock and it won't open...what does this mean?
Thanks for any help.The icon in the dock is a shortcut to the app itself.....for some reason the icon has lost contact with the app.......go to your Applications folder and drag Picasa back to the dock....a new alias (shortcut) will be created.....
-
When trying to download Itunes this pops up " key not valid for use in specified state" what does this mean and how can I fix it? I am using a pc laptop if that makes any difference.
Try reading through this thread: key not valid for use in specified state. Possible solution involves moving the RSA folder. Rather than deleting it as aniwack suggested I'd try this:
For "Key not valid for use in specified state" errors try moving the folder RSA from C:\Users\<User>\AppData\Roaming\Microsoft\Crypto\RSA to say C:\RSA (just in case there should be a need to restore it) then try installing again. This folder appears to act as a cache and should be rebuilt automatically as required.
tt2
Maybe you are looking for
-
How can I print in black when the colour cartridge is empty
Hi, I have an HP Photosmart 5510 that I use ONLY for simple black on white printing for work. I have it set to black ink only but today, a wet and cold Sunday night when I really really need the d*mned thing to work because it's month end and I have
-
iTunes stopped working so I uninstalled it. I downloaded the latest version but it won't complete installation, giving me a message that says: Service 'Apple Mobile Device' (Apple Mobile Device') failed to start. Verify that you have sufficient pr
-
XML-Cals table with aid namespaces
hi at all! i have a xml-cals table which i'd like to import in indesign including the aid-namespaces especially the tablestyle. for me, it never worked out. is it actually possible to include the aid namespaces in a xml-cals table model?! thanks in a
-
Is capturing in iMovie before transfer to FCP affect clip quality?
Capturing in iMovie detects all the start/stops. Then, importing in FCP is a fast and easy way to get all start/stops. But, does the resulting video quality just as good as if the capturing had been done entirely in FCP ? jcjber PowerBook 12" Mac O
-
Now sidebar is showing my folders multiple times!!! Please help
Hi, Well after messing around with the Downloads icons and trying to copy and paste it to another icon (see my post below) I have now found that for some strange reason all of the folders in my sidebar under 'Places' are being displayed multiple time