The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
cat /dev/null freakydancer UNIX for Dummies Questions & Answers 4 09-10-2008 03:34 PM
How to compare null and space using single if condition jayakumarrt UNIX for Dummies Questions & Answers 3 05-16-2008 05:13 AM
> /dev/null rrs Shell Programming and Scripting 2 06-19-2006 04:29 AM
Null Value Khoomfire UNIX for Advanced & Expert Users 1 04-10-2006 09:55 AM
Q1 :/dev/null Q2 -A big123456 UNIX for Advanced & Expert Users 4 11-10-2005 02:16 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-02-2006
nitin's Avatar
nitin nitin is offline
Registered User
  
 

Join Date: Aug 2001
Location: Toronto, ON
Posts: 88
compare null with non-null

I've got a very peculiar situation. I'm trying to find out if we can compare null fields with non-null. I've output csv files from SQL and Oracle. I need to compare each field from the files, and then find out any differences. The files usualy have over 500 fields, and send the resule to DBA.
Here is the intersting part, some fields may have different value, but thats ok. Like time stamps from SQL and Oracle. What I really need is to compare fields with null and non-null values. If SQL has non-null value and corresponding Oracle also has non-null then it's good. Though the values can be different some times. But a null value and same field on other file has non-null value, then I would like to extract that and report.
Any idea or suggestions? I've been looking in to diff, cmp, and even awk.

Thanks in advance

-Nitin
  #2 (permalink)  
Old 11-02-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,929
Can we see an example of the input?
  #3 (permalink)  
Old 11-02-2006
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
can you show the sample input files?
  #4 (permalink)  
Old 11-02-2006
nitin's Avatar
nitin nitin is offline
Registered User
  
 

Join Date: Aug 2001
Location: Toronto, ON
Posts: 88
Here is a sample data:

"","","SGP0000","Yes","Support","100006;","","charters","","Charters","xxx@xx.com","","9/29/2006 10:00:37 AM","9/29/2006 10:07:36 AM","10/24/2006 8:14:18 AM","Charters"

I've truncated most of the fields. So, there are some fields which may have time and date stamps etc. Lets compare the first field, it is null. Well it has "" that but for database standpoint it is null. I guess I could strip that using vi and really make it a null. The other file may have some thing like this:

"Charter group","","SGP0000","Yes","Support","100006;","","charters","","Charters","xxx@xx.com","","10/30/2006 10:00:26 AM","10/31/2006 10:11:45 AM","10/29/2006 9:18:21 AM","Charters"

So I would like to report that the first field has a diff. However, in field 13, 14, time stamps are different, I don't want that to be reported. The problem is that I can't always tell where these time fields will be. That usually depends on the DBA and developer, how they out put the data.


Thanks,
Nitin

Last edited by nitin; 11-02-2006 at 03:10 PM..
  #5 (permalink)  
Old 11-02-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,929
Quote:
Originally Posted by nitin
Lets compare the first field, it is null. Well it has "" that but for database standpoint it is null. I guess I could strip that using vi and really make it a null.
Thinking on this, but, how would you tell the difference between a NULL and an empty string?
  #6 (permalink)  
Old 11-02-2006
nitin's Avatar
nitin nitin is offline
Registered User
  
 

Join Date: Aug 2001
Location: Toronto, ON
Posts: 88
Well, a completly empty string is not possible. I mean a complete empty record. We can break the string using "awk -F," and then compare each and field. So the question is, can awk compare null and non-null?
Another thing I was gonna ask is if shell can handle dynamic arrays?

Ok.. can this be done in Perl? Any one?


-Nitin

Last edited by nitin; 11-03-2006 at 11:26 AM..
  #7 (permalink)  
Old 11-03-2006
nitin's Avatar
nitin nitin is offline
Registered User
  
 

Join Date: Aug 2001
Location: Toronto, ON
Posts: 88
Can this be done in perl? I've some exposure to Perl, any pointers....


-Nitin
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0