function in a decode
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: function in a decode

  1. #1
    Join Date
    Jul 2000
    Location
    india
    Posts
    213

    function in a decode

    Hi Everybody,

    How can i call a function in a decode.If i have to call the function in the else part of the decode will it work.

    Any good example will help me.

    Thanks in advance

    pras
    Dream as if u'll live forever..Live as if u'll die today.

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    And what seems to be the problem in using functions inside DECODE?
    Code:
    select job, decode(job, 'PRESIDENT', LOWER(job), INITCAP(job))
    from scott.emp;
    LOWER() and INITCAP() in the above example are functions used inside the DECODE, and INITCAP() is used in the else part of it.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  3. #3
    Join Date
    Jul 2000
    Location
    india
    Posts
    213
    Hi jmodic,

    There are some tables say

    table1 -- column11,column12

    table2 -- column21,column22

    table3 -- column31,column32

    table4 -- column41,column42,


    what i require is

    select column11 from table1 where column12 =
    decode(column21,'M',(select column31 from table3 where column32=column22),
    (select column41 FROM column4 WHERE column21 = column42))

    how can i write the above query more efficiently..
    i am planning to use the function in the else part...
    any advantages of using function...thanks

    pras
    Dream as if u'll live forever..Live as if u'll die today.

Posting Permissions

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


Click Here to Expand Forum to Full Width