Using instr in a decode select?

Is it possible to use the INSTR function within a DECODE function? What I want to do is return 'Repair and Return' if my column has an 'RR' in it, otherwise return 'Swap'. This is what I have tried within my select:
SELECT colA,
DECODE( instr(M4OWNER.REQUEST_LINE.REQUEST_PROCESS, 'RR' , 1, 1) from dual,'REPAIR AND RETURN','SWAP')
FROM tableA

This is enough , no..?
SQL> select c1,decode(instr(c1,'RR'),0,'SWAP','RR') flg
  2  from test;
C1         FLG
xxxRRhhhh  RR
xxxhhhh    SWAP                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Using Instr in Cursors or Loops...?

    Can anyone suggest me how to use "Instr" to find one parameter string in another parameter string, finding if one string is present in another using loops..??
    Edited by: user11339127 on Jul 1, 2009 11:04 PM

    You can use INSRT to find the position of your string in a given string.
    e.g:  select instr('navnit','av') from dual;  --sql
    PL/SQL--
    declare
       pos number;
    begin
      pos := instr('<string1>','<string2'>; or you can write in case of forms as pos:=instr('<:datablock>.<item>','<string to found');
      if pos = <some value> then
          <do something
      end if;
    end;  
    {coe}
    Similarly , you can extend your code.
    Hope it helps.
    +Please mark answer as helpful / correct, if it helps you+
    Navnit                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • To use Boolean function in DECODE or CASE statement

    Hi all
    I have a scenario where i need to use a boolean function inside DECODE statement. When i tried this way iam getting "ORA-06553: PLS-382: expression is of wrong type".
    I doubt whether i can use boolean function inside DECODE or not?
    My query will be like this:
    select decode(my_fuction( ),'TRUE',1,'FALSE',0) from dual;
    Any help is highly appreciated.
    Thanks
    Sriram

    Overloaded functions must differ by more than their
    return type . At the time that the overloaded
    function is called, the compiler doesn't know what type
    of data that function will return. The compiler cannot,
    therefore, determine which version of the function to
    use if all the parameters are the same.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to use instr functions?

    Hi guys,
    I have a table like this:
    name data
    a 10101000U000
    b 011U11001100
    c 0U1001001001
    d 01U010100010
    I want to get the position of "U" in data column, like:
    name position of U
    a 9
    b 4
    c 2
    d 3
    what should I do? I use "instr" function, but failed. can anyone help me on this?
    Thanks.

    Example for you:
    [email protected]> select instr('10101000U000','U') from dual;
    INSTR('10101000U000','U')
    9
    [email protected]> select instr('011U11001100','U') from dual;
    INSTR('011U11001100','U')
    4
    Best Regards
    Krystian Zieja / mob

  • Using utl_encode.base64_encode within decode function

    Hi, I want to use utl_encode.base64_encode within decode function. However, the result is not as expected.
    select 'a', decode('a', '1', 'EQUAL to 1',
    --'NOT EQUAL to 1'
    utl_encode.base64_encode('a')
    ) result
    from dual
    A     RESULT
    a     43673D3D
    43673D3D is not a base64 encoded value of a
    What is wrong with the sql?
    Thanks

    SQL> select 'a'
      2  ,      utl_encode.base64_encode(utl_raw.cast_to_raw('a')) raw_result
      3  ,      utl_raw.cast_to_varchar2(utl_encode.base64_encode(utl_raw.cast_to_raw('a'))) string_result
      4  from   dual;
    ' RAW_RESULT      STRING_RESULT
    a 59513D3D        YQ==
    1 row selected.Keep in mind that utl_encode.base64_encode returns a RAW and needs RAW input.
    You'll probably need UTL_RAW to get your desired result.
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_encode.htm#CACECFHF

  • PL-SQL Solve: Using INSTR and SUBSTR

    I am trying to work on this and cannot get a solution. Please help
    You have to use INSTR and SUBSTR to solve
    Question:
    You have the following acceptable value
    Numberic: 0-34
    80-100
    or Non Numberic X S U D- D D+
    Im have to use INSTR and SUBSTR functions to test that the value is a valid (as above) number before TO_NUMBER is called:
    SELECT TO_NUMBER('?? ') //HERE ?? and a space (for 100 etc) is for the values as above
    FROM DUAL
    WHERE ....INSTR(......)<=;
    (Hence if the number is true then number comes back or it says no rows)
    and also id non numberic it should also be tested.
    I am completely unsure about it but tried this
    SELECT TO_NUMBER('34 ')
    FROM DUAL
    WHERE INSTR('0123456789',1,1)<=9 (looking at first number ?)
    AND
    INSTR('0123456789',2,2)<=9
    AND
    INSTR('0123456789',3,3)=0;
    Please help

    We have the following value that we can use:
    Numeric: 0-34 and 80-100 only
    or Non Numberic X S U D- D D+
    Have to use INSTR and SUBSTR functions to test that the value is a valid
    (for now only trying to create a function which can later be put into a procedure.)
    SELECT TO_NUMBER('12 ') //e.g HERE 12 and a space for the values as above
    FROM DUAL
    the where clause looks at all three spaces to make sure values are correct (given number or non-numberic values only)
    (Hence if the number is true then number comes back (meaning true)
    or it says NO rows)
    If value is non numeric, test it to allow non numberic also.
    I am completely unsure about it but tried this
    SELECT TO_NUMBER('34 ')
    FROM DUAL
    WHERE INSTR('0123456789',1,1)<=9 (looking at first number ?)
    AND
    INSTR('0123456789',2,2)<=9
    AND
    INSTR('0123456789',3,3)=0;
    Something like this has to be done.....subst (instr, x,x,) i think mite help.

  • Finding substr till ',' using instr

    Hi All,
    I am using substr function in my query. In substr ,i am using Instr function to get index of ','  . It is working fine.But problem occurring for last value. because last value is not having ',' in end.
    for example my value of column is
    text1,text2,text23,text4,text5
    It is finding till text 4.but text 5 is missing.
    my query is like this
    Select Substr(columnValue,Instr(columnValue,Dwfstepname,1,1),Instr(columnValue,',',Instr(columnValue,Dwfstepname,1,1),1)) From Workflowhistory,Docmeta  Where
    Workflowhistory.Did=853
    And Docmeta.Did=Workflowhistory.Did And Daction='Approve'
    Can somebody help to resolve this

    Hi.
    For example, you can use
    with tt as (select 'text1,text2,text23,text4,text5' txt from dual)
    select regexp_substr(txt, '[^,]+', 1, level)
    from tt
    connect by level <= regexp_count(txt, ',') + 1

  • How to use my iPhone 4 to select Internet radio stations on MacBook Pro

    Okay, once again I return here to seek guidance and wisdom.  Fellow members here told me about Air Video, a terrific set of programs for iOS and OS X to stream videos from my MacBook Pro to my iPhone 4.  It is awesome!
    Now, my other need (?).  I want to run something on my Mac that lets me select Internet radio station streams like TuneIn for ex., but I want to be able to change selections on whatever is on the Mac from the iPhone 4.  What I want to do is use the iPhone 4 as a remote for the app on the Mac which I want to connect to either some external speakers or someday to a real external Dac, amp, and speakers.
    I have the TuneIn Pro app on my iPhone 4 already and on the Mac via browser have accessed their website.
    Now someone surely is going to mention Airplay or something to stream from the iPhone4.  From the cost of Airplay capable hardware, I just can't afford it yet.  Maybe if I could find Bluetooth speaker or device?
    One other thing to throw in for thought.  I have not only iTunes on my MacBook Pro, but also Fidelia and Amarra, and thinking about Decibel or Audirvana.  In other words somewhat hi-def music output quality available on the Mac.  So....I do have a remote app for Fidelia and think there's one for either Decibel or Audirvana, so that brings me back to Internet radio on the MacBook Pro.  If I can find a way to use the iPhone 4 to select an app on the Mac for Internet radio, I can play those plus hi-def music via one of those programs.
    I probably didn't say all that right, but I hope you can decipher what I am asking about.
    If nothing else, can you recommend inexpensive Bluetooth speakers to play radio from the iPhone4?  I was hoping to buy some AudioEngine powered speakers for the Mac, hence the desire to run all sound/music through that device but using the iPhone4 as control device.

    Hi Starbux48
    First off. The benefits of using Amarra, Pure Music, Audirvana or whatever, can only be heard if you have a true audiophile system set-up. Think of systems starting from 5000 U$. Then only if your music files are high resolution. Think ALAC or FLAC, AIFF or Wave.  For all other music playing the itunes set-up suffices. So the better idea for you will be playing the music over your macbook.
    Mountain lion offers airplay for intel based macs. You can use this. If you install the free Remote App. on your iPhone, you can use that to control itunes on your Macbook via wifi/Airplay. The remote app offers you the view of itunes on your Macbook and the screen of your Macbook changes with what you do on your iPhone. So you can even control the itunes radiostation from your iPhone.
    If you have an older, non-intel macbook, you can install airserver on your macbook. This will set you back 15 dollars or so, but will basically do the same.

  • How do I create my own favorite template for DVD slideshows? I used to be able to select this from pulldown menu, but cannot now do so. I am directed straight to templates, which take more memory. I have a large slideshow, and need all the space I can get

    First, how do I create my own favorite theme template for DVD slideshows? I used to be able to select this from pulldown menu, but cannot now do so. I am directed straight to already existing themes, which take more memory. I have a large slideshow, and need all the space I can get. I just want to use a picture as my DVD cover, and then insert a slideshow. Also, when I try to burn my 8.5gb double sided slideshow, all that burns is the music. It is a large slideshow, a memorial on the life of my now deceased brother. This means a lot to me and to my family, and I am having so much trouble trying to burn it. I have gone into Project View and selected appropriately. The bar shows I have room to burn this DVD, but it does not burn.  I have burned so many DVDs in the past, but this one just will not burn. I am so confused at this point. I will say this is the first 8.5gb I have attempted to create and burn. My specs list a 7.7gb or 4.7gb as operable....but there are no 7.7gb dvds. I had to purchase 8.5gb. Help? What am I doing wrong? I have spent so much time on this, and just cannot figure it out.

    Final Cut is a separate, higher end video editor.  The pro version of iMovie.
    Give iPhoto a look at for creating the slideshow.  It's easy to assemble the photos in an album in iPhoto, put them in the order you want and then make a slideshow of them.  You can select from various themes and transitions between slides and add music from your iTunes library.
    When you have the slidshow as you want use the Export button at the bottom of the iPhoto window and export with Size = Medium or Large.
    Save the resulting Quicktime movie file in your Movies folder.
    Next, open iDVD, choose your theme and drag the QT movie file into the menu window being careful to avoid any drop zones.
    Then follow this workflow to help assure the best qualty video DVD:
    Once you have the project as you want it save it as a disk image via the File ➙ Save as Disk Image  menu option. This will separate the encoding process from the burn process. 
    To check the encoding mount the disk image, launch DVD Player and play it.  If it plays OK with DVD Player the encoding is good.
    Then burn to disk with Disk Utility or Toast at the slowest speed available (2x-4x) to assure the best burn quality.  Always use top quality media:  Verbatim, Maxell or Taiyo Yuden DVD-R are the most recommended in these forums.
    The reason I suggest iPhoto is that I find it much easier to use than iMovie (except for the older iMovie 6 HD version).  Personal preferences showing here.

  • Filtering a sharepoint 2010 list using Multiple values from Multi-Select Filtering In Infopath 2010 form

    I am creating a browser based InfoPath 2010 form Calendar Filtering
    using SharePoint 2010 Calendar List (All Events) and InfoPath 2010.  This form has data connection to the Calendar list. Goal is to
    compare Calendar Events from Current Year to Previous Year. I have 2 columns called - Previous Year and Current Year. I have 2 drop-down controls in each columns called
    Select Year  and Select Week. I also have common drop down called
    Select Category which holds category of the events such as weather, power outages and so on. I wish to display specific events on specific date and specific week on both columns.
    I am able to filter the list based upon Year and Week
    on both these columns by applying rules in the InfoPath 2010 form. The real issue is that I want to apply category filter on the search result of
    Year and Week. Or it needs to show all the values if I
    select Category value as All. So I wish to apply filter on Search results using Category drop-down list selection.
    Hope I could explain this better but I tried to do the best here. Any suggestions, hint, or pointers
    Thanks
    Snehal H Rana
    Thanks Snehal H.Rana SharePoint Consultant

    I am creating a browser based InfoPath 2010 form Calendar Filtering
    using SharePoint 2010 Calendar List (All Events) and InfoPath 2010.  This form has data connection to the Calendar list. Goal is to
    compare Calendar Events from Current Year to Previous Year. I have 2 columns called - Previous Year and Current Year. I have 2 drop-down controls in each columns called
    Select Year  and Select Week. I also have common drop down called
    Select Category which holds category of the events such as weather, power outages and so on. I wish to display specific events on specific date and specific week on both columns.
    I am able to filter the list based upon Year and Week
    on both these columns by applying rules in the InfoPath 2010 form. The real issue is that I want to apply category filter on the search result of
    Year and Week. Or it needs to show all the values if I
    select Category value as All. So I wish to apply filter on Search results using Category drop-down list selection.
    Hope I could explain this better but I tried to do the best here. Any suggestions, hint, or pointers
    Thanks
    Snehal H Rana
    Thanks Snehal H.Rana SharePoint Consultant

  • Single Date Parameter, but using a date range for selection

    Post Author: fireman204
    CA Forum: Formula
    I'm fairly new to Crystal Reports, so be gentle with me.  I have a report that has 4 parameters.  The report asks for data for a specific month, the YTD data to the end of the selected month, and the same data from the previous year.  It seems there should be a way to enter a single parameter (ie., 2007-4-1), and off that date select all the data for the month, the current year to the end of that month, and then the data from the previous year for the same period.  I know this will be a formula field needed to select the data, but not sure how to get there from here.  Any ideas?  Thanks in advance!

    Post Author: SKodidine
    CA Forum: Formula
    It should be possible for you to create just one parameter to have the user input a single date and then create formulae to create the begin and end dates for the month, YTD and PYTD.  You can then use these formulae for record selection criteria.
    For example, if the user inputs a date of 2007-04-01 for the single parameter then create formulae such as:
    beginmonth
    datevar beginmonth;
    beginmonth := date(year({?My Parameter}),month({?My Parameter}),01);
    endmonth
    datevar endmonth;
    endmonth := cdLastDayOfMonth ({?My Parameter});
    To use the cdlastdayofmonth function, In the formula workshop window, click on "Repository Custom Functions" then under CRYSTAL and DATE right click on cdlastdayofmonth and click on ADD TO REPORT.  Once that is done, then create the above "endmonth" formula.  You should see this new function in your formula workshop window in the FUNCTIONS window under CUSTOM FUNCTIONS.
    beginytd
    datevar beginytd := date(year(currentdate),01,01);
    endytd
    datevar endytd;
    endytd := cdLastDayOfMonth ({?My Parameter});
    beginpytd
    datevar beginpytd := date((year(currentdate)-1),01,01);
    endpytd
    evaluateafter({@endytd});
    datevar endytd;
    datevar endpytd;
    endpytd := date(year(endytd)-1,month(endytd),day(endytd));
    In your record selection criteria, you can use the above formulae like this:
    in {@beginmonth} to {@endmonth}
    or
    in {@beginytd} to {@endytd}
    or
    in {@beginpytd} to {@endpytd};
    This is one way of doing it, perhaps others might pitch in with a more efficient way.

  • Method to be used to delete a particular select parameter in a Sales order

    Hi ,
    Which Method can be used to delete a particular select parameter in a Sales order search screen using class CL_CRM_BOL_DQUERY_SERVICE

    Hi,
    Okie :) please feel free to post any problem :)
    Please apply the patch that has the fix for this issue:
    [Patch 9791839|https://updates.oracle.com/ARULink/PatchDetails/process_form?patch_num=9791839]
    The above link worked fine for me .
    Ideally, you should pick up the latest patch, which is [ Patch 11846804|https://updates.oracle.com/ARULink/PatchDetails/process_form?patch_num=11846804]
    Click on View Read me for install instructions. Let me know if you find any problem with patch install.
    Regards,
    Ajay Kumar

  • "all my music is unchecked.  I can not check whole playlists by using the top checkmark to select all.  I went to all my playlists, same thing.  I can only press them ONE at a time, which will take about a day to check all of them." Please help.Windows7

    "While in MY MUSIC on itunes, all my music is unchecked.  I can not check whole playlists by using the top checkmark to select all.  I went to all my playlists, same thing.  I can only press them ONE at a time, which will take about a day to check all of them.
    any ideas?  anyone have same problem?  This just happened since last update." I have windows7

    Thanks A Lot! I should have clicked: "This solved my question" But Thanks all the same!

  • The Control A key is not working. I cannot multi-select my songs. I'm not sure if it is the problem with iTunes 10.6.1.7 or my PC settings encounter issues. Also, i cannot find Album Artwork online using iTunes and i cannot select any view form but List.

    The Control A key is not working. I cannot multi-select my songs. I'm not sure if it is the problem with iTunes 10.6.1.7 or my PC settings encounter issues. Also, i cannot find Album Artwork online using iTunes and i cannot select any view form but List.

    The Control A key is not working. I cannot multi-select my songs. I'm not sure if it is the problem with iTunes 10.6.1.7 or my PC settings encounter issues. Also, i cannot find Album Artwork online using iTunes and i cannot select any view form but List.

  • Use of GROUP BY in SELECT

    I am considering using GROUP BY in several selects where I will access very big bsik, bsid, bsad, bsak, ecc...
    My two concerns are performance and high data volume.
    GROUP BY should reduce data arriving from DB but will it hurt performance?
    What are your considerations?
    Any ideas are welcome. I cannot seem to find anything specific for or against GROUP BY.
    thanks,
    Phillip

    Hello Philip,
    I would advise that you do not use the Group By clause in the select statements for these tables. As you have rightly said, the data volume in these tables might be a major cause for concern.
    Using the Group By clause will heavily load the database server. while in the development environment, your query  might run okay, in the productive environment it might crash. The reason : the cursor to the database would have timed out.
    The Group By operation, as you know can be simulated after you get the data into the application server. The application server processing can take some time but you can usually optimize it.
    Regards,
    Anand Mandalika.

Maybe you are looking for