Solved

Oracle query  - Blank in field

Posted on 2014-11-12
5
558 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 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Retreiving column names in Windows but not in Unix 11 58
PL/SQL Two changes 7 34
SQL Workhours Count beetween Workhours 3 26
join a table with user_tab_columns in oracle 3 48
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to take different types of Oracle backups using RMAN.

856 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