Ora-01858

create or replace function t_recovery(branch number,t_prd varchar2,t_date date)
   return varchar2
   is
   v_var varchar2(30):='0.00|0.00';
begin
   begin
           SELECT INT_REC INTO V_VAR FROM
                   select to_char(sum(prn_rec),'9999999999.99') INT_REC  from
                           SELECT LBRCODE,MAINACCTID,
                           SUM(DECODE(REMARK,'prn_rec',FCYTRNAMT,0)) prn_rec,
                           SUM(DECODE(REMARK,'int_rec',FCYTRNAMT,0)) int_rec
                           from
                                   SELECT LBRCODE,MAINACCTID,FCYTRNAMT,VCRACCTID,DRCR,ENTRYDATE,cashflowtype,activitytype,
                                   (case       when (cashflowtype='LNPCR' or cashflowtype='LNOCHCR') then 'prn_rec'
                                               when (cashflowtype<>'LNPCR' and trim(substr(vcracctid,1,8))='INTREC') then 'int_rec'
                                       ELSE 'NOT_TO_BE_CONSIDERED'END)AS REMARK ,
                                           t_module(trim(substr(mainacctid,1,8)),lbrcode) module FROM vcr_file
                                           WHERE LBRCODE=branch
                                           and ENTRYDATE BETWEEN TRUNC(to_date('t_date','dd-mon-yyyy'),'MONTH') AND to_date('t_date','dd-mon-yyyy')
                                           and t_module(trim(substr(mainacctid,1,8)),lbrcode) IN (13,30)
                                           and canceledflag<>'C'
                                           and drcr='C'
                                           and mainacctid=t_prd
                           )group by lbrcode,mainacctid,remark
                           group by lbrcode,mainacctid
                   exception
                   when no_data_found then
                   return v_var;
   end;
           return v_var;
end t_recovery;when i created above function oracle did not show any error
but when i tried the function
SQL> SELECT LBRCODE,PRDACCTID,T_RECOVERY(LBRCODE,PRDACCTID,TO_DATE('31-OCT-2011','DD-MON-YYYY')) REC FROM D009022
  2  WHERE LBRCODE=18;
SELECT LBRCODE,PRDACCTID,T_RECOVERY(LBRCODE,PRDACCTID,TO_DATE('31-OCT-2011','DD-MON-YYYY')) REC FROM ac_mastfolllowing error ocurred
ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at "RECORD.T_RECOVERY", line 7i am using 10g standard edition

See examples in the link provided:
The Format Model of the to_char function uses the letters D and G as the decimal and the group separator respectively to be able to cope with different languages.
Take a look at http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10766/tdddg_globalization.htm#TDDDG62620
Regards
Etbin

Similar Messages

  • Error while pulling data from an Oracle database. ORA-01858: a non-numeric character was found where a numeric was expected

    I'm trying to pull data from an Oracle database using SSIS. When I try to select a few fields from the source table, it returns the following error message:
        [OLE DB Source [47]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80040E14.
        An OLE DB record is available.  Source: "OraOLEDB"  Hresult: 0x80040E14  Description: "ORA-01858: a non-numeric character was found where a numeric was expected".
        An OLE DB record is available.  Source: "OraOLEDB"  Hresult: 0x80004005  Description: "ORA-01858: a non-numeric character was found where a numeric was expected".
    The source columns are a combination of numeric and texts, and I've also tried selecting one of them, which didn't work. I'm using the Oracle client 11.2.0.1, and it works fine with any other data sources I have connected to so far. How can I resolve this
    error?

    Hi H.James,
    According to your description, the issue is a non-numeric character was found where a numeric was expected while pulling data from an Oracle database in SSIS.
    Based on the error message, the issue should be you are comparing a number column to a non-number column in a query. Such as the query below (ConfID is a number, Sdate is a date):
     where C.ConfID in (select C.Sdate
                       from Conference_C C
                       where C.Sdate < '1-July-12')
    Besides, a default behavior for the Oracle OleDb Provider that change the NLS Date Format of the session to 'YYYY-MM-DD HH24:MI:SS can also cause the issue. For more details about this issue, please refer to the following blog:
    http://blogs.msdn.com/b/dataaccesstechnologies/archive/2012/01/20/every-bug-is-a-microsoft-bug-until-proven-otherwise.aspx
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • ORA-01858: a non-numeric character was found where a numeric was expected

    hi ,
    This was the code which shows the sales rep invoice amount and collected amount but while running report thru concurrent program its showing the following error:
    ORA-01858: a non-numeric character was found where a numeric was expected
    WHERE TO_CHAR ( TO_DATE ( PS.GL_DATE , 'DD/MON/YY' ) , 'MON-YYYY' ) BETWEEN TO_CHAR ( TO_DATE ( : ==> P_todate , 'YYYY/MM/DD' ) , 'MON-YYYY' ) AND TO_CHAR ( TO_DATE ( : P_todate , 'YYYY/MM/DD' ) , 'MON-YYYY' ) AND ps.customer_id = cust.custome
    The Actual Code was this
    SELECT SUBSTR(SALES.name,1,50) salesrep_name_inv,
    --ps.CLASS,
    SUM(ABS(ps.acctd_amount_due_remaining)) acctd_amt,
    SUM(ABS(ps.amount_due_remaining)) amt_due_remaining_inv,
    SUM(ABS(ps.amount_adjusted)) amount_adjusted_inv,
    SUM(ABS(ps.amount_applied)) amount_applied_inv,
    SUM(ABS(ps.amount_credited)) amount_credited_inv,
              SALES.salesrep_id,
    NULL "REMARKS"
    -- ps.gl_date gl_date_inv,
    FROM ra_cust_trx_types ctt,
    ra_customers cust,
    ar_payment_schedules ps,
    ra_salesreps SALES,
    ra_site_uses site,
    ra_addresses addr,
    ra_cust_trx_line_gl_dist gld,
    gl_code_combinations c,
    ra_customer_trx ct
    WHERE TO_CHAR(TO_DATE(PS.GL_DATE,'DD/MON/YY'),'MON-YYYY')
    BETWEEN TO_CHAR(TO_DATE(:P_todate,'YYYY/MM/DD'),'MON-YYYY') AND TO_CHAR(TO_DATE(:P_todate,'YYYY/MM/DD'),'MON-YYYY')
    AND ps.customer_id = cust.customer_id
    AND ps.customer_trx_id = ct.customer_trx_id
    AND ps.cust_trx_type_id = ctt.cust_trx_type_id
    AND NVL(ct.primary_salesrep_id, -3) = SALES.salesrep_id
    AND ps.customer_site_use_id+0 = site.site_use_id(+)
    AND site.address_id = addr.address_id(+)
    AND TO_CHAR(TO_DATE(PS.GL_DATE_CLOSED,'DD/MON/YY'),'MON-YYYY')
    BETWEEN TO_CHAR(TO_DATE(:P_todate,'YYYY/MM/DD'),'MON-YYYY') AND TO_CHAR(TO_DATE(:P_todate,'YYYY/MM/DD'),'MON-YYYY')
    --AND    ps.gl_date_closed > TO_DATE(:P_todate,'MON-YYYY')
    AND ct.customer_trx_id = gld.customer_trx_id
    AND gld.account_class = 'REC'
    AND gld.latest_rec_flag = 'Y'
    AND gld.code_combination_id = c.code_combination_id
    AND sales.salesrep_id is not null and sales.name is not null
    -- and ps.payment_schedule_id+0 < 9999
    -- AND SALES.salesrep_id ='1001'
    GROUP BY SALES.name,
    --ps.CLASS,
    SALES.salesrep_id

    So to_date function accepts a string as input and returns a date. When a date is input instead, it is implicity converted to the required type of the function paremeter, which is a string, so that to_date can convert it back to a date again.
    If you are lucky with the implicit conversion, you get the same date back, if you are not you might get a different date or an error.
    From your query it appears that this conversion from a date, to a string, to a date, and then back to a string using to_char this time, is being done to remove the time or day part of the date. The actual range comparison is being done on strings rather than dates, which is dangerous as strings sort differently than dates.
    In this example if I sort by date, Jan 01 comes between Dec 00 and Feb 01 as you would expect.
    SQL> select * from t order by d;
    D
    12-01-2000
    01-01-2001
    02-01-2001When converted to strings, Feb 01 comes between Dec 00 and Jan 01, which is probably not the desired result
    SQL> select * from t order by to_char(d,'DD-MON-YY');
    D
    12-01-2000
    02-01-2001
    01-01-2001If you want to remove time and day parts of dates you should use the trunc function
    trunc(d) removes the time, trunc(d,'mm') will remove the days to start of month.
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/functions201.htm#i79761

  • ORA-01858 error in Application but not in sqlpluss

    Hi.
    I have this query that runs nicely in sqlpluss and the SQL Commands that came with Expressedition 10g, but when I put it in a report region it produce:
    report error:
    ORA-01858: a non-numeric character was found where a numeric was expected
    query:
    SELECT temae.temae, NVL(antall,0) Antall
    FROM temae LEFT OUTER JOIN (SELECT temae, count(temae) as antall
    FROM okeiko
    WHERE person = :P3_PERSON and dag >= to_date(DECODE(SIGN(to_char(current_date,'mm')-5),
    -1, to_date('01-NOV-'||to_char(current_date,'yy'))-365,
    0, to_date('01-MAY-'||to_char(current_date,'yy')),
    1, DECODE(SIGN(to_char(current_date,'mm')-10),
    -1,to_date('01-MAY-'||to_char(current_date,'yy')),
    0,to_date('01-MAY-'||to_char(current_date,'yy')),
    1,to_date('01-NOV-'||to_char(current_date,'yy')))),'dd-mon-yy')
    GROUP BY temae) p
    ON temae.id = p.temae
    where antall > 0
    ORDER BY NVL(antall,0) DESC, temae.type, temae.temae
    Before I added the decode part for the date it looked like this, and worked nice in the application:
    SELECT temae.temae, NVL(antall,0) Antall
    FROM temae LEFT OUTER JOIN (SELECT temae, count(temae) as antall
    FROM okeiko
    WHERE person = :P3_PERSON and dag > to_date('30-apr-06','dd-mon-yy')
    GROUP BY temae) p
    ON temae.id = p.temae
    where antall > 0
    ORDER BY NVL(antall,0) DESC, temae.type, temae.temae
    This is the data structure
    SQL> describe temae
    Name Null? Type
    ID NOT NULL NUMBER
    TEMAE VARCHAR2(20)
    TYPE NUMBER
    Then it worked nicely in the application to.
    SQL> describe okeiko;
    Name Null? Type
    ID NOT NULL NUMBER
    PERSON NOT NULL NUMBER
    TEMAE NOT NULL NUMBER
    SENSEI NUMBER
    REMARK VARCHAR2(4000)
    DAG NOT NULL DATE
    Can anyone se why application is complaining?
    BTW report region also complains to_date('01-may-06','dd-mon-yy') does not have a valid month.

    Marius,
    I am not sure but try this:
    SELECT   temae.temae, NVL (antall, 0) antall
        FROM temae LEFT OUTER JOIN (SELECT   temae, COUNT (temae) AS antall
                                        FROM okeiko
                                       WHERE person = :p3_person
                                         AND dag >=
                                                TO_DATE
                                                   (DECODE
                                                       (SIGN
                                                           (  TO_CHAR
                                                                    (CURRENT_DATE,
                                                                     'mm'
                                                            - 5
                                                        -1, TO_DATE
                                                              (   '01-NOV-'
                                                               || TO_CHAR
                                                                     (CURRENT_DATE,
                                                                      'yy'
                                                         - 365,
                                                        0, TO_DATE
                                                           (   '01-MAY-'
                                                            || TO_CHAR
                                                                    (CURRENT_DATE,
                                                                     'yy'
                                                        1, DECODE
                                                           (SIGN
                                                               (  TO_CHAR
                                                                     (CURRENT_DATE,
                                                                      'mm'
                                                                - 10
                                                            -1, TO_DATE
                                                               (   '01-MAY-'
                                                                || TO_CHAR
                                                                      (CURRENT_DATE,
                                                                       'yy'
                                                            0, TO_DATE
                                                               (   '01-MAY-'
                                                                || TO_CHAR
                                                                      (CURRENT_DATE,
                                                                       'yy'
                                                            1, TO_DATE
                                                               (   '01-NOV-'
                                                                || TO_CHAR
                                                                      (CURRENT_DATE,
                                                                       'yy'
                                    GROUP BY temae) p ON temae.ID = p.temae
       WHERE antall > 0
    ORDER BY NVL (antall, 0) DESC, temae.TYPE, temae.temaeI took out the formating of your to_date function.
    Denes Kubicek

  • HELP!!!!  ORA-01858 By creating user or reset password get this error

    By creating user or reset password get this error:
    Data Error: ORA-01858: found a non-digital world where expecting one numerical ORA-06512: at "DERWEB.ORA_ASPNET_MEM_RESETPASSWORD", line 80 ORA-06512: at line 1

    Hi
    You get this error when profile class amounts are not set for all the currency.  Go back to your profile and ensure that the profile amounts are set for all the currencies found, whether you are using it or not.
    Regards

  • Oracle error - ociexecute(): OCIStmtExecute: ORA-01858

    Using PHP 4.3.11 on Linux and ADODB data abstraction library.
    Oracle client version is 10.1.
    Can sucessfully connect to remote database (version 9.2.0.6 NLS_LANG AL32UTF8).
    When doing a simple select from a view:
    select RTS_LOAD from VW_R_PROJECTED_LOAD_OUTPUT
    I get the error message:
    ociexecute(): OCIStmtExecute: ORA-01858: a non-numeric character was found where a numeric was expected in /opt/devftp/var/www/php/adodb/461/drivers/adodb-oci8.inc.php on line 942
    1858: ORA-01858: a non-numeric character was found where a numeric was expected
    If in my PHP script I directly query the underlying table that this Oracle view is based on, I have no problem.
    Using SQLPlus on the web server I don't have any problems at all selecting from the view, it is definitely a valid view.
    Any clues? If so please email as well as posting response here.
    Geoff
    [email protected]

    Hi !
    I think Your view has to_date function in its definition, and this to_date is called without second parameter: date format. Probably NLS_DATE_FORMAT is set to different values in SQL*Plus and PHP environment. You can check it out by running
    select * from v$nls_parameters;
    in SQL*Plus and in PHP.
    If there are two different values You should modify view to use to_date in form: to_date(some_date_string, ‘poroper_date_format’)
    Regards,
    Pawel

  • National Language Support and Error ORA-01858

    Hi,
    I have a problem using NLS.
    When I use NLS for Italian,I become the error ORA-01858 -->
    "a non-numeric character was found where a numeric was
    expected".
    But with the same query I use for NLS_Italian,it works with
    NLS_German and NLS_English.
    I use this date-formats "DD.Month YYYY" , "DD.MM.YYYY", "DD.MM"
    For example:
    Select to_char(sd.Datum,'DD.Month YYYY') Datum ,
    sd.FONDSVERMOEGEN, sd.AKTIEN, sd.KASSE, sd.RENTEN,sd.FUTURES,
    sd.WERTPAPIERE, sd.IMMOBILIEN,
    sd.KUPON, sd.DURCHSCHNITT_RENDITE, sd.DURCHSCHNITT_RL from
    Strukturdaten sd,fondsdaten_allgemein fd
    where sd.match=fd.match and sd.match=amfcomm .
    Can somebody help me??

    Can you tell us what the value of sd.Datum is in the queries?

  • Nationnal Language Support and Error ORA-01858

    Hi,
    I have a problem using NLS.
    When I use NLS for Italian,I become the error ORA-01858 -->
    "a non-numeric character was found where a numeric was expected".
    But with the same query I use for NLS_Italian,it works with
    NLS_German and NLS_English.
    I use this date-formats "DD.Month YYYY" , "DD.MM.YYYY", "DD.MM"
    For example:
    Select to_char(sd.Datum,'DD.Month YYYY') Datum ,
    sd.FONDSVERMOEGEN, sd.AKTIEN, sd.KASSE, sd.RENTEN,sd.FUTURES,
    sd.WERTPAPIERE, sd.IMMOBILIEN,
    sd.KUPON, sd.DURCHSCHNITT_RENDITE, sd.DURCHSCHNITT_RL from
    Strukturdaten sd,fondsdaten_allgemein fd
    where sd.match=fd.match and sd.match=amfcomm .
    Can somebody help me??

    Can you tell us what the value of sd.Datum is in the queries?

  • Lession 3 oca sql fundamental doubts on ora -01858 error

    SELECT last_name, hire_date
       FROM   employees
       WHERE  hire_date = TO_DATE('May 24, 1999', 'fxMonth DD, YYYY');
       books mention it will leave a error (ora-01858 which is an non-numeric error )but the statement running perfectly while
    by deleting that "fx"-prefix gives an error called ora-01861.
    i am confused here??can anyone show me the right way?

    Hi,
    The outcome depends on your NLS settings. Probably yours are set to something different than AMERICAN. In you language the month of May may then have a different number of characters(?)
    That's why you hit the ORA-01861 with the FX Format Model, and something else without. (Can't see why you should get ORA-01858, though)
    Regards
    Peter

  • Handling ORA-01858 error

    hi every body,
    How can i handle exception ora-01858 without
    using when others then null;
    I want something
    like
    when user_definded =ora-01858 then null;
    when others then
    v_ErrorNumber := SQLCODE;
    v_ErrorText := SUBSTR(SQLERRM, 1, 2000);

    in fact ,
    I use a procadure that insert values into a table.
    I want that when it reaches an ORA-01858 , then the error is ignored and continue
    to insert others values,
    but now , when I reach error it stops, how to deal with it ?
    CREATE OR REPLACE PROCEDURE INSERT_SWAP_FIXINGS (l_num number)
    as
    v_date varchar2(20);
    v_swap varchar2(1000);
    conn utl_tcp.connection;
    p pls_integer;
    line varchar2(4000);
    v_ErrorNumber NUMBER; -- Variable to hold the error number
    v_ErrorText VARCHAR2(200); -- Variable to hold the error message text
    e_Non_Numeric EXCEPTION;
    PRAGMA EXCEPTION_INIT(e_Non_Numeric , -1858);
    begin
    select trunc(sysdate) -l_num into v_date from dual;
    select regexp_replace (stringAgg(ticker),',','|') ||';' into v_swap from SWAP_DESC ;
    conn := utl_tcp.open_connection(remote_host=>'MY_H0ST',remote_port=>123156);
    p := utl_tcp.write_line(conn, v_swap);
    p := utl_tcp.write_line(conn, 'PX_Last;');
    p := utl_tcp.write_line(conn, v_date );
    p := utl_tcp.write_line(conn,';');
    p := utl_tcp.write_line(conn, v_date);
    p := utl_tcp.write_line(conn, '>');
    begin
    loop
    line := utl_tcp.get_line(conn, TRUE);
    if get_token(line,2) like '%N/A%' then
    dbms_output.put_line(get_token(line,1)||','||get_token(line,2));
    dbms_output.put_line(line);
    insert into TMP_SWAP_FIXINGS
    values (get_token(line,1),to_date(get_token(line,2),'DD/MM/YYYY'));
    else
    insert into swap_fixings values (get_token(line,1),to_date(get_token(line,2),'DD/MM/YYYY'),get_token(line,3));
    end if;
    end loop;
    EXCEPTION
    WHEN utl_tcp.end_of_input THEN
    NULL;
    end;
    utl_tcp.close_connection(conn);
    commit;
    declare
    ligne varchar2(2000);
    corps varchar2(7000);
    begin
    ligne :=' DATA SWAP INSERTION : '
    || UTL_TCP.crlf || UTL_TCP.crlf
    || RPAD ('TICKER',30,' ')
    || RPAD ('INFO_DATE',40,' ')
    || RPAD ('LAST_PRICE',10,' ');
    corps := ligne || UTL_TCP.crlf;
    for x in (select ticker,to_char(info_date,'DD/MM/YYYY') "INFO_DATE",LAST_PRICE from SWAP_FIXINGS where trunc(info_date) = v_date)
    loop
    ligne :=
    RPAD (x.TICKER, 30, ' ')
    ||RPAD (x.info_date,40 ,' ')
    ||RPAD (x.LAST_PRICE,10,' ');
    corps := corps || ligne || UTL_TCP.crlf;
    end loop;
    corps := '<pre>' || corps || '</pre>';
    debug(corps);
    end;
    EXCEPTION
    WHEN e_Non_Numeric then
    null;
    when OTHERS THEN
    v_ErrorNumber := SQLCODE;
    v_ErrorText := SUBSTR(SQLERRM, 1, 200);
    declare
    ligne varchar2(2000);
    corps varchar2(7000);
    begin
    ligne := RPAD (v_ErrorText, 200, ' ');
    corps := corps || ligne || UTL_TCP.crlf;
    corps := '<pre>' || corps || '</pre>';
    debug(corps);
    end;
    end;
    /

  • ORA-01858: a non-numeric character found where a digit was expected

    Hi,
    I'll cut introductions short. We're trying to read data from a flat file (OWB ver.9.2. by the way). After successfully mapping, then generating (with two insignificant warnings), we execute.
    Although it says the execution was 'successful', more than a dozen errors return in the form of ORA-01858: a non-numeric character found where a digit was expected
    a - Here is the error:
    Record 1: Rejected - Error on table "TOPSSTAGE"."FLTR_DCS_IRREG", column "OPERATIVE_FLIGHT_LEG_DATE".
    ORA-01858: a non-numeric character was found where a numeric was expected
    *it's actually repeated 20 times (Record 1, Record 2, and so on and so forth...) with the same exact error description and details.
    b - Here's the part of the OWB-generated script that defines the creation of that field/column:
    "OPERATIVE_FLIGHT_LEG_DATE" DATE "mm/dd/yyyy"
    c - And here's the data from the flat file (1 of 4 rows)
    "2/20/2007","I","0899","N","TPE","MNL","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","750","950","746","955"," P3231",,"04","32","32",,,,,,,,"758","946",,"A000","4","D000","5","000","0","0","0","0","D","P","0","0","0","0","0","0","0","0","0","0","0","2/22/2007","000","012","144","2/20/2007","2/20/2007"
    *the part where it is in bold is the one that is mapped from the column OPERATIVE_FLIGHT_LEG_DATE to the OPERATIVE_FLIGHT_LEG_DATE column (flat to physical, right?)
    it is set as DATE in all settings (mapping, file, etc..)
    Any form of help will be greatly appreciated :)
    Thanks!
    Regards,
    _lilim                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi Bharadwaj,
    Yes, I believe you are right. And yes that column is designated a primary key. The weird thing is, we do have null values being entered into the table from the flat file, but these values are far from the "OPERATIVE_FLIGHT_LEG_DATE" column (index-wise). Let me give you an example of our case:
    this is a row in the flat file: (sample data only)
    "2/20/2007","I","0899","N","TPE","MNL","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","750","950","746","955"," P3231",,"04","32","32",,,,,,,,"758","946",,"A000","4","D000","5","000","0","0","0","0","D","P","0","0","0","0","0","0","0","0","0","0","0","2/22/2007","000","012","144","2/20/2007","2/20/2007"
    as you can see, I've made the 'null' values bold, as well as the data for OPERATIVE_FLIGHT_LEG_DATE (which shows up, as you can see, at the end of the row).
    Now, in the OWB table, the OPERATIVE_FLIGHT_LEG_DATE column is set as a primary key (or foreign, i think, I'll check again) and, thus, is set as one of those columns to first receive data transferred from the flat file.
    We see nothing wrong with our mask (which is mm/dd/yyyy by the way) as well as with our data type settings. It has to be with the flat file I guess. We're gonna try putting in dummy values in place of the null ones in the flat file. I'll get back to you asap. Thanks for helping out. :D
    Regards,
    _lilim

  • PL/SQL Function Returning Query Error / ORA-01858: a non-numeric char.....

    I'm trying to write a PL/SQL function to dynamically return a query with varying # of columns. I've done this type of thing before wiith much success, however this is the first time I'm using a cursor for loop within a function to accomplish my task.
    here is the error I get:
    ORA-01858: a non-numeric character was found where a numeric was expected
    Error ERR-1101 Unable to process function body returning query.
    Mind you I have tested the PL/SQL from a SQL editor and it works fine. I'm confused.
    Code is below.
    Thanks in advance!
    DECLARE
    my_query varchar2(4000);
    string1 varchar2(50) := 'select city, ';
    string2 varchar2(4000) := '' ;
    string3 varchar2(4000):= 'from
    ( select a.title, a.city, a.start_date, sum(a.total_stu) cnt
    from sj_class_summary3 a
    group by a.title, a.city, a.start_date
    having a.title = :P4_COURSE )
    group by title, city';
    TYPE date_tab_type IS TABLE OF date INDEX BY PLS_INTEGER;
    date_tbl date_tab_type;
    i number;
    BEGIN
    i:=1;
    for myrec in (select distinct start_date from sj_class_summary3
    where start_date between :P4_START_DATE and :P4_END_DATE order by 1) loop
    date_tbl(i) := myrec.start_date;
    string2 := string2 || ' max( decode( start_date, ''' || date_tbl(i) || ''', cnt,0) ) "' || date_tbl(i) || '", ';
    i := i+ 1;
    end loop;
    string2 := SUBSTR(string2,1,LENGTH(string2)-2);
    string2 := string2 || ' ';
    my_query := string1 || string2 || string3;
    return my_query;
    END;

    Hi Bob,
    you also have another date to character to date conversion in:
    decode( start_date, ''' || date_tbl(i) || ''', cnt,0)
    does this need to be:
    decode( start_date, to_date(''' || to_char(date_tbl(i), 'dd/mm/yyyy') || ''', ''dd/mm/yyyy''), cnt,0)
    Regards
    Michael

  • ORA-01858 error from Apex Report on working/valid underlying query

    After two days of searching these forums and AskTom, I think I need to post the following problem.
    I have what seems to be a valid view of some data created as follows (with an apology for the formatting - doesn't seem to be a way of using a fixed font here):
    CREATE OR REPLACE FORCE VIEW "PRICING_CAPABILITY"."POW_EXEC_SUMM010" ("Item",
    "Jul-09", "Aug-09", "Sep-09", "Oct-09", "Nov-09", "Dec-09", "Jan-10",
    "Feb-10", "Mar-10", "Apr-10", "May-10", "Jun-10", "YTD")
    AS
    SELECT
    "Item",
    SUM(DECODE("ItemMonth",'Jul-09',"ItemValue",0)) "Jul-09",
    SUM(DECODE("ItemMonth",'Aug-09',"ItemValue",0)) "Aug-09",
    SUM(DECODE("ItemMonth",'Sep-09',"ItemValue",0)) "Sep-09",
    SUM(DECODE("ItemMonth",'Oct-09',"ItemValue",0)) "Oct-09",
    SUM(DECODE("ItemMonth",'Nov-09',"ItemValue",0)) "Nov-09",
    SUM(DECODE("ItemMonth",'Dec-09',"ItemValue",0)) "Dec-09",
    SUM(DECODE("ItemMonth",'Jan-10',"ItemValue",0)) "Jan-10",
    SUM(DECODE("ItemMonth",'Feb-10',"ItemValue",0)) "Feb-10",
    SUM(DECODE("ItemMonth",'Mar-10',"ItemValue",0)) "Mar-10",
    SUM(DECODE("ItemMonth",'Apr-10',"ItemValue",0)) "Apr-10",
    SUM(DECODE("ItemMonth",'May-10',"ItemValue",0)) "May-10",
    SUM(DECODE("ItemMonth",'Jun-10',"ItemValue",0)) "Jun-10",
    SUM("ItemValue") AS "YTD"
    FROM
    SELECT
    'New Proposals Received' AS "Item",
    TO_CHAR(t1.scope_received,'Mon-RR') AS "ItemMonth",
    COUNT(*) AS "ItemValue",
    10 AS "SortOrder"
    FROM
    PRICING_CAPABILITY.POW_DATA t1
    WHERE
    t1.scope_received IS NOT NULL
    AND extract(YEAR FROM t1.scope_received) IN (2009,2010)
    AND t1.scope_received >= '01-JUL-2009'
    GROUP BY
    'New Proposals Received',
    TO_CHAR(t1.scope_received,'Mon-RR'),
    10
    UNION
    SELECT
    'New Proposals Completed' AS "Item",
    TO_CHAR(t2.pricing_approval,'Mon-RR') AS "ItemMonth",
    COUNT(*) AS "ItemValue",
    20 AS "SortOrder"
    FROM
    PRICING_CAPABILITY.POW_DATA t1
    JOIN PRICING_CAPABILITY.POW_LAST_HISTORY t2
    ON
    t1.POW_DATA_ID = t2.POW_DATA_ID
    WHERE
    t2.pricing_approval IS NOT NULL
    AND extract(YEAR FROM t2.pricing_approval) IN (2009,2010)
    AND t2.pricing_approval >= '01-JUL-2009'
    GROUP BY
    'New Proposals Completed',
    TO_CHAR(t2.pricing_approval,'Mon-RR')
    GROUP BY
    "Item",
    "SortOrder"
    ORDER BY
    "SortOrder" ;
    This view works, ie produces the right results when run (ie select * from ...) in SQL Developer and in the SQL Workshop section of Apex.
    But when I attempt to produce an Apex report using it as the source of data, I get the following error:
    ORA-01858: a non-numeric character was found where a numeric was expected
    The error is displayed before any part of the report itself is displayed, ie the Region Header is displayed and then the error message.
    So far, anything I've been able to find on the forums or AskTom suggests that it is probably due to a date conversion problem. But the aim here is to summarise dated records by month, so I'm extracted the year and month elements of the date values, converting them to strings (using TO_CHAR), and then using the resulting 'Mon-YY' strings to group the results.
    If there is a better way, I'm interested.
    But I don't understand why Apex seems to be rejecting what appear to be valid results from a valid working query.
    Any ideas? Suggestions?
    Cheers,
    Peter

    Thanks again, Flavio. I'm learning and I appreciate your patience.
    The solution you provided is very similar to the one I came up with after your previous message, but I didn't have the NLS_DATE_LANGUAGE parameter. I'll go back and try it.
    I appreciate your explanation re Apex not needing to know and Oracle assuming that the client knows what it is doing, but it puzzles me more.
    The way that I originally had things, I think, was consistent with what you have explained, but it didn't work. To make it clear:
    1 I had an Oracle view that had no parameters and contained the date literal in the where clause and worked fine in both SQL Developer and in the Apex SQL Workshop.
    2 The view did not return any date values. Aside from the column headings and the first column (of character strings), the body of the table comprised integer values only.
    3 So, when Apex called the view, I would have expected the Oracle server to independently execute the view and return the (dateless) results to Apex, which would then present the unmodified results in a standard report. This is, I think, what SQL Developer and the Apex SQL Workshop appear to have successfully done.
    My expectation seems to be consistent with at least some of your explanation (ie [Oracle assumes] "+that the client knows what it is doing+" and "+apex doesn't need to know anything about the underlying query+"), but is not consistent with actual experience, where Apex seems to know that the underlying query contains a date literal and unsuccessfully (and unnecessarily) attempts to interpret it.
    I'm obviously missing something about how Apex and Oracle interact in this situation. While I don't need to know - as I have a working solution now - it is valuable to understand how things work. Makes life easier and more productive.
    Cheers,
    Peter

  • ORA-01858 in Oracle forms

    Hi,
    I am getting ORA-01858 in Oracle form ,when following statement is firing in oracle form
    Datatype of itemname is DATE
    :blockname.itemname :=sysdate
    This particular statement is working in Oracle forms with Patch 17 and not with Oracle forms with Patch 13.
    But its not listed in the bugs fixed in Patch17.
    So help me out...
    Regards,
    SS

    probably you can find a faster answer in the Forms forum:
    Forms

  • Ora 01858 through Java code

    In a very peculiar condition the following code gives ora-01858(a non-numeric character was found where a numeric was expected) in one environment whereas it doesnt give in other environment.
    In Environment 1
    DEBUG - %%%%%%%% sbSQLDetailsMbrLp==select TB_TRS_LP.MKT_BID_RATE, PUBLISH_DT from TB_TRS_LP where TB_TRS_LP.SWIFT_CCY_CODE='HKD' and TB_TRS_LP.TENOR='O/N' and TO_DATE(TB_TRS_LP.PUBLISH_DT,'dd/MM/YYYY hh:mi:ss AM') <= TO_DATE('', 'dd/MM/YYYY hh:mi:ss AM') AND BKG_CODE='SIN' ORDER BY PUBLISH_DT DESC
    ERROR - Exception: java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
    ERROR - Exception: com.pbg.eplatform.exception.CDBException: Problem occured in DAO(CShowCustomerInterestRateDAO) due to SQLException!
    Exception Raised - ORA-01858: a non-numeric character was found where a numeric was expected
    In Environment 2 this goes perfectly fine. We are using Weblogic JDBC. If we execute the same query outside java code, the sql does nt throw any errors.
    Any known issues or anybody who have come across this problem. please throw some light.
    The oracle versions between environment 1 and 2 are as follows.
    In Environment 1
    SQL> select * from v$version;
    BANNER
    Oracle8i Enterprise Edition Release 8.1.7.2.0 - Production
    PL/SQL Release 8.1.7.2.0 - Production
    CORE 8.1.7.0.0 Production
    TNS for Solaris: Version 8.1.7.2.0 - Production
    NLSRTL Version 3.4.1.0.0 - Production
    SQL>
    In Environment 2
    SQL> select * from v$version;
    BANNER
    Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
    PL/SQL Release 8.1.7.0.0 - Production
    CORE 8.1.7.0.0 Production
    TNS for 32-bit Windows: Version 8.1.7.0.0 - Production
    NLSRTL Version 3.4.1.0.0 - Production
    SQL>

    The answer is to extract the EXE into a temp directory, execute it, and delete it when you're done. For example:
    //This is the path *inside* the JAR file!
    InputStream in = getClass().getResourceAsStream("/resources/myprog.exe");
    OutputStream out = new FileOutputStream("myprog.exe");
    File file = new File("myprog.exe");
    int data;
    while((data = in.read()) >= 0) out.write(data);
    in.close();
    out.close();
    //Execute the EXE here using java.lang.Runtime.exec()
    if(file.exists()) file.delete();
    ...

  • JDBCaccess message ORA-01858: a non-numeric character was found where a num

    When trying to read a cloumn from a table using JDBC I get the above message
    Below is a copy of the code;
    Connection conn=null;
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
              System.out.println ("Driver registered"); // Print Driver Connected
              try
         {  //  <-- 1.1
              conn = DriverManager.getConnection("jdbc:oracle:thin:@***.******.**:1521:orcl", "********", "*******");
    // @machineName:port:SID, userid, password
              } // <-- 1.1
         catch (SQLException exc_1)
         {     // <-- 1.1
              //System.out.println("SQL Connect failed with: '" + exc_1.getMessage() + "'");
              exc_1.printStackTrace();
              System.exit(1);
         } //<-- 1.1
              System.out.println ("Connected - User/Password"); // Print Connected User/Password
    Statement stmt = conn.createStatement();
         System.out.println ("Instansiate SQL Statement "); // Print Instansiate
              String sql = "select BASE_CURRENCY_CODE from WH_ENT_MODEL.V_FX_DAILY_RATES ";
         try
         oracle.jdbc.driver.OracleLog.startLogging();
         PreparedStatement ps = conn.prepareStatement(sql);
         ResultSet rs = ps.executeQuery();
         oracle.jdbc.driver.OracleLog.stopLogging();
         System.out.println ("Create SQL Statement resultset "); // Print SQL Statement
    while (rs.next())
    System.out.println (rs.getString("BASE_CURRENCY_CODE")); // Print Base_Currency_Code
    stmt.close();
         catch(Exception e)
         e.printStackTrace();
                   System.exit(1);
    The error I get is;
    java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:153)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:330)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:287)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:742)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:930)
         at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1131)
         at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:983)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1257)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3467)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3512)
         at com.exchange.interfaces.dbAccess.main(dbAccess.java:69)
    This is a test class to prove we can access the database from within Java program.
    Any help much appreciated.

    Hi Deepak,
    I would first look at your session state, this should show what was passed to the procedure.
    I would suggest that if you have a select list showing a null value that that would be the issue as it passes %null% through.
    Regards
    Michael

Maybe you are looking for