MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Case sensitive IF statement

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Deepthi
Beginner


Joined: 20 Aug 2005
Posts: 27
Topics: 6
Location: MN

PostPosted: Fri Jan 05, 2007 4:29 pm    Post subject: Case sensitive IF statement Reply with quote

Hi,

I have a cobol program which does a insert into 2 DB2 tables for any new record and an update in both if the record is already present in the tables.

Scenario:

Table 1 has a primary key and one particular field in Table 1 is the primary key of Table 2. Updation is based on few checks in both the tables. First the primary key is pulled from the input file and checked with the primary key of Table 1. If present in Table 1, then the Primary key of the Table 2 is pulled from Table 1 and corresponding rows from Table 1 and Table 2 is pulled for updation.

But before updation, few other fields are checked to ensure that the input record is not duplicate. Now problem arises because the other fields that are being checked are alphabets and can be either in upper or lower case.

Looks like IF statement in Cobol is case sensitive and a new record is inserted with a new primary key ( new key generated by the program itself) in Table 1 and Table 2 just because the original field was in one case(ex:upper case) and the new record to be updated has a different case.(ex:lower case) . This should not be the case, and the new details should be updated to the same record irrespective of the case. Unfortunately I cannot omit the check on these alphabet fields and hence need to find out some way of updating the same record irrespective of the case.

Could you please let me know if its feasible???
_________________
Thanks,
Deepthi.

Our lives begin to end the day we become silent about things that matter.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Jan 05, 2007 4:52 pm    Post subject: Reply with quote

Deepthi,

You can the functions UCASE or LCASE to fetch the data from table

Code:

SELECT UCASE(COL1) FROM TABLE


Now compare it with your string from the file. Also there is an intrinsic function Upper-case and lower-case in cobol also. You can even use them also.

Check this link for the explanation of the functions

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3LR10/7.1?SHELF=&DT=20020920180651&CASE=

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Deepthi
Beginner


Joined: 20 Aug 2005
Posts: 27
Topics: 6
Location: MN

PostPosted: Fri Jan 05, 2007 5:09 pm    Post subject: Reply with quote

Thanks Kolusu. My problem here is that the data can be in either way.i.e., suppose in my table there are 2 entries.

Deepthi

NIMMI

and the input file has something like this

DEEPTHI
Nimmi

Then 2 extra rows are inserted for these.
The file can also have,

deepthi
nimmi

Even in this case 2 new rows will be updated. So if I am right, then I need to check for the variables by converting the values on both the sides of the expression( file and table) to a single case(either upper or lower) and then compare.

Let me know if this will work.
_________________
Thanks,
Deepthi.

Our lives begin to end the day we become silent about things that matter.
Back to top
View user's profile Send private message
dbzTHEdinosauer
Supermod


Joined: 20 Oct 2006
Posts: 1411
Topics: 26
Location: germany

PostPosted: Fri Jan 05, 2007 5:27 pm    Post subject: Reply with quote

why don't you try it and LET US KNOW.
_________________
Dick Brenholtz
American living in Varel, Germany
Back to top
View user's profile Send private message
Deepthi
Beginner


Joined: 20 Aug 2005
Posts: 27
Topics: 6
Location: MN

PostPosted: Fri Jan 05, 2007 5:39 pm    Post subject: Reply with quote

Yeah.. In progress..
_________________
Thanks,
Deepthi.

Our lives begin to end the day we become silent about things that matter.
Back to top
View user's profile Send private message
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Fri Jan 05, 2007 5:59 pm    Post subject: Reply with quote

Deepthi,

In that case you can code in either of the following ways:

1) First fetch the data in the UCASE & compare with the file field and then fetch the data in LCASE & again compare with the file field.

2) Fetch the data in UCASE from the table and compare it with the upper case file field using the function UPPER-CASE
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group