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.
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.