Re: Error, numeric or value error: character to number conversion error

Can someone please please tell me why I'm getting this error and what I'm doing wrong? It looks like a simple error, "numeric or value error: character to number conversion error".
My code is as follows:
string connectionString = WebConfigurationManager.ConnectionStrings["DEMO_TEST"].ConnectionString;
OracleConnection con = new OracleConnection(connectionString);
OracleCommand cmd = new OracleCommand("DEMO.PKG_LOCATION_TYPE.INS", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new OracleParameter("@P_DESCRIPTION", OracleDbType.Varchar2, 60));
cmd.Parameters["@P_DESCRIPTION"].Value = "Test_Description";
cmd.Parameters.Add(new OracleParameter("@P_NAME", OracleDbType.Varchar2, 6));
cmd.Parameters["@P_NAME"].Value = "Test_Name";
cmd.Parameters.Add(new OracleParameter("@P_LOCATION_TYPE_CD", OracleDbType.Decimal, 4));
cmd.Parameters["@P_LOCATION_TYPE_CD"].Direction = ParameterDirection.InputOutput;
con.Open();
try
cmd.ExecuteNonQuery();
catch
//In case of an error
finally
con.Close();
con.Dispose();
And I recieve the following error block:
Oracle.DataAccess.Client.OracleException was unhandled by user code
Message="ORA-06502: PL/SQL: numeric or value error: character to number conversion error\nORA-06512: at line 1"
Source="Oracle Data Provider for .NET"
DataSource="demotest"
Number=6502
Procedure="DEMO.PKG_LOCATION_TYPE.INS"
StackTrace:
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src)
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
at System.Web.UI.WebControls.Wizard.OnFinishButtonClick(WizardNavigationEventArgs e)
at System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e)
at System.Web.UI.WebControls.Wizard.WizardChildTable.OnBubbleEvent(Object source, EventArgs args)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
********************************************************

Are the parameters in your procedure in the same order as they are created in this code? Oracle command works by position unless you change it to be BindByName.
Failing that you seem to have defined a parameter (P_NAME) to have a length of 6, and are then setting it's value to a string with a length of 9.
Also the in/output parameter is defined as type decimal. Is this correct? It is defined as InputOutput but you don't assign it any value.
If these suggestions don't help then perhaps if you post the stored procedure you might get some more ideas.
HTH
Lyndon

Similar Messages

  • Error ORA-06502, numeric or value error character to number conversion

    I have been trying to create an email including data from a table as part of the body. Whenever I try to send it, I get an error ORA-06502, numeric or value error, character to number conversion. If I take out the part referencing the table, the email will go without error, but if I put it back in I get the error.
    There is the code:
    DECLARE
    v_email_body CLOB;
    v_from_email_address VARCHAR2(100) := v('APP_USER');
    v_id NUMBER;
    BEGIN
    v_email_body := 'Please pay the attached invoice from FY '||:P14_FY||' funds
    Date: '||:P14_PURCHASE_DATE||'
    Vendor: '||:P14_VENDOR||'
    Invoice Number: '||:P14_INVOICE||'
    Invoice Date: '||:P14_INVOICE_DT||'
    Due Date: '||:P14_INVOICE_DUE_DT||'
    KSR Number: '||:P14_KSR||'
    DTS PO: '||:P14_DTS_PO||'
    FINANCE DO: '||:P14_FINANCE_PO||'
    FOR detail IN(SELECT OB_CODE
    FROM BUDGET_USED
    WHERE P_ID = :P14_ID)
    v_email_body := v_email_body||detail.OB_CODE||utl_tcp.crlf;
    LOOP
    FOR detail2 IN (SELECT ob_code, amount
    FROM budget_used
    WHERE p_id = :P14_ID)
    LOOP
    v_email_body := v_email_body||detail2.ELCID||' - '||detail2.AMOUNT||utl_tcp.crlf;
    END LOOP;
    END LOOP;
    v_email_body := v_email_body
    '||:P14_EMAIL_NOTES||'
    Thanks.
    v_id := APEX_MAIL.SEND
    (p_to => :P14_SUBMIT_TO
    ,p_cc => v('APP_USER')
    ,p_bcc => '[email protected]'
    ,p_from => v_from_email_address
    ,p_body => v_email_body
    ,p_subj => 'Invoice, '||:P14_VENDOR||', '||:P14_INVOICE||'');
    --Having set up your email, now add one (or more) attachments...
    FOR c1 in (SELECT FILENAME
    ,BLOB_CONTENT
    ,MIME_TYPE
    FROM file_subjects f, apex_application_files a
    where a.name = f.name
    and f.P_ID = :P14_ID) LOOP
    IF c1.blob_content IS NOT NULL THEN
    APEX_MAIL.ADD_ATTACHMENT( p_mail_id => v_id,
    p_attachment => c1.blob_content,
    p_filename => c1.filename,
    p_mime_type => c1.mime_type);
    END IF;
    END LOOP;
    END;
    Apex_mail.push_queue();
    This is important to my company to be able to put this data into an email. If anyone can help me, I would greatly appreciate it. Thank you in advance.

    Lets isolate the erroring line by running the code in debug mode and adding some debug lines at various stages in the code
    Apex has a builtin function named wwv_flow.debug which can print messages to the debug stack and would be visible when the page is run in debug mode.
    DECLARE
    v_email_body CLOB;
    v_from_email_address VARCHAR2(100) := v('APP_USER');
    v_id NUMBER;
    BEGIN
    wwv_flow.debug('BEGIN');
      v_email_body := 'Please pay the attached invoice from FY '||:P14_FY||' funds
      Date: '||:P14_PURCHASE_DATE||'
      Vendor: '||:P14_VENDOR||'
      Invoice Number: '||:P14_INVOICE||'
      Invoice Date: '||:P14_INVOICE_DT||'
      Due Date: '||:P14_INVOICE_DUE_DT||'
      KSR Number: '||:P14_KSR||'
      DTS PO: '||:P14_DTS_PO||'
      FINANCE DO: '||:P14_FINANCE_PO||'
      '||:P14_EMAIL_NOTES||'
      Thanks.
    wwv_flow.debug('Before sending mail');
      v_id := APEX_MAIL.SEND
      (p_to => :P14_SUBMIT_TO
      ,p_cc => v('APP_USER')
      ,p_bcc => '[email protected]'
      ,p_from => v_from_email_address
      ,p_body => v_email_body
      ,p_subj => 'Invoice, '||:P14_VENDOR||', '||:P14_INVOICE||'');
    wwv_flow.debug('Before attachements');
      --Having set up your email, now add one (or more) attachments...
      FOR c1 in
             (SELECT FILENAME
            ,BLOB_CONTENT
            ,MIME_TYPE
            FROM file_subjects f, apex_application_files a
            where a.name = f.name
            and f.P_ID = :P14_ID)
      LOOP
        IF c1.blob_content IS NOT NULL THEN
        APEX_MAIL.ADD_ATTACHMENT( p_mail_id => v_id,
        p_attachment => c1.blob_content,
        p_filename => c1.filename,
        p_mime_type => c1.mime_type);
        END IF;
      END LOOP;
    wwv_flow.debug('Finished attachements'); 
      Apex_mail.push_queue();
    END;What is the last message you see in the debug after running the page in debug mode and submitting it ?

  • Numeric or value error: character to number conversion error

    I'm having problems inserting a value from a date picker field (DD-MON-YYYY HH MI )
    i'm submitting this value to a packaged procedure that accepts this field as VARCHAR2 .
    on the insert, i do a to_date( P_DATE, 'DD-MON-YYYY HH:MI PM' )
    and i get the numeric conversion error.
    If I change the to_date on the procedure side, I get the :could not read the end of the format mask - which I've found threads about on this site.
    I've tried using HH24 and different formats, but I get one of the two above errors on the insert.
    If I don't fill in the datepicker field at all, it works fine.
    help is appreciated !
    Bill

    Here is the trace anyway:
    *** ACTION NAME:(application 4000, page 1) 2004-09-24 12:58:44.052
    *** MODULE NAME:(HTML DB) 2004-09-24 12:58:44.052
    *** SERVICE NAME:(TOPS) 2004-09-24 12:58:44.052
    *** SESSION ID:(151.1) 2004-09-24 12:58:44.052
    *** 2004-09-24 12:58:44.052
    ksedmp: internal or fatal error
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    Current SQL statement for this session:
    declare
    rc__ number;
    begin
    owa.init_cgi_env(:n__,:nm__,:v__);
    htp.HTBUF_LEN := 255;
    null;
    null;
    null;
    null;
    f(p=>:p);
    if (wpg_docload.is_file_download) then
    rc__ := 1;
    wpg_docload.get_download_file(:doc_info);
    null;
    null;
    null;
    commit;
    else
    rc__ := 0;
    null;
    null;
    null;
    commit;
    owa.get_page(:data__,:ndata__);
    end if;
    :rc__ := rc__;
    end;
    ----- PL/SQL Call Stack -----
    object line object
    handle number name
    6A3C4A00 532 package body FLOWS_010500.WWV_FLOW_UTILITIES
    6A3C4A00 2502 package body FLOWS_010500.WWV_FLOW_UTILITIES
    6A3C4A00 2748 package body FLOWS_010500.WWV_FLOW_UTILITIES
    6A0E63C8 991 package body FLOWS_010500.WWV_FLOW_FORMS
    6A11675C 932 package body FLOWS_010500.WWV_FLOW_DISP_PAGE_PLUGS
    6A11675C 247 package body FLOWS_010500.WWV_FLOW_DISP_PAGE_PLUGS
    6A4B54E0 8341 package body FLOWS_010500.WWV_FLOW
    6A2A99F0 102 procedure FLOWS_010500.F
    6A2B9E54 10 anonymous block
    ----- Call Stack Trace -----
    calling call entry argument values in hex
    location type point (? means dubious value)
    ksedmp+524          CALLrel  ksedst+0 1
    ksedmptracecb+15 CALLrel _ksedmp+0            C
    _ksddoa+118          CALLreg  00000000             C
    ksdpcg+143          CALLrel  ksddoa+0
    ksdpec+180          CALLrel  ksdpcg+0 1966 6D7D208 1
    __PGOSF3__ksfpec+11 CALLrel _ksdpec+0            0
    8
    _kgerev+77           CALLreg  00000000             7474210 1966
    kgerec1+18          CALLrel  kgerev+0 7474210 6DCE5EC 1966 1
    6D7D260
    peirve+465          CALLrel  kgerec1+0
    pevmCVTCN+346 CALLrel _peirve+0           
    pfrinstrCVTCN+36 CALLrel pevmCVTCN+0 6E6E604 71CE370 7160F0C
    pfrrunno_tool+51 CALL??? 00000000
    pfrrun+1834         CALLrel  pfrrun_no_tool+0 6E6E604 6A3C010A 6E6E640
    plsqlrun+1051 CALLrel _pfrrun+0            6E6E604
    peicnt+179          CALLrel  plsql_run+0 6E6E604 1 0
    kkxexe+477          CALLrel  peicnt+0
    opiexe+4896         CALLrel  kkxexe+0 6A2B9E54
    kpoal8+1705         CALLrel  opiexe+0 49 3 6D7E06C
    _opiodr+977          CALLreg  00000000             5E 14 6D7E7CC
    _ttcpip+1827         CALLreg  00000000             5E 14 6D7E7CC 0
    _opitsk+1098         CALL???  00000000            
    opiino+938          CALLrel  opitsk+0 0 0 747ABC0 6DEFB14 D8 0
    _opiodr+977          CALLreg  00000000             3C 4 6D7FBBC
    opidrv+479          CALLrel  opiodr+0 3C 4 6D7FBBC 0
    sou2o+45            CALLrel  opidrv+0 3C 4 6D7FBBC
    opimai+237          CALLrel  sou2o+0
    OracleThreadStart@  CALLrel  opimai+0
    4+899
    77E7D338 CALLreg 00000000

  • PL/SQL: numeric or value error: character to number conversion error in TRG

    Hi,
    I've got strange issue with one trigger which during update of table reports (DB is 9.2.0.8):
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    ORA-06512: at "UDR_LOG", line 345
    ORA-04088: error during execution of trigger 'UDR_LOG'but line 345 is:
    END IF;
    so its kind of strange
    the code looks like
    343 IF nvl(to_char(:old.PKD_ID),'''') <> nvl(to_char(:new.PKD_ID),'''') THEN
    344     v_zmn := v_zmn || 'PKD_ID''' || to_char(:old.PKD_ID) || '''' || to_char(:new.PKD_ID) || '''';
    345    END IF;
    so its concatenation not to_number usage .error is triggered by update statement on any column .
    I'm sorry I cant provide You with whole trigger code .
    So if You could only recommend any investigation method that would be great .
    Regards
    Greg

    Hi, Greg,
    When there's an error in a trigger, the line numbers in the error messages are relative to the first DECLARE or BEGIN statement; often, that's a few lines after CREATE OR REPLACE TRIGGER. Post a few lines after what you already posted.
    If you can't find the error, then create another table for testing this, and create a smaller trigger on that table, which does only enough to cause the error. Then you'll be able to post the complete trigger, and the code needed to re-create the problem.

  • ORA-06502: PL/SQL: numeric or value error: character to number conversion e

    Hi,
    when I do same thing in my procedure it throws below error but it works fine as annonymus block.
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    CREATE TABLE test_table
    (memberid NUMBER,
    trans_date date);
    DECLARE
    v_num number(10,0);
    v_text varchar2(100);
    begin
    v_text := '123456abcdef';
    v_num := substr(v_text,1,5);
    INSERT INTO test_table
    (memberid,
    trans_DATE)
    VALUES
    (v_num,
    sysdate);
    end;Thanks
    Sandhya

    Works fine as a procedure as well;
    SQL> DECLARE
      2  v_num number(10,0);
      3  v_text varchar2(100);
      4  begin
      5  v_text := '123456abcdef';
      6  v_num := substr(v_text,1,5);
      7  INSERT INTO test_table
      8  (memberid,
      9  trans_DATE)
    10  VALUES
    11  (v_num,
    12  sysdate);
    13  end;
    14 
    15  /
    PL/SQL procedure successfully completed.
    SQL> select * from test_table;
      MEMBERID TRANS_DAT
         12345 20-MAY-10
    SQL> create or replace procedure ins_test_table as
      2 
      3    v_num number(10,0);
      4  v_text varchar2(100);
      5  begin
      6  v_text := '123456abcdef';
      7  v_num := substr(v_text,1,5);
      8  INSERT INTO test_table
      9  (memberid,
    10  trans_DATE)
    11  VALUES
    12  (v_num,
    13  sysdate);
    14 
    15  end ins_test_table;
    16  /
    Procedure created.
    SQL>
    SQL> exec ins_test_table;
    PL/SQL procedure successfully completed.
    SQL> select * from test_table;
      MEMBERID TRANS_DAT
         12345 20-MAY-10
         12345 20-MAY-10

  • ORA-06502: numeric or value error: character to number conversion error

    I met the following error when I ran Donald's PL/SQL function to_number_or_null. Could somebody here help me find the resolution? Thanks!
    SQL> create or replace FUNCTION to_number_or_null (
    2 aiv_number in varchar2 )
    3 return number is
    4 /*
    5 to_number_or_null.fun
    6 by Donald J. Bales on 12/15/2006
    7 An errorless to_number( ) method
    8 */
    9 begin
    10 return to_number(aiv_number);
    11 exception
    12 when INVALID_NUMBER then
    13 return NULL;
    14 end to_number_or_null;
    15 /
    Function created.
    SQL> select to_number_or_null('A') from dual;
    select to_number_or_null('A') from dual
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    ORA-06512: at "CAROL.TO_NUMBER_OR_NULL", line 10

    Only INVALID_NUMBER exception is handled and also VALUE_ERROR should be handeled. You can resolve it by handling VALUE_ERROR exception or by adding WHEN OTHERS as I did in following example.
    SQL> create or replace FUNCTION to_number_or_null (
      2      aiv_number in varchar2 )
      3      return number is
      4     /*
      5     to_number_or_null.fun
      6     by Donald J. Bales on 12/15/2006
      7     An errorless to_number( ) method
      8     */
      9  begin
    10     return to_number(aiv_number);
    11     exception
    12     when INVALID_NUMBER then
    13      return NULL;
    14     when OTHERS then
    15      return null;
    16     end to_number_or_null;
    17  /
    Function created.
    SQL> select to_number_or_null('A') from dual;
    TO_NUMBER_OR_NULL('A')
    ----------------------With kind regards
    Krystian Zieja

  • ORA-06502: PL/SQL: numeric or value error: character to number conversion

    Hello,
    I am new to Oracle Apex so I decided to read and do the tutorials that are on the apex.oracle.com site.
    Now I am at the tutorial 6: How to Work with Check Boxes of the Advanced Tutorials.
    At a certain point you have to add a new radio button.
    At the Item Source Value you have to add SELECT 'Y' FROM DUAL WHERE :P2_LIST_PRICE*0.75=:P2_MIN_PRICE.
    But when I try to create the item, I keep getting the following error:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    Error creating item.
    Does anybody know what could be the problem.
    Thanks in advance.

    CREATE OR REPLACE PROCEDURE xxbb_query (
    p_branch_code XXBOB_HRMS_APPRAISALS_DATA.Branch_code%TYPE,
    p_PERIOD_NAME XXBOB_HRMS_APPRAISALS_DATA.PERIOD_NAME%TYPE
    IS
    emp_refcur SYS_REFCURSOR;
    v_deposits XXBOB_HRMS_APPRAISALS_DATA.deposits%TYPE :=0;
    v_branch_code XXBOB_HRMS_APPRAISALS_DATA.branch_code%TYPE:=0;
    p_query_string VARCHAR2(500);
    BEGIN
    DBMS_OUTPUT.PUT_LINE('Hello' || ' ' || '...');
    p_query_string := 'SELECT Avg(deposits) Dep,branch_code  FROM XXBOB_HRMS_APPRAISALS_DATA WHERE ' ||
    *' Branch_code = :branch_code '||*
    *' AND PERIOD_NAME = SubStr( :PERIOD_NAME ,1,4))||(SubStr( :PERIOD_NAME ,InStr( :PERIOD_NAME ,'-',1,1)+3,5)) ' ||*
    *' group BY SubStr(PERIOD_NAME,5),BRANCH_CODE ';*
    DBMS_OUTPUT.PUT_LINE('Hi' || ' ' || '...');
    OPEN emp_refcur
    FOR p_query_string USING p_branch_code,v_p_PERIOD_NAME,v_p_PERIOD_NAME,v_p_PERIOD_NAME;
    -- DBMS_OUTPUT.PUT_LINE('----- -------');
    Here I m passing a string variable to pass the select statement for the ref cursor.
    There seems some problem in the substr conversion in the statement.
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    But when i run as a independent staement passing real values in the place of placeholders
    i get the result right.
    The *:PERIOD_NAME* format is *'Jan-2009-10'* .
    And I need to pass the *:PERIOD_NAME* to the query as *'Jan-09-10'*
    Pls suggest.
    Edited by: user7391361 on Jul 23, 2009 8:28 AM

  • ORA-06502 PL/SQLnumeric or value error character to number conversion error

    Hi,
    I have written report in FastReport and I am using "Oracle Provider for OLE DB" for Oracle connection.
    I have seen that my report throws oracle exception in some machines , so I analysed my PL/SQL and saw that problem occurs in "TO_NUMBER" function. (if i remove it exception does not occur)
    However, same report works fine in another machine with the same data (same oracle provider version).
    What can be the problem? What can be the dependence?
    Thanks in advance
    Elshan
    p.s. Oracle provider version is 11.2.0.2.0

    Hi ,
    the reason you are gettin this error is ecause sometimes in your data you are trying to convert a character to a number. When you say it works fine in other machine dos it mean for the same data set or a different data?
    If you thing that you data may conatin a character and you still need to use TO_NUMBer than you should chack the data before converting and if it is a character than you should no do the conversion.
    you can use this link to chek numeris or non numeric
    How to check if a field is numeric?
    thanks
    Edited by: Himanshu Kandpal on Mar 31, 2011 7:55 AM

  • Character to number conversion error during uploading csv

    hi
    I have a question regarding oracle application express.
    I want to upload the csv data to the database using apex application.
    I used a code from otn but it does not work to the number datatype value..
    It gives an error like number to charcter conversion error am not able to resolve it.
    I also use TO_NUMBER functions to convert but it doesn't works..please help me out..
    Following code I used to upload the data:
    DECLARE
    v_blob_data BLOB;
    v_blob_len NUMBER;
    v_position NUMBER;
    v_raw_chunk RAW(10000);
    v_char CHAR(1);
    c_chunk_len number:= 1;
    v_line VARCHAR2 (32767):= NULL;
    v_data_array wwv_flow_global.vc_arr2;
    v_rows number;
    BEGIN
    delete from chktable;
    select blob_content into v_blob_data
    from wwv_flow_files
    where last_updated = (select max(last_updated) from wwv_flow_files where UPDATED_BY = :APP_USER) and id = (select max(id) from wwv_flow_files where updated_by = :APP_USER); v_blob_len := dbms_lob.getlength(v_blob_data); v_position := 1; WHILE ( v_position <= v_blob_len ) LOOP v_raw_chunk := dbms_lob.substr(v_blob_data,c_chunk_len,v_position);
    v_char := chr(hex_to_decimal(rawtohex(v_raw_chunk)));
    v_line := v_line || v_char;
    v_position := v_position + c_chunk_len; IF v_char = CHR(10) THEN v_line := REPLACE (v_line,',','~'); v_data_array := wwv_flow_utilities.string_to_table (v_line,'~'); EXECUTE IMMEDIATE 'insert into SRS_CC_MI_DATA(OUTAGE,TAR_#,CUSTOMER_NAME,RECEIVED,RESOLUTION_TIME,SEVERITY,PRIORITY)
    values (:1,:2,:3,:4,:5,:6,:7)'
    USING
    v_data_array(1),
    v_data_array(2),
    v_data_array(3),
    v_data_array(4),
    v_data_array(5),
    v_data_array(6),
    v_data_array(7);
    v_line := NULL;
    END IF;
    END LOOP;
    END;
    my table contains:
    "OUTAGE" VARCHAR2(4000),
    "TAR_#" VARCHAR2(4000),
    "CUSTOMER_NAME" VARCHAR2(4000),
    "RECEIVED" VARCHAR2(4000),
    "RESOLUTION_TIME" VARCHAR2(4000),
    "SEVERITY" VARCHAR2(1),
    "PRIORITY" VARCHAR2(4000) NOT NULL ENABLE
    i need to make last two rows number type..
    it works fine if it is varchar2 but not with number type..
    plz help out

    Hello,
    >> "PRIORITY" VARCHAR2(4000) NOT NULL ENABLE
    What is the valid values of this column that you need to use varchar2(4000)? Are you sure this column include valid numbers?
    Regards,
    Arie.
    &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    &diams; Author of Oracle Application Express 3.2 – The Essentials and More

  • Report error:ORA-06502: PL/SQL: numeric or value error: character to number

    The oracle application express environment is created by installing the HTTP Server on the windows server and the application express 3.2.1 components on the 11.1.0.7 oracle database on UNIX. The installation is successfully and have not seen any issues during the installation. After completing all the steps, when tried to login and click the application builder or workspace components, I see the error message
    report error:ORA-06502: PL/SQL: numeric or value error: character to number.
    This error message is seen on most of the pages when trying to accessed and not able to understand the reasons behind it. Its a brand new environment setup and not even presented to developers to test it.
    Below error message is always seen when trying to access most of the components like application builder, schema comparison and some other tabs. Please advice
    report error:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    Edited by: user589320 on Jun 9, 2011 5:17 PM

    I think its better you use APEX 4.x version ratherthan using old version.
    You will get more features and some bug fixes and also it's easy for you to get some help when you need.
    * If this answer is helpfull or correct then please mark it and grant the points.

  • ORA-06502: PL/SQL: numeric or value error: character to number error

    Hello Gurus,
    I keep getting the following error:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    It happens on wizard generated tabular form.
    DECLARE
    v_venue_prsntd_qtr varchar2(3);
    v_venue_prsntd_fy  number;
    BEGIN
    FOR i IN 1 .. apex_application.g_f02.COUNT
      LOOP
        IF apex_application.g_f05 (i) IS NOT NULL THEN
            v_venue_prsntd_qtr :=
             Case WHEN TO_CHAR(apex_application.g_f05 (i), 'MON') IN ('OCT','NOV','DEC') THEN '1'
                  WHEN TO_CHAR(apex_application.g_f05 (i), 'MON') IN ('JAN','FEB','MAR') THEN '2'
                  WHEN TO_CHAR(apex_application.g_f05 (i), 'MON') IN ('APR','MAY','JUN') THEN '3'
                  ELSE '4'
                  END;
      -- INTO v_venue_prsntd_qtr
      -- FROM venue_prsntd
      -- WHERE venue_prsntd_seqno = apex_application.g_f02 (i)
      -- AND dfcy_seqno = apex_application.g_f03 (i)
      -- AND apex_application.g_f05 (i) IS NOT NULL;
    ----fiscal year
    --    v_venue_prsntd_fy :=
    --       CASE WHEN TO_CHAR(TO_NUMBER(TO_CHAR(apex_application.g_f05(i), 'MMDD'))) < 1001 THEN --------TO_CHAR(apex_application.g_f05 (i),'YYYY')
    --        ELSE TO_CHAR(TO_NUMBER(TO_CHAR(apex_application.g_f05 (i),'YYYY')) + 1)
    --      END;
       --  INTO v_venue_prsntd_fy
       --  FROM venue_prsntd
       --  WHERE venue_prsntd_seqno = apex_application.g_f02 (i)
       --  AND dfcy_seqno = apex_application.g_f03 (i)
       --  AND apex_application.g_f05 (i) IS NOT NULL;
    ---END IF;
      --- IF apex_application.g_f02 (i) IS NULL AND apex_application.g_f05 (i) IS NOT NULL Then
              -- INSERT INTO venue_prsntd(venue_prsntd_qtr, venue_prsntd_fy)
              --                   VALUES(v_venue_prsntd_qtr, v_venue_prsntd_fy);
                 UPDATE VENUE_PRSNTD
                      SET VENUE_PRSNTD_QTR = to_number(v_venue_prsntd_qtr)
                         -- VENUE_PRSNTD_FY = v_venue_prsntd_fy
                 WHERE VENUE_PRSNTD_SEQNO = APEX_APPLICATION.G_F03(i);
    END IF;
    END LOOP;
    END;I am trying to update venue_prsntd_qtr. I have commented everything else out to see if I can limit where the error is coming from.
    qtr is a number field in the database. I have gone back and forth with variable type in the code and still get the same error.
    I am using oracle db 10g, apex 3.2.1
    Thanks
    Mary

    Hi,
    I am guessing that apex_application.g_f05 is a date field. If that is the case, you need to use to_date() before using to_char(). For example:
    SELECT to_char('01-jan-10', 'MON') FROM dual -- Error!
    SELECT to_char(to_date('01-jan-10'), 'MON') FROM dual -- Ok!
    I hope this helps.
    Luis

  • Error while selecting NULL value from Popup Key LOV(numeric or value error)

    Hi,
    I have a item P1_DEPTNO with following properties.
    P1_DEPTNO - Popup Key LOV (Displays description, returns key value)
    LOV - P1_DEPT_LOV
    select deptname d, deptno r from deptP1_DEPTNO item properties
    List of Values
      Named LOV - P1_DEPT_LOV
      Display Null - Yes // changed to Yes, so that it can accept NULL values.
      Null display value - NULL
      Null return value -   (blank)PL\SQL Process -
    declare
    v1 number;
    begin
    if :P1_DEPTNO is null OR :P1_DEPTNO = '' then
        v1 := 0;
    else
        v1 := :P1_DEPTNO;
    end if;
    // rest of the PL\SQL process
    end;Now, when I run the page and select NULL value from Popup LOV and submit, I get the following error.
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error.When, I select any other value other than NULL, then it's working perfectly fine.
    Only in case of NULL value, I am getting this error.
    ANY idea, why this error is coming??
    Thanks,
    Deepak

    Hi Varad,
    I did the following change
    Null display value - (blank) // by default it is displaying '%' in the select this
    Null return value - -1
    but when I select % (null value) from the popup list, it displays the return value -1 in the text field.
    My question is why it is displaying the return value -1 in the text field...*It should display the display value in the text field (i.e blank in this case)*
    then, I did the following change
    Null display value - (blank) // by default it is displaying '%' in the select this
    Null return value - // a single space, so that when I select %(null value) from the list, it should display blank in the text field...
    then I did the following change in the PL\SQL process.
    PL\SQL process
    declare
    v1 number;
    begin
    if :P1_DEPTNO = ' ' then // -- checking the value of single space ' ' when we select %(null) in the popup list, BUT even I select %(null), control is not coming here.
        v1 := 0;
    else
        v1 := :P1_DEPTNO;
    end if;
    // rest of the PL\SQL process
    end;Thanks,
    Deepak

  • Difficulty in resolving ORA-06502: PL/SQL: numeric or value error:

    Hi
    I am having great difficulty to resolve the following error - ORA-06502: PL/SQL: numeric or value error: character string buffer too small . In my Oracle Package, I have a Function that returns a varchar(255).
    My Function is basically as follows:
    FUNCTION GetUserDept (DeptNum IN NUMBER) RETURN VARCHAR2
    IS
    deptname varchar(255);
    BEGIN
    SELECT name INTO deptname
    FROM depts
    where id = DeptNum;
    RETURN deptname
    END;
    The SQL is running correctly and returns one result, which is what I want. However, when I call the function in my .NET C# code, this is when I am seeing the error message.
    In my code, I said that the commandtype is a stored procedure, passed the parameters, and add it to to the parameters, with the return type and direction put first and executed as a scalar. The code executes, and then fails at the ExecuteScalar line, and it is at this point on my exception handler that I see the error message ORA-6502.
    This really odd, because I have two other functions that return numbers, and I have executed them in the same way, and theses works!
    I have checked my function and can't see what is wrong, and I have tried changing the return type from varchar2 to NVarchar on the return type, but this made no difference.
    This problem has really dogged me for hours and I cannot see how to resolve it.
    Can someone, please help me?

    user633278 wrote:
    This really odd, because I have two other functions that return numbers, and I have executed them in the same way, and theses works!It is that very reason that your code fails. You need to declare the return variable as a string.
    SQL?create or replace
    FUNCTION GetUserDept (DeptNum IN NUMBER) RETURN VARCHAR2
    IS
    deptname varchar(255);
    BEGIN
      RETURN 'hello world';
    END;
      2    3    4    5    6    7    8    9   10 
    Function created.
    SQL?
    SQL?
    declare
      x number;
    begin
      x := GetUserDept(100);
    end;
    SQL?  2    3    4    5    6  declare
    ERROR at line 1:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    ORA-06512: at line 4
    SQL?
    SQL?
    declare
      x varchar2(255);
    begin
      x := GetUserDept(100);
    end;
    SQL?  2    3    4    5    6 
    PL/SQL procedure successfully completed.

  • ORA-06502: PL/SQL: numeric or value error : Not able to run a script

    Hi All,
    I want to run a script like this:
    DECLARE
    I_so_status_dtl     RIB_SOStatusDtl_REC;
    BEGIN
    I_so_status_dtl := RIB_SOStatusDtl_REC('0'     --Cust Order No
                   ,'1000000014'     --Dest ID
                   ,'100010222'     --Item ID
                   ,1          --Order Line Number
                   ,1          --Unit Quantity
                   ,'R'          --Status
                   ,'RMS12DEV'     --User ID
                   ,'06-May-2001'     --Updated Date
    End;
    I am trying to run this script. Actually this script is supposed to generate an XML message, which I require. Here's the definition for the TYPE RIB_SOStatusDtl_REC:
    create or replace TYPE RIB_SOStatusDtl_REC UNDER RIB_OBJECT (
         cust_order_nbr     VARCHAR2(10),
         dest_id     VARCHAR2(10),
         item_id     VARCHAR2(25),
         order_line_nbr     NUMBER(3),
         unit_qty     NUMBER(12,4),
         status     VARCHAR2(2),
         user_id     VARCHAR2(10),
    updated_date DATE,
         overriding member procedure appendNodeValues( i_prefix in varchar2)
    ,constructor function RIB_SOStatusDtl_REC (rib_oid number, cust_order_nbr VARCHAR2, dest_id VARCHAR2, item_id VARCHAR2, order_line_nbr NUMBER, unit_qty NUMBER, status VARCHAR2) return self as result
    ,constructor function RIB_SOStatusDtl_REC (rib_oid number, cust_order_nbr VARCHAR2, dest_id VARCHAR2, item_id VARCHAR2, order_line_nbr NUMBER, unit_qty NUMBER, status VARCHAR2, user_id VARCHAR2) return self as result
    This TYPE has a body which actually generates an XML message.
    But whenever I am trying to run this, I am getting the following message:
    Error report:
    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:   
    *Action:
    Therefore I am not able to run the following script. Here I am passing hard coded value within the TYPE, as I have run similar kind of scripts, which accepts this and creates an xml message. Can anyone help me what's the wrong with this script?
    Thanks & Regards,
    Debabrata

    Hi,
    Create one constructor same as with 8 parameters as you have constructor for only 7 and 8 9 parameters.
    Regards
    RK

  • How to solve numeric or value error?

    Hi,
    Im getting "ORA-06502: PL/SQL: numeric or value error: character to number conversion error" while executing the procedure with executeSQL method.Please help me with solutions.
    Thanks in advance

    Hi,
    Im getting "ORA-06502: PL/SQL: numeric or value error: character to number conversion error" while executing the procedure with executeSQL method.Please help me with solutions.
    Thanks in advance

Maybe you are looking for

  • CD Burner Troubleshooting: No Burner Disc or software found

    I've had my iMac for just a couple months, slowly learning the ropes. I successfully burned a few CDs, but then one day it suddenly started giving me an error message when I click on "burn disc." It said: No Disc Burner or software found. I tried to

  • Getting an error in ECC 6.0 when open table MARA

    Hello  Experts, In ECC 6.0 while opening  table MARA, I am getting an error "Inconsitency inthe Dictionary for the structure "Mara"."and  so on for other tcodes. This error I am getting since yesterday, previously I was not getting such error. Can an

  • Updating a DB table with only non-empty values of a work area

    Hi everybody, Is that possible in ABAP to update a table in the database with a work area, but only with non-empty values of this work area? Example: data: ls_custom type ZCUSTOMERS_0. ls_custom-CUSTOMER = '20'. ls_custom-LASTNAME = 'MyName'. ls_cust

  • Custom field values are not storing in the data base

    Hi Friends, We have created one  Custom field called   ZZ_APPROVER in Rfx Header , we have included this field in the below  stuctures 1.INCL_EEW_PD_HEADER_CSF_BID 2.INCL_EEW_PD_HEADER_CSF The data type of this field ( ZZ_APPROVER ) is CHAR and the l

  • Duplicates

    I transferred a bunch of stuff to a new computer from my old one. It doesn't matter how, but I have duplicates of a ton of tunes in my new computer's library now. Is there a quick way to delete all the duplicates and just have "one" of each tune in t