[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Local function corrupting numeric argument?
- Subject: Local function corrupting numeric argument?
- From: Bruce Pecci <bdpecci@AEP.COM>
- Date: Tue, 8 Jun 1999 17:07:30 -0400
Platform
OS: HP-UX 11.00 E 9000/800
DB: Oracle 8.0.4.2.1
SQR: 4.3.2
We are using SQR to extract data from a transaction table and write it to a
file. Each file has a header record, detailed transaction records, and a
trailer record that includes the line count and total dollar amounts.
The output file is read into a COBOL program that expects numerics to be
formatted with the sign leading separate. The relevant code follows:
begin-report
.
.
let $format14 = '000000000000v99'
.
!select rows from database meeting extract criteria and accumulate total
amounts
.
do Decimal-Format-Sign-Sep(#tot_resrce_amt,$format14,$tot_resrce_amt)
.
write 1 from $rec_type:2
.
.
$resource_amt:15
.
.
status=#filestat
.
.
end-report
The code for the Decimal-Format-Sign-Sep function is as follows:
begin-procedure Decimal-Format-Sign-Sep(#amt,$format,:$num)
if #amt < 0
let $sign = '-'
else
let $sign = '+'
end-if
let $num = $sign||edit(abs(#amt),$format)
end-procedure Decimal-Format-Sign-Sep
We recently began declaring the numeric fields as decimals to solve a
totaling problem and have incorporated additional debugging code. On one
of the most recents runs, the total amount written to the file in the
trailer line was formatted incorrectly. We have also seen similar problems
in another extract program with detail lines as opposed to the trailer
line. The display of the accumulated numeric value (done before the call
to the format function) showed the numeric value was correct (the same as
the total for the rows selected from the database - 3024137.36). The
display of the formatted value after the call to the function showed the
formatted value to be incorrect (+000003024136=6).
Re-running the extract eventually (usually first re-run) results in the
file containing correctly formatted results.
Any similar experiences or thoughts would be appreciated.