How to compare varchar with number

i am doing one report for that am passing receipt number(from , to) as parameters
if i compare for that table i am getting output.
select receipt_num from rcv_shipment_headers rsh
where to_number(rsh.receipt_num) between nvl(:P_RECEIPT_FROM,rsh.receipt_num) and nvl(:P_RECEIPT_TO,rsh.receipt_num)
but when i am using in below query it is getting error "Invalid Number"
select rsh.receipt_num
, sum(rs.quantity)
, rs.unit_of_measure
, rct.transaction_date "Date of Entry"
, pov.vendor_name
, msi.segment1 "Item Code"
, msi.description "Item Description"
from rcv_transactions rct
, rcv_shipment_headers rsh
, rcv_shipment_lines rsl
, po_vendors pov
, mtl_system_items_b msi
, rcv_supply rs
where rsh.shipment_header_id=rct.shipment_header_id
and rsh.shipment_header_id=rsl.shipment_header_id
and rsl.shipment_line_id=rct.shipment_line_id
and rsh.vendor_id=pov.vendor_id
and rsl.item_id=msi.inventory_item_id
and msi.organization_id=106
and rsl.shipment_line_id=rct.shipment_line_id
and rct.transaction_id=rs.rcv_transaction_id
and to_number(rsh.receipt_num) between nvl(:P_RECEIPT_FROM,rsh.receipt_num) and nvl(:P_RECEIPT_TO,rsh.receipt_num)
and rct.organization_id=nvl(:P_ORG_ID,rct.organization_id)
and rsh.vendor_id=nvl(:P_Vendor_Name,rsh.vendor_id)
and rct.inspection_status_code='NOT INSPECTED'
group by rsh.receipt_num
, rs.unit_of_measure
, rct.transaction_date
, pov.vendor_name
, msi.segment1
, msi.description
plese help to solve
Thanks & Regards
Adina

The problem lies here:
and rsh.vendor_id=nvl(:P_Vendor_Name,rsh.vendor_id)How can you compare vendor_name with vendor_id????????????
SQL> select * from po_vendors where vendor_id = NVL(&p_vendor_name,vendor_id);
Enter value for p_vendor_name: 'AAAA'
old   1: select * from po_vendors where vendor_id = NVL(&p_vendor_name,vendor_id)
new   1: select * from po_vendors where vendor_id = NVL('AAAA',vendor_id)
select * from po_vendors where vendor_id = NVL('AAAA',vendor_id)
ERROR at line 1:
ORA-01722: invalid number
SQL> Message was edited by:
user605919

Similar Messages

  • Compare varchar with number

    Hi,
    I had a problem as below:
    Create table Test (col1 varchar2(20));
    insert into Test (col1) values ('123');
    insert into Test (col1) values ('ABC');
    select * from Test Where col1 = 123;
    I get following error:
    ORA-01722: invalid number
    select * from Test Where col1 = '123';
    select successful.
    But when I perform following step:
    Delete from Test;
    insert into Test (col1) values ('123');
    insert into Test (col1) values ('234');
    insert into Test (col1) values ('345');
    select * from Test WHERE col1 = 123;
    Select successful.
    I just query why I can't compare 1 number to a varchar2 column when there is character record in that column. I'm using Oracle DB 10.2.0.2 and I believe oracle should be allow implicit convert between number char varchar2. Do I miss anything to make my first select statement return with the record I need?
    Thank in advance.
    Eng Khoon

    Hi,
    I had some new input for this post i created yesterday.
    Let say i create a new table with 2 column
    Create table test (col1 varchar2(30), col2 varchar2(30))
    I insert following data into the table
    col1 col2
    123 ABC
    ABC BCD
    234 ABC
    345 ABC
    BCD BCD
    I perform following select statement from above data:
    select * from test where col2='ABC' and col1=123
    I perform this test in my local DB (10.2.0.2) and I can successful selected out 3 rows;
    But when i perform same select statement in my server DB (10.2.0.2), it complain ORA-01722: invalid number
    Please help! Anything I can set so that my server also allow to perform the similar select statement?
    Thanks.

  • Trying to compare item with number in PL/SQL report

    Hi,
    I'm using for my report SQL Query (PL/SQL Function body returning SQL Query). And I found that I can't to write:
    if v('ITEM_NAME')=1 then ..., because it is 'missing expression' error.
    I can only
    if v('ITEM_NAME') IS NULL then ...
    or
    if v('ITEM_NAME') IS NOT NULL then ...
    Why I can't to compare item value, for example, with number?
    Thanks!
    Karina.

    Hi,
    I'm using my own htmldb installation. The reports' code is:
    DECLARE
    q varchar2(10000);
    v_lesst_str varchar(255);
    v_lesst_stmt_2 VARCHAR2(100):='select lesst_id from lesson_types';
    v_meas_str varchar(255);
    v_meas_stmt_2 VARCHAR2(100):='SELECT meas_id FROM project_measures';
    BEGIN
    if v('P16_LESSONS_TYPE') is null THEN v_lesst_str:=v_lesst_stmt_2;
    ELSE v_lesst_str:=v('P16_LESSONS_TYPE');
    END IF;
    if v('P16_PRO_MEASURE') is null THEN v_meas_str:=v_meas_stmt_2;
    ELSE v_meas_str:=v('P16_PRO_MEASURE');
    END IF;
    q:='SELECT distinct ul.title, ul.summary, ul.details, ul.less_id
    FROM user_lessons ul
    WHERE ul.lesst_lesst_id IN ('||v_lesst_str||')
    AND ul.meas_meas_id IN ('||v_meas_str||')';
    return q;
    END;
    The error is occurred when I'm trying to compare item with number, for example, v('P16_LESSONS_TYPE')=1 in if condition.
    And the errors' text is next:
    "#1 error has occurred
    Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00936: missing expression"
    Karina.

  • ORA-01722: invalid number error when comparing varchar and number

    Hi,
    We are upgrading our databases to 10g and have issue with the below query
    SELECT VALUE FROM table1 WHERE SUBSTR (VALUE, 10) = 1.
    In table1, VALUE is the column name and it will have data ending with number. ex: SIGNATURE1, SIGNATURE2, SIGNATURE3, SIGNATURE4....SIGNATURE9.
    As output of substr is varchar, Is comparing it with number throwing the error?
    If so, the same query is working perfect in another 10g database which we migrated into.
    Please help.
    Thanks,
    Madhuri

    I think its data issue. may be some data is defected where string after 10th place contains non numeric character and you are trying to compare it with 1.
    My test
    Case 1
    Below code works fine, since all 10th place characters are digits, so can be compared with 1
    with c as
    (select 'SIGNATURE1' n from dual union all
    select 'SIGNATURE2' from dual union all
    select 'SIGNATURE3' from dual union all
    select 'SIGNATURE9 ' from dual )
    select n,substr(n,10) from c where substr(n,10)=1
    Case 2
    with c as
    (select 'SIGNATURE1' n from dual union all
    select 'SIGNATURE2' from dual union all
    select 'SIGNATURE3' from dual union all
    select 'SIGNATURE9a' from dual ) -------non numeric character
    select n,substr(n,10) from c where substr(n,10)=1
    This query shows error because , after 10th place there exists a non numeric character

  • Attempt to compare nil with number

    When trying to open a plugin via File->Plugin-extra for a missing photo, a message "Sorry, Lightroom could not complete your request. The reason code appears below: ?:0: attempt to compare nil with number". Plugin was Photo Frame 4.6 from OnOne Software. Same happens when opening any plugins of the same 5.5 Suite.
    MAC OS 10.6.5, Lightroom 3.3.

    The plugin could be intending to interact with image metadata or something else, which is still present even if the physical image file is missing. That is, a plugin may not need actual access to a managed image file.
    If I understand what you are doing correctly, Lr has no idea what the plugin is going to do with the reference it has been handed. It knows the target file is missing and should have updated the UI to indicate this, but this does not really have anything to do with what some arbitrary plugin might do with an API reference to this same managed image.
    It looks like the error is being thrown in the plugin Lua code, and Lr is just reporting this fact. The plugin might want to check that the API ref it has been handed is actually sound, and recover more gracefully instead of assuming that the managed image file actually exists.
    [Later]
    For example, a plugin can use the photo:checkPhotoAvailability() API call since v2.0 to determine if the photo is believed to be present on disk.

  • How to Compare date with Current system date in XSLT mapping.

    Hello Experts
    In a XSLT mapping program, I hava a filed, ZZOB which is giving some date.
    which I need to compare with the current date.
    Condition-
    ZZOB is greater than current date or ZZOBLIG = NULL
    Then go further statements.
    how can i campare with the current date?
    Please help.
    Thanks
    Balaprasad

    This example may help:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    <xsl:param name="currentDate"/>
        <xsl:variable name="firstDate" select="concat(substring($currentDate, 1,4),substring($currentDate, 6,2),substring($currentDate, 9,2))"/>
        <xsl:template match="/">
            <xsl:apply-templates select="//item"/>
        </xsl:template>
        <xsl:template match="item">
            <xsl:variable name="secondDate" select="concat(substring(submissionDeadline, 1,4),substring(submissionDeadline, 6,2),substring(submissionDeadline, 9,2))"/>
            <xsl:choose>
            <xsl:when test="$firstDate &gt; $secondDate">
                <xsl:call-template name="late"/>
                </xsl:when>
                <xsl:when test="$firstDate &lt; $secondDate">
                    <xsl:call-template name="ontime"/>
                </xsl:when>
                <xsl:when test="$firstDate = $secondDate">
                    <xsl:call-template name="same"/>
                </xsl:when>
                <xsl:otherwise>Monkeys<br /></xsl:otherwise>
            </xsl:choose>
        </xsl:template>
        <xsl:template name="ontime">
            This is on time
        </xsl:template>
        <xsl:template name="late">
            This is late
        </xsl:template>
        <xsl:template name="same">
            This is on time
        </xsl:template>
    </xsl:stylesheet>

  • HOw to compare column with column using JCheckBox

    i have declare 4 JCheckBox which is a,b,c,d
    How to compare this value with the one in the database?

    Hi
    Say myCheckbox is the checkbox I want to test.
    The example below uses its state to query the database:
    String value;
    Statement stmt;
    ResultSet rset;
    value = myCheckbox.isSelected() ? "Y" : "N";
    stmt = conn.createStatement();
    rset = stmt.executeQuery("select column2 from table where column2 = "+value);
    In this case, the database colum is character, with the possibles values of Y or N.
    hth
    Luis Cabral

  • How to compare date with thr current date

    Hi,
    I have an inout string which is in date format(dd/mm/yyyy hh:mm:ss) .
    what i need to do is comparing this date string with the current date. if my input string is less than current date , then display error message..
    how to do this?
    regards

    Excellent suggestions from all of you people!
    finally i got the solution
    code is:
    import java.util.*;
    import java.text.*;
    public class TestDate {
      public static void main(String args[]){
        TestDate a = new TestDate();
      TestDate() {
        String DATE_FORMAT = "dd/MM/yyyy hh:mm:ss";
         Date today = new Date();
         Date myDate=null;
        java.text.SimpleDateFormat sdf =
             new java.text.SimpleDateFormat(DATE_FORMAT);
         try{
         myDate = sdf.parse("01/06/2006 00:00:00");
         }catch(Exception e) {System.out.println(e);}
        Calendar c1 = Calendar.getInstance();
        Calendar c2 = Calendar.getInstance();
        c1.setTime(today);
        c2.setTime(myDate1);
        System.out.print(sdf.format(today));
        System.out.print(sdf.format(c1.getTime()));
        if (c1.before(c2)) {
           System.out.print(" is before ");
        if (c1.after(c2)) {
           System.out.print(" is after ");    
        if (c1.equals(c2)) {
           System.out.print(" same as ");    
    System.out.print(sdf.format(c2.getTime()));
      }

  • How to compare date with char

    hi
    i am having date from and date to feilds in my overtime element.i want to do the validation on these dates the the dates do not overlap or duplicated.the input value date from and date to are stored in database as varchar2 in the format yyyy/mm/dd 00:00:00. Now if i am trying to compare entered date with these dates i am getting literal does not match format string or date picture ends before....Can any body tell me what to do.
    Regards

    user10502390 wrote:
    hi
    i am having date from and date to feilds in my overtime element.i want to do the validation on these dates the the dates do not overlap or duplicated.the input value date from and date to are stored in database as varchar2 in the format yyyy/mm/dd 00:00:00. Now if i am trying to compare entered date with these dates i am getting literal does not match format string or date picture ends before....Can any body tell me what to do.
    RegardsPoint a) VERY BAD IDEA storing dates as VARCHAR2 on the database. It will only lead to corrupt data in the future.
    Point b) When comparing dates, you should compare them as DATE datatype as the database knows how to do comparisons against DATES. If you try and compare them as VARCHAR2 then you will most likely end up with incorrect comparisons.
    If you must have varchar2 storing of your dates/times (there's absolutely no reason to though)... you want...
    TO_DATE(:entered_date,'YYYY/MM/DD HH24:MI:SS') BETWEEN TO_DATE(DATEFROM,'YYYY/MM/DD HH24:MI:SS') AND TO_DATE(DATETO,'YYYY/MM/DD HH24:MI:SS')
    e.g.
    TO_DATE('20080815 13:23:33','YYYY/MM/DD HH24:MI:SS') BETWEEN TO_DATE(DATEFROM,'YYYY/MM/DD HH24:MI:SS') AND TO_DATE(DATETO,'YYYY/MM/DD HH24:MI:SS')

  • AWR snapshot not generatedand how to compare statistics with a baseline

    01. AWR snapshot not being generated even after setting looks fine
    02. compare a captured set of statistics with a baseline.
    i m not much clear on this, please help as i have this requirement at hand.
    Thanks a lot in advance.

    01.
    SQL> show parameter statis
    NAME TYPE VALUE
    statistics_level string TYPICAL
    I explicitly run and did cntl^C as it looks running endless... (waited almost 2-3 hours).
    SQL> exec dbms_workload_repository.create_snapshot;
    ^CBEGIN dbms_workload_repository.create_snapshot; END;
    ERROR at line 1:
    ORA-01013: user requested cancel of current operation
    looks like job_name is enabled.
    GATHER_STATS_JOB TRUE WEEKNIGHT_WINDOW
    freq=daily;byday=MON,TUE,WED,THU,FRI;byhour=22;byminute=0; bysecond=0
    GATHER_STATS_JOB TRUE WEEKEND_WINDOW
    freq=daily;byday=SAT;byhour=0;byminute=0;bysecond=0
    anything else can be checked, i dont have access to OEM..must be done at SQL prompt.
    02. thanks for info. i understand.. how do we compare set of snapshots with baseline(which is actually pair/range of snapshot kept for further comparison)
    no access to OEM. must be done at SQL prompt.
    please help in both. thanks ...

  • How to replace name with number ID

    Example:
    Table1
    T1ID Name1
    1 John Smith
    2 Kathy Smith
    Table2
    T2ID Name2
    100 John Smith
    101 Kathy Smith
    102 John Smith
    103 Kathy Smith
    I want to replace all names in column called Name2 in Table 2, with matching T1ID from Table 1. There are many name repetitions in Table 2.

    If Name2 is VARCHAR and T1id is number then it would be better to add a new column with a consistent data type;
    Sample data;
    create table table1 as (
    select 1 t1id, 'John Smith' name1 from dual union all
    select 2, 'Kathy Smith'from dual);
    Table created
    alter table table1 add constraint table1_pk primary key (t1id);
    Table altered
    create table table2 as (
    select 100 t2id, 'John Smith' name2 from dual union all
    select 101, 'Kathy Smith' from dual union all
    select 102, 'John Smith' from dual union all
    select 103, 'Kathy Smith' from dual);
    Table createdAdd the new column;
    alter table table2
       add name_id references table1(t1id);
    Table alteredUpdate the new column;
    merge into table2 t2
    using (select t1id, name1
           from table1) t1
    on (t2.name2 = t1.name1)
    when matched then
      update
      set t2.name_id = t1.t1id;
    DoneDrop the retired column;
    alter table table2 drop column name2;
    Table altered
    select * from table2;
          T2ID    NAME_ID
           100          1
           101          2
           102          1
           103          2

  • How to compare character with \ ?

    Hi,
    How can I compare a character with backslash ?
    when I do 
    if  (c == '\')
    then it gives error invalid character constant
    I cant even declare string with this value like
    String str = "\";
    this gives error string literal is not properly closed by double qoute
    thanks in advance
    B

    Hi,
    You can use the below
    String str = "\\";
    char c = '\\';
    * are considered as \ at runtime.
    Regards,
    Sruti

  • How to compare date with null value

    Hi
    I have a date filed and i assigned that input box with context attribute of type Date.
    Here my problem is
    when the end user not entered any thing (null ) the i have give some defaul date.
    so first in the action method i have to check the date with null
    if it is null i have to give default date.
    so please let me know how to over come this.
    thanks
    Mukesh

    Hi
    You can get your date in your action method like
    Date newDate=new Date();
    Date myDate= wdThis
                              .wdGetYourComponentNameController()
                                      .wdGetContext()
                                           .currentYourNodeNameElement()
                                                           .getYourDateName();
    if ( myDate== null) {
             wdContext.currentContextElement().setYourDateName(newDate);
    else{...........//continue your other validations or calling other methods}
    Regards
    Abhijith YS
    Message was edited by:
            Abhijith YS

  • How to subract char with number

    Hi Experts
    Here is my requirement
    select sysdate-1 from dual -- Goes to previous date sysdate formate is DD-MON-RRRR
    Iam changing this format as MM-DD-RRRR
    select to_char(sysdate, 'MM-DD-RRRR') From Dual -- Here now how can I go to my previous date with this?
    I am trying this
    select to_char(sysdate, 'MM-DD-RRRR') ,-1 From Dual -- here I am subtracting Char with no which is not possible how can i achieve this ?
    Regards
    Suresh Babu

    subtract then convert:
    select to_char(sysdate-1,'mm-dd-yyyy')
    from dual;
    TO_CHAR(SY
    05-23-2013?
    nb 'rr' only makes sense for 2-digit years.

  • How to compare files with Java - help me!

    Is there any free utilities?

    www.google.com and www.sourceforge.net would be good places to start. You can locate these using a 'browser'.
    - Saish

Maybe you are looking for

  • I need help to run this package and i got some error

    create or replace PACKAGE BODY SUBS_INS_API_sun AS PROCEDURE SUBSCRIBER_INS_sun     (SOURCE_SYS_ID IN VARCHAR2,     TRACKING_ID IN VARCHAR2,     ACCOUNT_NO IN VARCHAR2,     prepaidActDevDetails_tab IN prepaidactdvcdetailsobj_sun,     ERROR_CODE OUT V

  • Any FM to calculate planned costs for a Maintenance plan

    Hi all, Is there any FM to calculate planned costs for an Maintenance plan. I can use report RISTRA30(IP31). but i need to use for multiple multiple Mplans and different time frames. using SUBMIT to this report and getting data will lead to performan

  • IPhoto can't read disk

    Hi, I'm using iPhoto '08 7.1.3 with a Sony DSC-H2 digital camera and a Digital Concepts MemoryStick card reader. All was working fine until my imac wouldn't recognize my memorystick (received message that the "disk you inserted was not readable by th

  • Lion will not allow my Belkin USB hub to work

    Since having upgraded to Lion, my Belkin USB no longer works. At start-up a get a message asking that install software for the Hub, but of ourse the software disc pre-dates Lion and there is nothing on the Belkin website to offer guidance. Any ideas

  • Problems reading RAW format after update 6.03

    I have problems reading RAW format images into Iphoto 9.6 after update 6.03 or maybe earlier updates (have not imported for a few months). The images show up like half, black or partly distorted. I use a Canon 5D mk2 camera. The images looks okey whe