Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6376717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:46:50+00:00 2026-05-25T01:46:50+00:00

Hi there I am looking for common mistakes pl/sql programmers make when they program

  • 0

Hi there I am looking for common mistakes pl/sql programmers make when they program applications which deals with a lot of monetary computations. (Discounts, tax, rates, etc.)
I had been using java and hibernate for monetary computations for as far as I can remember java has a set of rules and best practices like BigDecimal to preserve precision and etc. Right now Im trying to improve my pl/sql skills in dealing with financial modules thats why I want to know this gotchas and avoid them. Also are there any existing mantra or pl/sql best practice for this?
Thanks in advance guys.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:46:51+00:00Added an answer on May 25, 2026 at 1:46 am

    Using this example:

    create table t_val
      (id number(10,0),
      value number(5,2));
    
    declare
      v_dummy number;
    begin
      delete from t_val;
      for i in 9 .. 20 loop
        insert into t_val values (i, 1/i);
        select count(*)
        into v_dummy 
        from t_val 
        where value = 1/i;
        dbms_output.put_line(to_char(i,'00')||':'||v_dummy||':'||
                  to_char(1/i,'000.999999'));  
      end loop;
      --
    end;
    /
    
    select id, value from t_val order by 1;
    

    You can see that the code inserts, for example, 0.11111 which is implicitly rounded to 0.11
    When the code immediately tries to count the values for 0.11111 it fails to find any matches.

    Similarly the values for (1/14) and (1/15) both get rounded to 0.07.

    This isn’t a problem specific to PL/SQL, and I’ve seen similar issues in Java and PHP code when the value in the ‘client’ is rounded when it makes it into the database. PL/SQL does offer a better solution though, as you can declare a variable of the type of a specific table/column, and this binding is maintained even if the column is changed.

    declare
      v_value  t_val.value%type;
      v_dummy number;
    begin
      delete from t_val;
      for i in 9 .. 20 loop
        v_value := 1/i;
        insert into t_val values (i, v_value);
        select count(*)
        into v_dummy 
        from t_val 
        where value = v_value;
        dbms_output.put_line(to_char(i,'00')||':'||v_dummy||':'||
                to_char(1/i,'000.999999')||':'||to_char(v_value,'000.999999'));  
      end loop;
      --
    end;
    /
    

    So best practice is, when dealing with an SQL statement, use bind variables that are anchored to the type (including length/scale/precision) of the underlying table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project where there are multiple applications that have some common configuration
my question is: is there a good (common) algorithm to create numbers, which match
Looking to see if there's an existing method or application to increase display size
I am looking to see if there is an open source/free project that provides
Looking at the processmodel element in the Web.Config there are two attributes. maxWorkerThreads=25 maxIoThreads=25
Looking for a good rss/feed reader for windows or if there are any good
Is there a better solution to the problem of looking up multiple known IDs
Is there a way to keep a window inactive looking, even if it contains
I'm looking for a standard dual-map structure - is there one implemented in std/boost/another
I am looking at some PHP code where there are translation strings. For French

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.