Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2011
    Posts
    2

    Unanswered: Passing a varchar value to an integer column

    Hi,

    I want pre build query which I don't have access to change, to which I can pass a value which is varchar to an integer column.

    Something like:

    Select *
    from emp
    where emp_id = '123, 124, 125';

    I can convert the string to number using collections or some replace functions and pass it as a IN to the query. The problem is I can't change the "=" sign to "IN" as it is a pre-bulit query. Is there any way I can tweak the values before passing to the query.

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    It seems that you can pass anything behind the "=" sign. If that's the case, create a multiple OR construct, such as
    Code:
    SQL> select ename
      2  from emp
      3  where empno = '7369' or empno = '7499' or empno = '7521';
    
    ENAME
    ----------
    SMITH
    ALLEN
    WARD
    
    SQL>

  3. #3
    Join Date
    Sep 2011
    Posts
    75
    Hello,

    Please try like this

    Select *
    from emp
    where emp_id = '123' or emp_id = '124' or emp_id = '125'
    OR


    Select *
    from emp
    where emp_id IN ('123','124','125')

  4. #4
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Jassi, read what's being said. The OP can not modify "=" into "IN" (so your second query is useless) (while the first one is a slightly modified copy/paste of the previous message).

  5. #5
    Join Date
    Oct 2011
    Posts
    2
    Thanks Littlefoot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •