Solved

Oracle query  - Blank in field

Posted on 2014-11-12
5
569 Views
Last Modified: 2014-11-12
In my data set I have have a column that has 'Blanks' in it.  In other words there is nothing in the field.  What is the Oracle SQL query syntax to find only the records with the blank fields or the fields where there is nothing in the field.  thanks.
0
Comment
Question by:donnie91910
5 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 300 total points
ID: 40438189
To find 'blanks':
where trim(column_name) is null

To find 'not blanks':
where trim(column_name) is not null

The trim may be optional depending on the data type and if the application allows spaces.

CHAR data types pad with spaces where VARCHAR2 does not.
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 200 total points
ID: 40438251
I wouldn't use TRIM, because that will cause fields with nothingbut space charactes to be treated as nulls

that is the intent in slightwv's post, but likely not what you're looking for.
0
 
LVL 74

Assisted Solution

by:sdstuber
sdstuber earned 200 total points
ID: 40438259
if you are looking for NULL values (nothing) as well as non-visible data (spaces, line feeds, carriage returns, etc) then you'll need more than just trim.

if this is the case then how exhaustive of a search would you want?

you can use regular expressions to look for common white-space but still not all non-visible characters.
0
 

Author Closing Comment

by:donnie91910
ID: 40438406
I used the 'Dump' function to find out what was really in the blank field and it is a hidden 'Null' value.   so I used slightwv's post and it seems to have worked.  Thanks.
0
 
LVL 13

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 40438697
if you are looking for NULL values (nothing) as well as non-visible data (spaces, line feeds, carriage returns, etc) then you'll need more than just trim.
AddOn: in these cases the LNNVL built-in function becomes quite handy (which itself is used in the WHERE clause as a true/false condition, that returns all rows matching this condition plus the "NULLs"...
Maybe you give it a shot, next time ;-)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
pivot rows to columns 1 44
oracle collections 2 27
How to find the cost of a stored procedure in Oracle and optimize it ?? 2 35
Oracle Nested table uses ? 2 44
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to recover a database from a user managed backup

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question