[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
RE: [sqr-users] Illogical if statement
- Subject: RE: [sqr-users] Illogical if statement
- From: "Thompson, Betty P" <thompsob@uww.edu>
- Date: Fri, 17 Nov 2006 13:03:08 -0600
- Delivery-date: Fri, 17 Nov 2006 14:05:41 -0500
- List-id: "This list is for discussion about the SQR database reportinglanguage from Hyperion Solutions." <sqr-users.sqrug.org>
- Thread-index: AccKeVcYEoc0/+3rR6ar5PgU080oWwAASooQ
- Thread-topic: [sqr-users] Illogical if statement
Hi, Cathy,
I was pulling my hair out years ago over this same problem. I no longer
recall the full explanation of what was happening, but it had to do with
the precision not being consistent (not even from one run to the next, I
think).
Here's what I learned to add to the setup section which eliminated the
problem, and it's now my standard to use it in every SQR I write:
DECLARE-VARIABLE
DEFAULT-NUMERIC=DECIMAL(18)
END-DECLARE
End-SETUP
I'd like to know if you try this and still have the problem.
--Betty
++++++++++++++++++++++++++++++++++++++++++
Betty Thompson
Applications & Systems Development (AIS) - Specialist
Instructional, Communication & Information Technology (iCIT)
University of Wisconsin - Whitewater
800 W. Main Street -- Room L-1015
Whitewater, WI 53190-1790
262-472-5532
thompsob@uww.edu
++++++++++++++++++++++++++++++++++++++++++
-----Original Message-----
From: sqr-users-bounces+thompsob=uww.edu@sqrug.org
[mailto:sqr-users-bounces+thompsob=uww.edu@sqrug.org] On Behalf Of
Stratman, Cathy
Sent: Friday, November 17, 2006 12:49 PM
To: 'the dragon'
Cc: sqr-users@sqrug.org
Subject: RE: [sqr-users] Illogical if statement
Clark - Well it works but how dumb is that code?! I thought programming
was supposed to use a little logic!
Thanks,
Cathy
-----Original Message-----
From: the dragon [mailto:ceprn@hotmail.com]
Sent: Friday, November 17, 2006 12:35 PM
To: sqr-users@sqrug.org
Cc: CSTRATMAN@crown-chicago.com
Subject: RE: [sqr-users] Illogical if statement
Cathy - I know SQR *used to* have this problem where the numbers didn't
match up, and it was somhow related to a number like about 32 decimal
places
out. Given this *shouldn't* be happening, but it was. If you want to
make certain the logic works if the numbers are really the same, convert
them into characters with the same edit mask in the compare. This will
add unnecessary overhead, but it your case I don't think you'll be able
to get around it.
let us know if this helps any.
peace,
clark 'the dragon' willis
PSA: Salary <> Slavery. If you earn a salary, your employer is renting
your services for 40 hours a week, not purchasing your soul. Your time
is the only real finite asset that you have, and once used it can never
be recovered, so don't waste it by giving it away.
I work to live; I don't live to work.
"Time is the coin of your life. It is the only coin you have, and only
you can determine how it will be spent. Be careful lest you let other
people spend it for you."
Carl Sandburg
(1878 - 1967)
It is impossible to defeat an ignorant man in argument.
William G. McAdoo
----Original Message Follows----
Oh great guru's of sqr, I'm tired of beating my head against a wall and
invite you to please help. I have a very simple, very dumb little
program that reads a csv file, does some validation, inserts valid data
into PS_FLAT_RATE_TBL and reports on invalid data.
The first thing that I check is to see if the sum of the employer rate
and the employee rate actually equal the total rate. The if statement I
am using has a mind of it's own and I can't seem to figure out what I
may be doing wrong.
We are on PT 8.22.10, HRMS 8.3sp1, SQL server 2000.
The following code is the reading the input file and validating the
coverage rate. I have included several display statements and what is
being displayed in the log. The numbers look like they are equal to me
but the program doesn't seem to think so. If I insert these three rows
via the panels, everything works fine. Using the program, only the
first record is inserted properly, the other two error out.
Suggestions????
Begin-Procedure Read-Input-File
let #Inserts = 0
let #Tot-Recs = 0
let #row = 5
let #err_row = 50
While 1 = 1
Read 1 Into $Input:200
Unstring $Input By ',' Into
$Flat_rate_id
$Effdt
$Emplr_covrg_rate
$Empl_covrg_rate
$Total_covrg
let $Prov_covrg_rate = $Total_covrg
If #end-file = 1
Break
End-If
let $ValidFlag1 = 'Y'
let $ValidFlag = 'Y'
Do Validate-Covrg-Rate
If $ValidFlag1 = 'N'
let $Error_msg = 'Sum of Employer Coverage Rate and Employee
Coverage Rate is not equal to Total Coverage Rate'
Do Report-Error
Else
Do Validate-Date
If $ValidFlag = 'N'
let $Error_msg = 'Date is not in the Right Format'
Do Report-Error
End-If
If $Validflag = 'Y'
let $flag = 'Y'
let #row_found = 0
Do get-fields
if #row_found != 1
let $Error_msg = 'There is no prior data for this
FLAT_RATE_ID'
let $flag = 'N'
Do Report-Error
end-if
If $flag = 'Y'
Do Insert-Flat-Rate-Table
End-if
End-If
End-If
End-While
.
.
.
end-procedure
Begin-Procedure Validate-Covrg-Rate
let #num_Emplr_covrg_rate = 0
let #num_Empl_covrg_rate = 0
let #num_Total_covrg = 0
let #total = 0
let #num_Emplr_covrg_rate = to_number($Emplr_covrg_rate)
let #num_Empl_covrg_rate = to_number($Empl_covrg_rate)
let #num_Total_covrg = to_number($Total_covrg)
let #total = #num_Emplr_covrg_rate + #num_Empl_covrg_rate
DISPLAY '$ValidFlag1 COMING IN TO PROCEDURE:' NOLINE
DISPLAY $ValidFlag1
display '#total:' noline
display #total noline
display 'X'
display '#num_Total_covrg:' noline
display #num_Total_covrg noline
display 'X'
if #total = #num_Total_covrg
!do nothing
else
let $ValidFlag1 = 'N'
End-If
DISPLAY '$ValidFlag1 COMING OUT OF PROCEDURE: ' NOLINE
DISPLAY $ValidFlag1
End-Procedure
Log file:
$ValidFlag1 COMING IN TO PROCEDURE:Y
#total:1574.020000X
#num_Total_covrg:1574.020000X
$ValidFlag1 COMING OUT OF PROCEDURE: Y
$ValidFlag1 COMING IN TO PROCEDURE:Y
#total:2422.570000X
#num_Total_covrg:2422.570000X
$ValidFlag1 COMING OUT OF PROCEDURE: N
$ValidFlag1 COMING IN TO PROCEDURE:Y
#total:304.160000X
#num_Total_covrg:304.160000X
$ValidFlag1 COMING OUT OF PROCEDURE: N
_________________________________________________________________
Get FREE company branded e-mail accounts and business Web site from
Microsoft Office Live
http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users