|
From: Jim Essinger <dilbernator@xxxxxxxxx>long,
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 03/16/2010 12:34 PM
Subject: Sql update of a file based on the same file
Sent by: midrange-l-bounces@xxxxxxxxxxxx
All,
I have a file that contains 1 field called LINE that is 186 characters
and contains spool data. In about 900 cases, (of 25,000+ lines) oneposition
particular line gets split into 2 lines like;
2 1234.56-
0 798.00
I need to have them combined into one line like:
2 1234.56- 798.00
The data is all numbers, edited. The 2nd line is always a zero in
4 of the line, and one RRN later in the file. What I want to do is toupdate
the first line with both parts of the data, and then I will remove theone
"Zero" record.
I have created an SQL statement that will combine the two pieces into
line that is correct. Now I need to use that statement to update thelocates
correct records. That is where my mind has failed me.
The select statement that puts together the 2 lines is;
select rrn(a), substr(a.LINE,1,String_str - 1) concat
substr(c.LINE,string_str)
from MyFile a join (
select rrn(b) - 1 as Join_rrn ,
locate('Z',
substr(b.LINE,1,4) concat
translate(substr(b.line,5,length(b.LINE) -1),'Z','.0123456789-','Z'))
as String_Str,
b.LINE
from MyFile b
where line like ' 0%' ) c on rrn(a) = join_rrn
The subselect translates all editing and numbers to a "Z" and then
the first occurrence of "Z" to find the starting of the string on thesecond
line. The file is joined to itself based on RRN and the line containinga
zero in position 4.line
1st - Is there an easier way I could code this statement?
2nd - How can I use this statement in an UPDATE to change the correct
using RRN as the key?list
Thanks!
Jim
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.