Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle PL/SQL block comparing values to 4 decimal places

xarg-XrcAug 1 2014 — edited Aug 1 2014

Hi,

I am using Oracle Database 11GR2. I have written a simple PL/SQL block that is validating as false. Basically trying to ensure that FX calculation is correct to 4 decimal places.

So example,

1.000 vs 1.0000 should evaluate to false

1.0000 vs 1.0000 should evaluate to true

For this purpose, I am doing string comparison. I am not sure why the below code is evaluating to "false", or what is the proper way to do such comparison in PL/SQL?

declare

l_fx_rate varchar2(100) := to_char(1, '9999.9999');

l_aud_usd varchar2(100) := to_char((23/23),'999999.9999');

BEGIN

htp.p(l_fx_rate);

htp.p(l_aud_usd);

  IF l_fx_rate = l_aud_usd

  THEN

htp.p('true');

  else

htp.p('false');

  END IF;

END;

Thanks.

This post has been answered by unknown-7404 on Aug 1 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 29 2014
Added on Aug 1 2014
2 comments
1,265 views