title: How to pass a NUMBER with decimal values as a parameter to a FUNCTION or PROCEDURE
body: <p>I'm creating some procedures and functions to make easier the tasks of inserting, deleting or updating rows.
  My question could sound silly because sure there's something I'm missing.</p>
  
  <p><strong>Any time I try to pass a decimal value as a parameter to a procedure or function I get an error.</strong></p>
  
  <blockquote>
    <p>ORA-06502: PL/SQL: numeric or value error: character to number conversion error</p>
  </blockquote>
  
  <p>The next code isn't functional but a way to show the problem.</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION test1(num1 NUMBER)
      RETURN NUMBER IS
          BEGIN
          RETURN num1;
          END;
  /
  SET SERVEROUTPUT ON;
  DECLARE
      numVar NUMBER;
  BEGIN
  numVar:= 2.1;
  DBMS_OUTPUT.PUT_LINE('Raw Number: '||numVar);
  
                        /***********Calling test1*************/
              DBMS_OUTPUT.PUT_LINE('Function Number: '|| test1(2.1));
  
  END;
  /
  </code></pre>
  
  <p>Some of the output is in spanish but most of it is in english.</p>
  
  <pre><code>Function TEST1 compilado
  
  Raw Number: 2,1
  
  
  Error que empieza en la línea: 8 del comando :
  DECLARE
      numVar NUMBER;
  BEGIN
  numVar:= 2.1;
  DBMS_OUTPUT.PUT_LINE('Raw Number: '||numVar);
      DBMS_OUTPUT.PUT_LINE('Function Number: '|| test1(2.1));
  
  END;
  Informe de error -
  ORA-06502: PL/SQL: numeric or value error: character to number conversion error
  ORA-06512: at line 6
  06502. 00000 -  "PL/SQL: numeric or value error%s"
  *Cause:    An arithmetic, numeric, string, conversion, or constraint error
             occurred. For example, this error occurs if an attempt is made to
             assign the value NULL to a variable declared NOT NULL, or if an
             attempt is made to assign an integer larger than 99 to a variable
             declared NUMBER(2).
  *Action:   Change the data, how it is manipulated, or how it is declared so
             that values do not violate constraints.
  </code></pre>
  
  <p><strong>When I call the function, without decimal parameters, I get no troubles</strong>.</p>
  
  <pre><code>          /***********Calling test1*************/
  DBMS_OUTPUT.PUT_LINE('Function Number: '|| test1(2));
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>Function TEST1 compilado
  
  Raw Number: 2,1
  Function Number: 2
  </code></pre>
  
  <p><strong>If I pass a variable instead of a raw decimal number, I don't get any trouble either</strong> and I actually can use a decimal number but it makes less sense for me creating a procedure to insert data that requires defining a variable to pass it as a parameter</p>
  
  <pre><code>         /***********Calling test1*************/
  DBMS_OUTPUT.PUT_LINE('Function Number: '|| test1(numVar));
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>Function TEST1 compilado
  Raw Number: 2,1
  Function Number: 2,1
  </code></pre>
  
  <p>I would like to understand why I can´t pass a raw decimal number as a parameter, maybe I don't understand well the way Oracle casts data before introducing it as a parameter.</p>