Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare files?

Status
Not open for further replies.

trdin

Programmer
Jan 19, 2004
13
VE
Hey guys,

I have a table that stores files in a Clob field, is there any way i can for example get two files to compare them and display the lines where they are different?, something similar to the Diff command in Unix but in 4GL.

Thanks a lot

trdin
 
Hey guys, forget the previous post, i have already loaded the data from the files to 4GL, now i need to compare them line by line and display both lines from both files if they differ in so much as a character, i have been trying a lot of stuff but i don't know if i am doing it right, here's an example of the code. So far i only get two lines on return from two very different files.



LOAD FROM 'file' INSERT INTO t_data
LOAD FROM 'file2' INSERT INTO t_data1
DECLARE cur1 CURSOR FOR select * from t_data
DECLARE cur2 CURSOR FOR select * from t_data1

let cntr=0
open cur1
open cur2
while(1)
fetch cur1 into m_dat
fetch cur2 into m_dat1
if status=notfound then
exit while
end if
let cntr=cntr+1
let arr_cols[cntr].mcol=m_dat clipped
let arr_cols1[cntr].mcol=m_dat1 clipped

IF arr_cols[cntr].mcol NOT LIKE arr_cols1[cntr].mcol THEN

display cntr,m_dat
display cntr,m_dat1

ELSE continue while
end if
end while

This is part of the code where i'm suppose to do the compare but it's too simple i think, i'm missing something very important but i cannot see what.


Thanks in advance.

trdin.
 
Hi:

First, in this line, I think you should use != in a strind comparision instead of NOT LIKE:

IF arr_cols[cntr].mcol NOT LIKE arr_cols1[cntr].mcol THEN

should be:

IF arr_cols[cntr].mcol != arr_cols1[cntr].mcol THEN

Second, when you load data into the temporary tables, you can't guarantee it's going to be selected the same way. I'd order by one of the columns in the temp tables.

Third, the 'ELSE continue while' isn't really needed.

Regards,

Ed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top