Matching Column names



IBM's Command List programming language & Restructured Extended Executor

Matching Column names

Postby Arunz » Tue Jun 23, 2015 4:43 pm

Hi,

Is there any way to match the column names between two tables.

EMP:
EMP_NUM
EMP_NAME
EMP_DEPT
EMP_SALARY

SALARY
EMP_NUM
EMP_DEPT
EMP_SALARY

My Requirement

In both the table EMP_NUM, EMP_DEPT, EMP_SALARY got matched. I need to write this in the output. :? :?

Output

EMP_NUM = EMP_NUM
EMP_DEPT = EMP_DEPT
EMP_SALARY = EMP_SALARY

Thanks in advance
Arunz
 
Posts: 6
Joined: Tue Jun 16, 2015 6:56 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Matching Column names

Postby enrico-sorichetti » Tue Jun 23, 2015 6:01 pm

how does the question relate to REXX ?
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Matching Column names

Postby Arunz » Tue Jun 23, 2015 8:00 pm

Hi Enrico,

This need to be developed in Rexx for some tool creation.
Arunz
 
Posts: 6
Joined: Tue Jun 16, 2015 6:56 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Matching Column names

Postby enrico-sorichetti » Tue Jun 23, 2015 8:17 pm

still Your explanation of the requirement is clear as mud!

the logical problem is to find out the common symbols/token/words/calltheminanywayYouwant in two lists .

brute force

ls1 = "EMP_NUM EMP_NAME EMP_DEPT EMP_SALARY ONLY_IN_LIST1"

ls2 = "EMP_NUM EMP_DEPT EMP_SALARY ONLY_IN_LIST2"

/*  brute force
*/
do  i = 1 to words(ls1)
    do  j = 1 to words(ls2)
        if  word(ls1, i) = word(ls2, j) then ,
            say "==>" word(ls1, i) "=" word(ls1, i)
    end
end



to get
==> EMP_NUM = EMP_NUM
==> EMP_DEPT = EMP_DEPT
==> EMP_SALARY = EMP_SALARY



frankly it is pretty sad that a tool developer could not come up with a solution
to such a simple matching problem

a more sophisticated solution would have been to sort the two list
and do a two sequences match
but the overhead of sorting would have been probably been higher
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Matching Column names

Postby enrico-sorichetti » Tue Jun 23, 2015 8:39 pm

a slightly less brutal way

/*  less brute force
*/
do  i = 1 to words(ls1)
    if  wordpos(word(ls1, i), ls2) > 0 then ,
        say "==>" word(ls1, i) "=" word(ls1, i)
end
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Matching Column names

Postby NicC » Tue Jun 23, 2015 9:33 pm

And to get the column names use the DCLGENs for the tables.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Matching Column names

Postby Arunz » Wed Jun 24, 2015 12:22 pm

Got it Enrico.. I am sorry for the bad explanation about my requirement...
Arunz
 
Posts: 6
Joined: Tue Jun 16, 2015 6:56 pm
Has thanked: 1 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post