Oracle Function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • suvam
    New Member
    • Nov 2006
    • 31

    Oracle Function

    Can nybody tell me how this works ?
    select CHARACTERS(trim (CAST(upc as VARCHAR(20)))) from T1 ;
    Here UPC may be a Number or a Varchar type column of T1 table .

    Say , Upc = 1256.23 then what is the O/p ??
    Again , say Upc = 'Skij' then what is the O/p ??
  • nunnasujatha
    New Member
    • Nov 2006
    • 24

    #2
    There is no function like characters in oracle i guess.

    cast is used for type conversion
    ex:to convert a date into varchar

    select cast(bday as varchar(20)) from sujatha_example ;

    CAST(BDAYASVARC HAR(2
    --------------------
    05/12/06 11:53:08AM
    05/12/06 11:54:59AM
    07/12/06 03:20:03PM


    this is also used as substring function
    ex:
    SQL> select CAST(empname as varchar(2)) from emp;

    CA
    --
    su

    this is similar to
    SQL> select substr(empname, 1,2) from emp;

    SU
    --
    su

    actually empaname is varchar(20) here

    if u feel this is useful let me know i'll explain u abt trim function also

    Comment

    • pragatiswain
      Recognized Expert New Member
      • Nov 2006
      • 96

      #3
      Originally posted by nunnasujatha
      There is no function like characters in oracle i guess.

      cast is used for type conversion
      ex:to convert a date into varchar

      select cast(bday as varchar(20)) from sujatha_example ;

      CAST(BDAYASVARC HAR(2
      --------------------
      05/12/06 11:53:08AM
      05/12/06 11:54:59AM
      07/12/06 03:20:03PM


      this is also used as substring function
      ex:
      SQL> select CAST(empname as varchar(2)) from emp;

      CA
      --
      su

      this is similar to
      SQL> select substr(empname, 1,2) from emp;

      SU
      --
      su

      actually empaname is varchar(20) here

      if u feel this is useful let me know i'll explain u abt trim function also
      To convert to Character you need to use To_Char(integer ) function which basically gives you the ascii character corresponding to that integer value.

      For your example, I guess, you really don't need that.

      Comment

      • suvam
        New Member
        • Nov 2006
        • 31

        #4
        Actually , I need to know the pattern of a column(Say Number type).
        Say , table T1 has a field F1 Number(6,2) .
        if F1 = 123.25 then the pattern will be 999.99 . Is there any SQL function which can evaluate this ?

        Comment

        • Pranav Joshi
          New Member
          • Dec 2006
          • 2

          #5
          Originally posted by suvam
          Actually , I need to know the pattern of a column(Say Number type).
          Say , table T1 has a field F1 Number(6,2) .
          if F1 = 123.25 then the pattern will be 999.99 . Is there any SQL function which can evaluate this ?

          Hey, Try This out:

          SELECT TRANSLATE(123.3 4,'1234567890.' ,'9999999999.') FROM dual;

          SELECT TRANSLATE(T1.F1 <=your coulmn>,'123456 7890.','9999999 999.') FROM dual;


          Regards,
          Pranav.

          Comment

          Working...