Understanding NVL: INVALID NUMBER in NVL Function

Hi,
The below query is a part of a cursor which takes in p_po_number as input with datatype same as segment1 of po_headers_all (varchar2(20)). The columns event_system_id1 to event_system_id4 are varchar2(240). In most cases p_po_number will be null as the program is scheduled and the input parameter of p_po_number is not passed. In effect, for most cases, the below query will end like event_system_id1 = NVL(NULL,event_system_id1)
I am getting an error of INVALID NUMBER
SELECT TO_NUMBER (event_system_id1)
FROM c_fnd_intf_transact_q
WHERE event_system_id2 = :p_organization_code
AND event_system_id4 =
DECODE (:p_po_type,
:vgc_internal, 'XXX',
:vgc_standard
AND event_system_id1 =
NVL (p_po_number, event_system_id1)
I modified the query to
SELECT event_system_id1
FROM c_fnd_intf_transact_q
WHERE event_system_id2 = :p_organization_code
AND event_system_id4 =
DECODE (:p_po_type,
:vgc_internal, 'XXX',
:vgc_standard
AND event_system_id1 =
NVL (p_po_number, event_system_id1)
which still threw the same error thus ruling out the cause of the issue being that to_number leaving only the implicit conversions of NVL.
I further modified the query to
SELECT TO_NUMBER (event_system_id1)
FROM c_fnd_intf_transact_q
WHERE event_system_id2 = :p_organization_code
AND event_system_id4 =
DECODE (:p_po_type,
:vgc_internal, 'XXX',
:vgc_standard
AND p_po_number is not null
which gave me the desired result in a round about way.
What confuses me here is both p_po_number and event_system_id1 are of varchar2 type. Why am I getting the error of INVALID NUMBER here and why is NVL converting the second parameter NUMBER datatype when the first one is VARCHAR2 even though null.
I am working in Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production.
P.S: The column event_system_id1 is not restricted to store numbers alone. It also contains character values though I use it only for storing number as it is shared table.

Well, the expression
NVL (p_po_number, event_system_id1)
has NUMBER and VARCHAR2 elements, and you say "+P.S: The column event_system_id1 is not restricted to store numbers alone+" , and the documentation:
http://download.oracle.com/docs/cd/E14072_01/server.112/e10592/functions117.htm
says:
+The arguments expr1 and expr2 can have any data type. If their data types are different, then Oracle Database implicitly converts one to the other. If they are cannot be converted implicitly, the database returns an error. The implicit conversion is implemented as follows:+
+•If expr1 is character data, then Oracle Database converts expr2 to the data type of expr1 before comparing them and returns VARCHAR2 in the character set of expr1.+
+•If expr1 is numeric, then Oracle determines which argument has the highest numeric precedence, implicitly converts the other argument to that data type, and returns that data type.+
Exactly what is it you don't understand?
Regards, A

Similar Messages

  • Pipelined function with Union clause(Invalid Number(ORA-01722) error )

    Hi,
    I have a pipelined function.
    I am fetching the data with the use of a REF cursor.
    The query has two part: query1 and query2
    when I am opeing the cursor with query1 UNION query2,it is giving me Invalid Number(ORA-01722) error.
    but when I open the cursor separately for query1 and query2,I am getting the resultset for each of the query.
    query1 and query2 are running fine with UNION in the sql editor.
    But,when I put them into two variables (var1 :='query1' and var2:='query2' and try to open the cursor with var1 UNION var2 , it's giving me the error.
    But when I put query2 as 'Select ..... from dual' and then try to open the cursor for query1 UNION query2,
    then getting the result of query1 and one extra row for query2(dual).
    The FROM table set is same for query1 and query2..
    can anyone please help me , why this Invalid Number(ORA-01722) error is coming.

    query1 := 'SELECT to_char(st.store_no) STORE_NUMBER,pp.name PROGRAM_NAME, ''HBS'' DISPENSING_SYSTEM,
    pt.PATIENT_SRC_NO SOURCE_ID, null RX2000_PATIENT_IDENTIFIER, pt.last_name PATIENT_LAST_NAME, pt.first_name
    PATIENT_FIRST_NAME, to_char(LPAD (pppd.rx_number, 7, '' '')|| ''-''|| LPAD (pppd.refill_number, 2, 0)) RX_REFILL
    FROM
    pega_patient_program_dispense pppd,pega_patient_program_reg pppr,health_care_profs hcp1,
    health_care_profs hcp2,prescription_dispenses pd,prescriptions p, pega_program_status_reason ppsr ,master_doctors md,
    prescription_disp_orders pdo, hbs_shipment_extract hse,stores st,master_stores ms,pega_programs pp,patients pt,master_patients mpt
    WHERE
    pppr.referring_hcp_id=md.id(+) and md.dispensing_system_id=hcp1.hcp_id and
    pppr.ID=pppd.PEGA_PATIENT_PROGRAM_REG_ID and pppd.prescription_dispense_id=pd.id and pd.prescriptions_id=p.id and
    p.hcp_id=hcp2.hcp_id and ppsr.ID=pppd.PEGA_PROGRAM_STATUS_REASON_ID and pppd.prescription_dispense_id = pdo.prescriptions_dispenses_id(+) AND
    pdo.shipment_number = hse.shp_no(+) and pppd.store_id=ms.id and st.id=ms.dispensing_system_id and pppr.pega_program_id=pp.id
    and pppr.patient_id=mpt.id and pt.patient_id=mpt.dispensing_system_id and pppd.dispensing_system=''HBS'' and pp.name LIKE ''REV%''
    AND
    ((pppd.prescription_dispense_id IS NOT NULL AND pppd.quantity_dispensed > 0 AND pppd.reported_date IS NULL AND
    pppd.src_delete_date IS NULL AND ((pppr.program_specific_patient_code IS NULL ) OR (hcp1.last_name IS NULL) OR
    (hcp1.first_name IS NULL) OR (hcp2.first_name IS NULL) OR (hcp2.last_name IS NULL) OR (hcp2.address_1 IS NULL) OR
    (hcp2.city IS NULL) OR (hcp2.state_cd IS NULL) OR (hcp2.zip_1 IS NULL)OR (pppr.referral_date is NULL) OR
    (hcp1.state_cd IS NULL) OR (hcp1.zip_1 IS NULL)
    OR (hcp2.zip_1 IS NULL) OR (pppr.last_status_change_date IS NULL) OR (pppr.varchar_1 IS NULL) OR
    (pppr.varchar_7 IS NULL OR pppr.varchar_7 LIKE ''NOT AVAILABLE AT REFERRAL%'') OR (pppr.varchar_5 IS NULL OR
    pppr.varchar_5 LIKE ''NOT AVAILABLE AT REFERRAL%'')) ) AND ppsr.INCLUDE_ON_EXCEPTION_RPT_IND=''Y'')
    OR
    ((pppd.authorization_number IS NULL OR NVL(TRUNC(pdo.shipped_date),TRUNC(hse.shp_act_date_dt)) NOT BETWEEN
    TRUNC(pppd.date_1) AND TRUNC(pppd.date_2)) OR (pppd.varchar_4 IS NULL OR NVL(TRUNC(pdo.shipped_date),
    TRUNC(hse.shp_act_date_dt)) NOT BETWEEN TRUNC(pppd.date_3) AND TRUNC(pppd.date_5)))
    OR
    (pppr.pega_program_competitors_id IS NULL AND (ppsr.manufacturer_status=''TRIAGE'' AND ppsr.manufacturer_reason=''COMPETITOR''))
    OR
    (ppsr.manufacturer_reason IS NULL)
    query2 := ' SELECT ''150'' STORE_NUMBER,''test'' PROGRAM_NAME , ''RX2000'' DISPENSING_SYSTEM
    ,''01'' SOURCE_ID, null RX2000_PATIENT_IDENTIFIER, ''test'' PATIENT_LAST_NAME, ''test'' PATIENT_FIRST_NAME,
    ''rx01'' RX_REFILL
    FROM
    pega_patient_program_reg pppr,health_care_profs hcp1, pega_program_status_reason ppsr ,
    master_doctors md,stores st,master_stores ms,pega_programs pp,patients pt,master_patients mpt
    WHERE
    pppr.referring_hcp_id=md.id(+) and md.dispensing_system_id=hcp1.hcp_id and
    ppsr.ID=pppr.REFERRAL_STATUS_ID and st.store_type=''M'' and pppr.store_id=ms.id and st.id=ms.dispensing_system_id
    and pppr.pega_program_id=pp.id and pppr.patient_id=mpt.id and pt.patient_id=mpt.dispensing_system_id and pp.name LIKE ''REV%''
    AND
    ((((pppr.program_specific_patient_code IS NULL ) OR (hcp1.last_name IS NULL) OR (hcp1.first_name IS NULL) OR
    (pppr.referral_date is NULL) OR (hcp1.state_cd IS NULL) OR (hcp1.zip_1 IS NULL) OR (pppr.last_status_change_date IS NULL)
    OR (pppr.varchar_1 IS NULL) OR (pppr.varchar_7 IS NULL) OR (pppr.varchar_5 IS NULL OR pppr.varchar_5 LIKE
    ''NOT AVAILABLE AT REFERRAL%'')) ) AND ppsr.INCLUDE_ON_EXCEPTION_RPT_IND=''Y'')
    OR
    (pppr.pega_program_competitors_id IS NULL AND (ppsr.manufacturer_status=''TRIAGE'' AND ppsr.manufacturer_reason=''COMPETITOR''))
    OR
    (ppsr.manufacturer_reason IS NULL)
    AND
    pppr.id NOT IN(select pppd.PEGA_PATIENT_PROGRAM_REG_ID from PEGA_PATIENT_PROGRAM_DISPENSE pppd)';
    BUT IF I put
    query2 := ' SELECT ''150'' STORE_NUMBER,''test'' PROGRAM_NAME , ''RX2000'' DISPENSING_SYSTEM
    ,''01'' SOURCE_ID, null RX2000_PATIENT_IDENTIFIER, ''test'' PATIENT_LAST_NAME, ''test'' PATIENT_FIRST_NAME,
    ''rx01'' RX_REFILL
    FROM DUAL';
    then it is giving result.

  • NVL function's strange behaviour

    Hi,
    I have a sql statement (listed below) that uses NVL function which returns either the business name of branch name depending on whether the business name is null or not. It also uses the branch_name pl/sql function that returns the name of the branch.
    What I found strange was that it executes the branch_name function even when the business_name is not null. It was my understanding that nvl returns expr1 if it's not null, and expr2 if expr1 is null. I don't want it to execute the branch_name function if business_name exists. Is it possible using NVL, or do I need to use DECODE to achieve that? p_record_id is a parameter that I pass to the function containing the sql statement e.g., p_record_id=10.
    SELECT nvl( business_name, branch_name( p_record_id) ) "Name"
    FROM entity
    WHERE record_id = p_record_id;
    Thanks
    Vic

    Marc,
    Thanks for looking into it.
    I just ran the code using DECODE and it seems that it executes the function only when the condition is true, which is exactly what I want. It won't execute the function if the condition is false, e.g., in the code below if the business_name is null then it executes the branch_name function, other wise it returns the business_name.
    SELECT DECODE ( business_name,
    null, branch_name( p_record_id ),
    business_name ) "Name"
    FROM entity
    WHERE record_id = p_record_id;
    Vic

  • NVL Function on CLOB data type

    Hi all,
    I am not able to use the NVL function over clob..please suggest me a way to do the data validation of the CLOB in sql ....
    below is the query i was using...
    select t1.pic_name,t2.pic_name
    from table1 t1,table2 t2
    where nvl(t1.picture_message,'X') <> nvl(t2.picture_message,'X');i am getting the following error....
    ORA-00932: inconsistent datatypes: expected - got CLOBThanks
    Rede

    Your problem is not NVL but rather comparing CLOBs:
    SQL> desc tbl1
    Name                                      Null?    Type
    ID                                                 NUMBER
    X                                                  CLOB
    SQL> desc tbl2
    Name                                      Null?    Type
    ID                                                 NUMBER
    X                                                  CLOB
    SQL> select  nvl(x,'NULL CLOB')
      2    from  tbl1
      3  /
    NVL(X,'NULLCLOB')
    NULL CLOB
    SQL> select  *
      2    from  tbl1,
      3          tbl2
      4    where tbl1.x = tbl2.x
      5  /
      where tbl1.x = tbl2.x
    ERROR at line 4:
    ORA-00932: inconsistent datatypes: expected - got CLOB
    SQL> SY.

  • Performance Hit Due to NVL() Function

    Hi,
    I am from dev project team,we are facing a performance hit due to NVL() function,pls give a solution to resolve this issue.
    the below is my function which i created to calculate some efforts.
    create or replace function check_function(
    v_deal_detail ,
    v_tower ,
    v_subtower,
    v_location ,
    v_client_role ,
    v_emp_category ,
    v_year ,
    v_state )
    return number
    is
    v_trans_offshore_efforts number(30,8) default 0;
    v_stdy_offshore_efforts number(30,8) default 0;
    begin
    if v_state =1
    or v_state is null
    then
    begin
    select nvl(sum(decode (d.loc_type_id,
    crmuat_global_constant_pkg.GLB_OFFSHORE,
    s.trans_efforts,
    0)),0)
    into v_trans_offshore_efforts
    from prc_calc_trans_fte_dtls_t s, prc_deal_dtl_loc_dtls_t d
    where s.deal_detail_id= d.deal_detail_id
    and s.tower_id = d.tower_id
    and s.location_id = d.location_id
    and s.deal_detail_id = v_deal_detail
    and s.client_role_id = nvl(v_client_role,s.client_role_id)
    and s.emp_category_id = nvl(v_emp_category,s.emp_category_id)
    and s.tower_id = v_tower
    and s.subtower_id = nvl(v_subtower,s.subtower_id)
    and s.location_id = nvl(v_location,s.location_id)
    and s.year_no = v_year;
    exception
    when no_data_found
    then
    v_trans_offshore_efforts := 0;
    end;
    end if;
    if v_state = 1
    then
    return v_trans_offshore_efforts;
    end if;
    end;
    pls give me a solution.
    Regards,
    shinu

    {message:id=9360003}

  • Using insert command in NVL function

    How can we use insert command in a NVL function
    exapmle : INSERT INTO employee
    VALUES ( (NVL ( (SELECT emp_id
    FROM employee
    WHERE emp_name LIKE 'Test'),
    (insert into employee values((select max(emp_id)+1 from employee),'Test')))));
    I mean i will check for the record to exist in the table and if not exist i will add it to the table.

    998504 wrote:
    How can we use insert command in a NVL function
    exapmle : INSERT INTO employee
    VALUES ( (NVL ( (SELECT emp_id
    FROM employee
    WHERE emp_name LIKE 'Test'),
    (insert into employee values((select max(emp_id)+1 from employee),'Test')))));
    I mean i will check for the record to exist in the table and if not exist i will add it to the table.The first thing caught my eye is this
    max(emp_id) +1A real bad piece of code. Never do that. Ever thought about multi user environment? Use a SEQUENCE.
    If you want EMP_NAME to be unique (Which looks strange to me), then just add a UNIQUE constraint. You dont try to do what oracle already does really well.

  • How to use NVL Function

    hi,
    i want to use nvl Function in that Quary
    select f_words(SUM(a.AMOUNT)+sum(a.vat_amount) +
    nvl( (select sum(b.LABOUR_AMT)+sum(b.service_tax_amt)
    from LAB_WORK_DTL b
    where a.bill_no =b.bill_no), 0)
    )) as t
    from TRANSACTION_DETAILS a
    where a.bill_no =:P42_bill_no
    group by a.BILL_NO;
    i am using NVL in that Quary Like This
    select f_words*(nvl(S*UM(a.AMOUNT)+sum(a.vat_amount) +
    nvl( (select sum(b.LABOUR_AMT)+sum(b.service_tax_amt)
    from LAB_WORK_DTL b
    where a.bill_no =b.bill_no), 0)
    )) as t
    from TRANSACTION_DETAILS a
    where a.bill_no =:P42_bill_no
    group by a.BILL_NO;
    I want to use NVL Function In BOLD
    How Can I use NVL Functiion.
    Thanks
    Edited by: Manoj Kaushik on Mar 25, 2010 5:55 AM

    hi,
    select f_wordsl(SUM(a.AMOUNT)+sum(a.vat_amount) +
    nvl( (select sum(b.LABOUR_AMT)+sum(b.service_tax_amt)
    from LAB_WORK_DTL b
    where a.bill_no =b.bill_no), 0)
    )) as t
    from TRANSACTION_DETAILS a
    where a.bill_no =:P42_bill_no
    group by a.BILL_NO;
    i have two tables Bill no is comman field in both tables if i have not enter value in any one of the table .
    so how can i show Total amount in words if Bill NO are not in any one table.
    Thanks

  • Compilation problems using NVL function in Pro*C subselect

    I have come across a weird oracle problem. When I execute the following query in SQLPlus it works but when
    I include it in Pro*C code in a EXEC SQL statement it gives syntax errors and fails to compile. Any idea what I am doing wrong.
    SELECT DISTINCT
         A.ID_PERSON,
         C.ID_STAGE_PERSON_LINK ,
         A.NM_PERSON_FULL,
         A.NBR_PERSON_AGE,
         A.ADDR_PERSON_ST_LN_1,
         A.ADDR_PERSON_CITY,
         A.ADDR_PERSON_ZIP,
         A.CD_PERSON_STATE,
         A.CD_PERSON_COUNTY,
         A.NBR_PERSON_PHONE,
         C.CD_STAGE_PERS_REL_INT
         FROM
              PERSON A,
              STAGE_PERSON_LINK C
         WHERE
         C.ID_CASE = 88776721
         AND          A.IND_INVALID_PERS IS NULL
         AND          C.CD_STAGE_PERS_TYPE = 'PRN'
         AND          C.ID_PERSON = A.ID_PERSON
         AND C.ID_STAGE_PERSON_LINK =
    NVL (
                   (SELECT MAX(F.ID_STAGE_PERSON_LINK)
                   FROM STAGE_PERSON_LINK F
                   WHERE F.ID_PERSON=C.ID_PERSON
                   AND F.ID_CASE = C.ID_CASE
                        AND F.CD_STAGE_PERS_TYPE = 'PRN'
                        AND F.CD_STAGE_PERS_REL_INT IS NOT NULL)
                   (SELECT MAX(G.ID_STAGE_PERSON_LINK)
                   FROM STAGE_PERSON_LINK G
                   WHERE G.ID_PERSON=C.ID_PERSON
                   AND G.ID_CASE = C.ID_CASE
                        AND G.CD_STAGE_PERS_TYPE = 'PRN')
    AND A.ID_PERSON NOT IN
    SELECT S.ID_PERSON
    FROM STAGE_PERSON_LINK S,STAGE T
    WHERE S.ID_CASE = C.ID_CASE
    AND S.ID_CASE = T.ID_CASE
    AND S.ID_STAGE = T.ID_STAGE
    AND T.CD_STAGE &lt;&gt; 'INT'
    MINUS
    SELECT H.ID_PERSON
    FROM STAGE_PERSON_LINK H, STAGE F
    WHERE H.ID_CASE = F.ID_CASE
    AND H.ID_STAGE = F.ID_STAGE
    AND H.ID_CASE = C.ID_CASE
    AND H.CD_STAGE_PERS_ROLE &lt;&gt; 'XE'
    AND F.CD_STAGE &lt;&gt; 'INT'
    This query returns data when run in sqlplus.When used in a Pro*C C program and compiled the precompiler complains with syntax errors when used with EXEC SQL DECLARE CLSS82D_CURSOR CURSOR FOR &lt; query above &gt;.However removing the NVL function and retaining the subselect clause compiles but that is not what I want to do.
    Syntax error at line 262, column 20, file clss82d.pc:
    Error at line 262, column 20 in file clss82d.pc
    SELECT MAX( F.ID_STAGE_PERSON_LINK )
    ...................1
    PCC-S-02201, Encountered the symbol "MAX" when expecting one of the following:
    ( ) * + - / . @ | at, day, hour, minute, month, second, year,
    The symbol "(" was substituted for "MAX" to continue.
    Syntax error at line 263, column 10, file clss82d.pc:
    Error at line 263, column 10 in file clss82d.pc
    FROM STAGE_PERSON_LINK F
    .........1
    PCC-S-02201, Encountered the symbol "FROM" when expecting one of the following:
    , ) * + - / | at, day, hour, minute, month, second, year,

    Pro*C works bit differently tha sqlplus. try removing the blank line after
    SELECT MAX(G.ID_STAGE_PERSON_LINK)
    FROM STAGE_PERSON_LINK G
    WHERE G.ID_PERSON=C.ID_PERSON
    AND G.ID_CASE = C.ID_CASE
    AND G.CD_STAGE_PERS_TYPE = 'PRN')
    good luck,
    Gauranga

  • NVL function issue

    Hello All,
    I have a strange problem with a NVL function. In one of the view I am using a NVL fuction like this "NVL(doc_id,'-1') doc_id' and when I am
    querying the view based on the doc_id it is taking more time because of the this NVL function.I removed the same and tested it is coming out withing milli secs.
    Is there any way or any other function I can use.one more thing DOC_ID in the table is a VARCHAR2 field.
    Please help me with this.
    Best regards,
    Pavan Patil

    Tried Case not working ......
    Please find the query (Table names and joines mentioned are not proper ones) ---
    SELECT DECODE (tdoc.case_ver_no,
    -1, -1,
    c.uwrt_case_tid
    ) case_tid,
    c.case_id case_id, c.case_ver_no case_version_no,
    c.prft_cntr_sid profit_cntr,
    c.jnt_life_qualf_cd joint_life, c.co_id co_id,
    (SELECT co_lnm
    FROM t
    WHERE cd = c.cd) co_lnm,
    ald.given_nm first_name, ald.mid_nm middle_name,
    ald.family_nm last_name, ald.life_idx_id life_id,
    ald.sex_cd gender, al.doc_handle_id doc_handle_id,
    alb.bnft_cd benefit_type,
    alb.propsl_si_amt propsl_fc_amt, c.crncy_cd crncy_cd,
    c.indiv_grp_cd individual_group_code,
    c.assmnt_typ_cd assessment_type,
    c.cli_ref_id client_ref,
    DECODE (TO_CHAR (tdoc.case_ver_no),
    '-1', '-1',
    c.uwrt_id
    ) underwriter_id,
    c.bu_cd bu_cd, al.assmnt_age_offset age,
    (SELECT alb.bnft_cd rider_type
    FROM te al,
    tt alb,
    tuwrt_case c
    WHERE alb.main_bnft_ind <> 1
    AND al.atid = alb.atid
    AND al.utid = c.utid
    AND c.case_id = c.case_id
    AND ROWNUM = 1) rider_type,
    (SELECT stat_cd
    FROM tat
    WHERE uwrt_case_tid = c.uwrt_case_tid
    AND seq_no =
    (SELECT MAX (ucs1.seq_no)
    FROM tat ucs1
    WHERE ucs1.uwrt_case_tid = c.uwrt_case_tid))
    status,
    NVL(tdoc.doc_id,'-1') doc_id, tdoc.doc_ttl doc_ttl,
    tdoc.doc_typ_cd doc_typ_cd,
    tdoc.bof_doc_catg_cd bof_doc_catg,
    tdoc.doc_prim_catg_cd doc_prim_catg,
    tdoc.doc_lang_cd doc_lang_cd, tdoc.doc_nm doc_nm,
    tdoc.doc_crte_meth_cd doc_crte_meth_cd,
    tdoc.doc_del_stat_cd doc_del_stat_cd,
    tdoc.doc_fmt doc_fmt,
    tdoc.doc_lock_user_id doc_lock_user_id,
    tdoc.doc_lock_ts doc_lock_ts, tdoc.doc_ver doc_ver,
    tdoc.doc_size doc_size,
    tdoc.doc_ind_stat_cd doc_ind_stat_cd,
    tdoc.doc_ind_user_id doc_ind_user_id,
    DECODE (tdoc.doc_ind_loc_cd,
    'CA', 'CAN',
    'CARB', 'CAN',
    tdoc.doc_ind_loc_cd
    ) doc_ind_loc_cd,
    tdoc.last_upd_user_id last_upd_user_id, tdoc.upd_ts,
    TO_DATE
    (TO_CHAR (TO_DATE (tdoc.doc_recv_dt,
    'yyyymmddhh24miss'
    'MM/DD/YYYY HH24:MI:SS'
    'MM/DD/YYYY HH24:MI:SS'
    ) doc_recv_dt,
    TO_DATE
    (TO_CHAR (TO_DATE (tdoc.doc_attch_dt,
    'yyyymmddhh24miss'
    'MM/DD/YYYY HH24:MI:SS'
    'MM/DD/YYYY HH24:MI:SS'
    ) doc_attch_dt
    FROM tt c,
    ttl,
    ttd,
    ttft alb,
    ttoc tdoc
    WHERE al.u_tid(+) = c.u_tid
    AND ald.a_tid(+) = al.a_tid
    AND alb.astid(+) = al.astid
    AND tdoc.doc_handle_id(+) = al.doc_handle_id
    AND alb.main_ind(+) = 1
    AND NVL (tdoc.doc_del_stat_cd, 'XX') != 'DELETD'

  • NVL Function and Truncate Function in Template Builder

    Hi Guys,
    How would I use NVL function and Truncate function in the Word Template Builder.
    These functions do not work in the Query Builder when i use SQL Query as the Dataset while creating a report.
    I could not find examples in the Publisher Guide either.
    Thanks
    rkingmdu

    Hi
    How can you not use the functions in your query? Does the builder return an error? ow about just pasting your query into the report definition does the nvl/trunc work then ?
    Regards
    Tim
    http://blogs.oracle.com/xmlpublisher

  • Problem Using NVL Function

    I ran across a problem with the format of an ASCI output file of an SQL script. The problem I have is with handling a particular column that contains account numbers. The column is defined with 8 characters. However not every entry has data. I have several fields that don't have any information.
    Originally in my script I had the following line that made the script fail:
    LPAD(TO_CHAR(TO_NUMBER(konten_nr)),8,'0'),
    I then changed the line to the following: (The script ran but now I notice that the formatting is wrong)
    LPAD(TO_NUMBER(LTRIM(konten_nr)),8,'0'),
    I attempted to use the NVL function that will return a value when there is nothing in the column field but it doesn't work. Does anyone know what I'm doing wrong?
    LPAD(NVL(TO_CHAR(TO_NUMBER(konten_nr),'FM999999999'),'0'),8,'0'),

    what is exactly your problem ?
    you want to translater " 1234" in "00001234" ? then simply use to_char(konten_nr,'FM00000000') .
    You want to translate " 1 1 1 1" in "01010101", then use replace(konten_nr,' ','0')
    Give us some samples

  • There is an invalid number of arguments found in the function '@PARENTVAL

    Hi
    In a prior version of Hyperion, we had a business rule which pushed values down to to a child member
    +Fix ( EE105, , @Children("FX entry"), &District, @UDA("Cost centre - primary", "DuplicateMbr"),C3090,[Opex_WriteScenario], [Opex_WriteVersion],&CurYear: &YearPlus6)+
    Month = @PARENTVAL("Cost Centre");
    Endfix;
    We are moving across to Calc Manager in version 11.1.2.1 and the problem is that I now get the following error message:
    An error occurred in: Calc Opex CC
    There is an invalid number of arguments found in the function '@PARENTVAL(Cost Centre)'. .
    Your assistance is appreciated.
    Cheers

    Check if you can validate this script again Essbase, I am sure you will be able to.
    If I remember correctly there were few functions missing in calc manager which were fixed in the patches released.
    Try it on the latest patch:
    Patch 14265667: Patch Set Update: 11.1.2.1.104 for Oracle Hyperion Calculation Manager
    Cheers..!!!
    Rahul S.

  • Binding problem when using NVL function

    Hello.
    I have a problem with my ADF application (11.1.2.1).
    I use VO with a query (database view) - pivot table.
    If i use where clause like table.attr = :p_attr, everything works ok.
    If i use where clause like table.attr = NVL (:p_attr, table.attr) and put a value in :p_attr (executeWithParam) , query executes as if there is a null value.
    Debug console shows:
    Binding null of type 12 for "p_attr".
    Query with NVL works ok in sqldeveloper.
    But in jdev, as if the table attribute isn't bind to bind variable.
    If a just remove NVL function, it works.
    Any idea?
    Thanks.
    Regards
    Edited by: DejanH on Oct 6, 2011 1:32 PM

    Hello.
    I enter 50 in p_depart parameter and click "ExecuteWithParams". Query is executed and shows records (pivot table).
    But if i look at the log window i see that an empty query was executed first.
    <OracleSQLBuilderImpl> <bindParamValue> [427] Binding null of type 12 for "p_depart"
    <OracleSQLBuilderImpl> <bindParamValue> [428] Binding null of type 12 for "p_job"
    <OracleSQLBuilderImpl> <bindParamValue> [429] Binding null of type 12 for "p_hire_od"
    <OracleSQLBuilderImpl> <bindParamValue> [430] Binding null of type 12 for "p_hire_do"
    Then, it is autoexecuted for the second time with parameter set to the value i inserted.
    <OracleSQLBuilderImpl> <bindParamValue> [470] Binding param "p_depart": 50
    <OracleSQLBuilderImpl> <bindParamValue> [471] Binding null of type 12 for "p_job"
    <OracleSQLBuilderImpl> <bindParamValue> [472] Binding null of type 12 for "p_hire_od"
    <OracleSQLBuilderImpl> <bindParamValue> [473] Binding null of type 12 for "p_hire_do"
    The same happens in our query. But ours is much more complex and it takes a lot of time to first execute "empty" query and then with inserted parameter.
    We cannot use it.
    It looks like bug.
    Regards
    Edited by: DejanH on Oct 11, 2011 6:52 AM

  • To_number function return Invalid number

    Dear All,
    We have problem recently regarding one of our query that using to_number function. It worked smoothly for 4-5 years until recently our client complaints that the query is returning error ORA-01722: invalid number.
    This is the SQL Script -> SELECT * FROM <table_name> WHERE to_number(b) between :param1 and :param2;
    * Column b is defined as VARCHAR2(20)
    First thing that come to my mind is this error is due to invalid value entered by user. Using the solutions provided by users in this forum and internet, I created SQL a function that checks whether the value is numeric or not.
    So, when I run the query (+SELECT b from <table_name> WHERE is_numeric(b) = 0 AND ROWNUM < 20+) this is the result that I get.
    b
    251567
    251568
    251569
    251570
    251571
    (Up to 11 record; value from 251567 - 251577)
    Is there any limitation on the maximum value that can be converted using to_number* function?*
    I have search the solutions over the internet and I accept the solution/recommendation that we should not store numeric value on varchar/char column; but I hope somebody can explain why I can't use to_number to convert the above figures to numeric, because when I execute SELECT to_number('251567') FROM DUAL it doesn't returned any error)
    Thank you in advance for any help or clarification on this issue.
    Edited by: user5535734 on Apr 16, 2012 10:46 PM

    Funny answer, Billy!
    Sounds like: The world is evil, so you have 3 choices:
    1. Implement a good world
    2. Be a bad guy, too
    3. Live with that bad world and its consequences
    I guess, 930427 only asked for some protection...
    If one has to deal with two external system to move data from one to another - you can't change either of these systems (1 or 2) and you can't afford to fail (3).
    Sometimes blanks inside the numeric values are the reason for INVALID NUMBER, i.e. "123 456".
    as simple
    to_number(replace(VALUE_CHAR, ' ', NULL))
    may help...

  • ORA-01722: invalid number while using TO_CHAR function.

    Hi All,
    I was using this query from around past 1 year and everything was working fine.
    select to_char ( '2012/12/23','YYYY/MM/DD') from dual;
    how ever from monday onwards , this is returning me with the following error.
    ORA-01722: invalid number
    The NLS_DATE_FORMAT is DD-MON-RR in my oracle 11g version.
    Please help me regarding this.

    Your date is in literal & your intended format so no need to format it again.
    select to_char ( '2012/12/23','YYYY/MM/DD') from dual;
    same as
    select '2012/12/23' from dual;I don't know your need so same code to work!!!
    select to_char(to_date('2012/12/23','YYYY/MM/DD'),'DD/MM/YYYY') from dualsunnymoon wrote:
    where vale for ? is coming as '2011/12/23' from java.
    the whole application has to be changed and retested.
    >
    It it comes as a text convert it to date TO_DATE('2011/12/23','YYYY/MM/DD') to use in comparison operators like =, != , > , < etc. Comparison operators used taking date as literal will give you wrong result.
    Better to do it right even it takes huge effort.
    Edited by: Lokanath Giri on ३ जनवरी, २०१२ १२:०६ अपराह्न

Maybe you are looking for

  • Problem in converting text to image.

    Hi I am trying to convert a text to image. The code for the same is pasted below. The problem is how do I change the background color. No matter what color I give with Graphics2D object, the background is always black. I want a white background. publ

  • Configure: error: Cannot find php-config

    After security update 2008-002 for Leopard, the PHP module builder stops, because the PHP version running on the machine doesn't match the header files from the PHP-developer part. More info see: http://www.naquah.net/blog/dennis/2008/03/20/how-to-ge

  • Using ios 7.0.4 but i want ios 6's music player back!

    hello there. i just bought an ipod touch 5th generation a week ago. i love music and i collect all the albums of artists i like. i bought my ipod primarily to use as an mp3 player. i'm so obsessed with mp3 tags, covers and lyrics. I behave them like

  • Manul Tasklist assignment to 03 inspection lot

    Hi All, I need to assign the task list (Routing – Master Recipe, hence we are using Process Order) manually to 03-inspection type generated lots. I have checked the possibilities in the in IMG, but the option is not available there in for this partic

  • How to get link_status in solaris 10?

    ndd -get $interface link_status used to show link status of an interface. but it is no longer available in solaris 10. anyone know the alternative?