1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

reverse command not working with column of number datatype

Discussion in 'SQL PL/SQL' started by laxman, Jul 14, 2009.

  1. laxman

    laxman Forum Expert

    Messages:
    144
    Likes Received:
    0
    Trophy Points:
    230
    Location:
    MUMBAI
    Hi all,
    I have one doubt regarding reverse command using with query.

    e.g select reverse(ename) from emp;
    output is working fine

    but if i am using reverse on salary column
    such as select reverse(sal) from emp
    it is not working
    oracle showing message "FIND SOME ERROR NEED TO CLOSE"
    Is it showing erro because of colomn of number datatype?

    Kindly help me
    Regards
    Laxman
     
  2. srinath

    srinath Active Member

    Messages:
    7
    Likes Received:
    1
    Trophy Points:
    65
    hi laxman

    reverse is not a supported function even though it may work. And it is supposed to be used only for strings and not on numbers.
     
  3. laxman

    laxman Forum Expert

    Messages:
    144
    Likes Received:
    0
    Trophy Points:
    230
    Location:
    MUMBAI
    Hi srinath,
    Thanks for the valuable information,but if i want the column of number datatype to display in reverse form is there any method i can apply,please tell me.

    Regards
    Laxman
     
  4. tyro

    tyro Forum Genius

    Messages:
    368
    Likes Received:
    20
    Trophy Points:
    260
    Location:
    India
    Reverse is an undocumented SQL function. It would be safe NOT to use it in any case because there is no guarantee that it would work in future releases.

    You should write a PL/SQL function which takes the number as an input and returns the reverse of the number as output. That would be the best way. Alternately if it's just for some homework problem you can use to_char(reverse()), something like this:
    Code (SQL):

    SELECT REVERSE (TO_CHAR (123))
      FROM DUAL
     
     
  5. laxman

    laxman Forum Expert

    Messages:
    144
    Likes Received:
    0
    Trophy Points:
    230
    Location:
    MUMBAI
    Hello sir,
    Thanks for your kind suggestion.

    Regards
    Laxman
     
  6. salmankhalid

    salmankhalid Forum Advisor

    Messages:
    116
    Likes Received:
    6
    Trophy Points:
    260
    Location:
    Lahore, Pakistan
    i totally agree with TRYO, i have experienced it, it sometimes not show the exact result that you need.......