Decode in 'IN' clause doesn't work - any workaround?

Hi All,
I thought this was working, but as I tested further I found it's not returning the right results. I have a query that is trying to take the first 4 letters of a string, and based on that value I want to limit the values in the 'IN ' clause. (Does that make sense?)
Something like this:
select * from table_a where NAME in
  select decode(substr(:P_var,1,4),'ABCD','(''ALF'',''BOB'',''COLE'')','EFGH','(''EVE'',''FRED'',''GORD'')') from dual
)But it seems that no matter what I do I can't get the right results.
This does return ('EVE','FRED','GORD') as the result of the nested select (P_var = 'EFGH'), but I get 'No Data Found', even though I know those names are in the table...
Not sure what would be a better way - AKA one that works, so any help is greatly appreciated...
Corey

Assuming you have collection type handy a couple of approaches spring to mind (note that MEMBER OF syntax in second example is 10g specific)...
Oracle Database 10g Release 10.2.0.2.0 - Production
SQL> CREATE TABLE table_a (name VARCHAR2 (30));
Table created.
SQL> CREATE OR REPLACE TYPE varchar2_table
  2     AS TABLE OF VARCHAR2 (4000);
  3  /
Type created.
SQL> INSERT INTO table_a
  2     SELECT *
  3     FROM   TABLE (varchar2_table (
  4               'ALF', 'BOB', 'COLE',
  5               'EVE', 'FRED', 'GORD',
  6               'TOM', 'DICK', 'HARRY'));
9 rows created.
SQL> COMMIT;
Commit complete.
SQL> VARIABLE p_var VARCHAR2 (30);
SQL> EXEC :p_var := 'ABCD';
PL/SQL procedure successfully completed.
SQL> SELECT a.*
  2  FROM   table_a a
  3  WHERe  a.name MEMBER OF (
  4            DECODE (SUBSTR (:p_var, 1, 4),
  5                'ABCD', VARCHAR2_TABLE ('ALF', 'BOB', 'COLE'),
  6                'EFGH', VARCHAR2_TABLE ('EVE', 'FRED', 'GORD')));
NAME
ALF
BOB
COLE
SQL> EXEC :p_var := 'EFGH';
PL/SQL procedure successfully completed.
SQL> SELECT a.*
  2  FROM   table_a a,
  3         TABLE (DECODE (SUBSTR (:p_var, 1, 4),
  4             'ABCD', VARCHAR2_TABLE ('ALF', 'BOB', 'COLE'),
  5             'EFGH', VARCHAR2_TABLE ('EVE', 'FRED', 'GORD'))) t
  6  WHERE  a.name = t.column_value;     
NAME
EVE
FRED
GORD
SQL>

Similar Messages

  • What do you use to read .stn files on mavericks?  Genuine fractals doesn't work any longer?

    What do you use to read .stn files on mavericks?  Genuine fractals doesn't work any longer?  I get an error message that adobe photo shop 5 cant open it because the modules? arent right.  I assume that it is because I now have an intel machine. I know other people have used this file format and so how do you open your photo files?

    When I try to open in Adobe Reader is says, "Adobe Reader could not open 'Blank-AF 77-LOE.xfdl' because it is either not a supported file type or because the file has been damaged (for example, it was sent as an email attachment and wasn't correctly decoded)."  Now what.  I didn't email it.  I transferred from an external hard drive.  The file opens just fine on a Windows PC.

  • I bought a mini DVI to HDMI convertor and  a HDMI to VGA cable to connect my mac book pro to a tv but it doesn't work any one can help.\\\\\

    i bought a mini DVI to HDMI convertor and  a HDMI to VGA cable to connect my mac book pro to a tv but it doesn't work any one can help.

    I would suggest looking into a Thunderbolt to HDMI connector. In this case, you may be able to use the TV as an external monitor. For this option, please confirm through additional research. I have not tested it personally.
    You can also use an Apple TV, which connects with HDMI. In this case, you can use Airplay Mirroring. Not all Macs support Airplay Mirroring, so you need to check first. I have a Mid-2011 27" iMac, and it supports Airplay Mirroring. I don't use it often because my TV is in another room, but I just tried it and it worked. It had to change the screen resolution to work well, so I don't know if I would want to use it as my day to day monitor. http://support.apple.com/kb/ht5404

  • Mini displayport doesn't work any more

    My Mini Displayport doesn't work any more with VGA, DVi, just with the Apple Cinema Display. It started one week ago, I've tried many different monitors, but it seems to be that it only works with the Apple Cinema Display, Thunderbolt Ethernet Adapter is also accepted but nothing else. PRAM, SMC, booting from an Harddisk with Mavericks (I'm on 10.10.2), Safe Mode, nothing works. I have a Macbook Air, 11 " from Mid 2013, no warranty any more. Today I was at Bense, a german reseller (thank you guys for your effort), they did the same tests and some more, but also found nothing. Is there anyone with the same problems and a solution for it?
    Cheers
    Ayhan

    Does it work on the other command key? I typically use the one to the left of the space bar, and at one point of time, it stopped working. but then i started to use the command key to the right of the keyboard which worked. but, then i started using the one that wasn't working, and just clicking slowly rather than quickly, and now it seems to work again. Don't know why . . . but that is what happened for me.

  • Ipone 4s display suddenly doesn't work any more. i can't even unlock it as it put the numbers itself. and if i am lucky to unlock it opens apps and does everything whenever my finger comes near without even touching it. can anyone help?

    ipone 4s display suddenly doesn't work any more. most of the time i can't even unlock my iphone as it puts the numbers itself. and if i am lucky to unlock it opens apps and does everything else whenever my finger comes near the display without even touching it. I did reset and also updated my operating system. But the problem stills shows up... can anyone help please?

    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • Yahoo mail doesn't work any more in macBook mail

    Yahoo mail doesn't work any more in mac mail. Any help?

    Did you tried soft reset to your device?
    tanzim                                                                                  
    If your query is resolved then please click on “Accept as Solution”
    Click on the LIKE on the bottom right if the post deserves credit

  • PEN TOOL DOESN'T WORK ANY MORE after PS 2014.2 update!

    I just downloaded the latest Photoshop update.  Pretty slick......adjustable fonts in the dropdown menus again.....nice guide improvements.  One little problem....THE PEN TOOL DOESN'T WORK ANY MORE.  The program is totally useless.  What the h%+l is wrong with adobe?  At least I can still use Photoshop CC.  Anyone got a fix for this?
    Jim

    The program is totally useless.  What the h%+l is wrong with adobe?
    Venting is not going to do much good, please read these (especially the section headlined "Supply pertinent information …"):
    Best practices: Usage | Adobe Community
    http://blogs.adobe.com/crawlspace/2012/07/photoshop-basic-troubleshooting-steps-to-fix-mos t-issues.html
    On Max OSX 10.8.5 I can not notice a dysfunctional Pen Tool so far.

  • Aperture 3.0.3 - MobileMe doesn't work any more

    F*!
    I have installed new Aperture update and since then I'm only having problems. First I had to repair my library. Fortunately worked.
    But the sync of my MobileMe galleries doesn't work any more. I try to start the sync manually but it doesn't work. I double click on the sync icon but nothing happens. New galleries do not sync, too.
    Aperture is really annoying. Every some weeks more trouble. Slow, not syncing, what will be next?
    Did you have the problems with MobileMe and Aperture? Any idea what to do?
    Thanks ...

    Actually lost some photos in my galleries after the update. I held down the Option and Command keys while starting APerture and repaired the library permissions and then resynced the galleries. One gallery was stubborn, I had to remove a photo from this gallery and then drag it back into the gallery. This allowed everything to update.
    null

  • I down loaded fcp x 10.2 and my playhead doesn't work, any ideas

    I down loaded fcp x 10.2 and my playhead doesn't work, any ideas

    Move it to the trash and download again..
    Russ
    PS: I assume your profile info is somewhat outdated.

  • In iTunes, how do I switch to an Ipod nano from and old ipod that doesn't work any more

    in iTunes on your computer, how do I switch to an Ipod nano from and old ipod that doesn't work any more?  It has all the folders and songs I had on my old ipod, but does not recognize my ipod nano and cannot sync with it?

    Hi bob12345S,
    If your iPod nano does not appear in iTunes when connected to your computer, you may want to troubleshoot using the steps on this page -
    Apple - Support - iPod nano - iTunes Troubleshooting Assistant
    http://www.apple.com/support/ipodnano/assistant/itunes/
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • ITunes funktioniert nicht mehr / iTunes doesn't work any longer

    Hallo liebe Community,
    ich habe seit gestern ein sehr ärgerliches Problem mit iTunes.
    Seit gestern kann ich zwar iTunes noch öffnen, jedoch kommt bei jeglichem Versuch eine Verbindung mit dem iTunes Store herzustellen (sei es über iTunes Match oder Store oder meinen Account) die Windows 8.1 Fehlermeldung "iTunes funktioniert nicht mehr". Jegliche Versuche danach noch was zu machen schlagen fehl da sich das Programm dann automatisch schließt.
    Was habe ich bis jetzt getan:
    - einfache Neuinstallation
    - komplette Neuinstallation (mit jeglicher Apple Software die auf meinem Pc war/ist)
    - Bereinigung und Überprüfung des Pc's
    - 1 Tag warten
    - an und abmelden vom iTunes Store (war nur möglich bevor das Problem aufgetreten ist)
    Nichts hat geholfen. Und jetzt habe ich einen Pc ohne Musik und allem anderen, weil alles in meiner iCloud ist. Kennt wer das Problem und kann mir zufällig helfen? Sämtliche Beiträge in den Apple Foren sowie in den Foren, die man durch Google findet, helfen nichts...und ja, ich habe die vorgeschlagenen Sachen ausprobiert.
    daer community,
    since yesterday it's still possible to open iTunes but at any try to get a connection to the iTunes Store (no metter if i try it through iTunes Match or Store or my iTunes Account) i'll get the Windows 8.1 error massage "iTunes doesn't work any longer". Any tries to do something after the error massage are useless because iTunes get closed by hisself.
    What i've already done:
    - simple reinstallation
    - complete reinstallation (reinstalled all Apple softwares i've got at my pc)
    - cleaned and checked my pc
    - waited 1 day
    - logged out and in at the iTunes Store (this was just possible before the problem appeard)
    Nothing helped. And now i've got a pc without music and everything that i get from iTunes because all is in my iCloud. Does anyone know this problem and could help me solving it? All posts in the Apple forums and the forums you'll find with the google search are useless...and yes, i tried them all.
    Vielen Dank,
    Thanks,
    Dominik

    https://discussions.apple.com/thread/5457433?start=0&tstart=0
    This solved my problem after even the Apple Support couldn't help me!

  • Getting a dotted line around .swf files in my flash site now. this is new as of Firefox 3. Using 4 on a MacBookPro. tried "style outline none" fix. doesn't work. any help?

    Question
    getting a dotted line around .swf files in my flash site now. this is new as of Firefox 3. Using 4 on a MacBookPro. tried "style outline none" fix. doesn't work. any help?

    /* stops annoying focus-selection boxes in FF3 */
    *:active, object:focus, embed:focus
    outline: none;
    }

  • CTRL+RMB doesn't work any more on Firefox4.

    [http://www.lingoes.net Lingoes] translator uses CTRL+RMB to capture text. It doesn't work any more on Firefox4. Why? Is it possible to restore it? Thanks!

    Thanks for your answers!
    I found out, that only on the US site Expert Mouse there is no software for Lion.
    (The one you can get there is from 2006!)
    But I found suitable TrackballWorks software on the Kensington UK site
    http://eu.kensington.com/kensington/en/gb/o/15/sku/498/64325/kensington+expert+o ptical+trackball.aspx
    of 2010 and a Beta-version of July 2011.
    Since the 2010 version works fine under Lion I'm happy with it.
    I hope this will also help others with problems with old Kensington software.
    Thanks again!

  • MRUFolders=TRUE - doesn't work any longer?

    Colleagues,
    I've got trouble with MRUFolders option on my PC... It doesn't work any longer just for me or for everyone?
    LabVIEW 8.6f1 on WinXP Prof SP3.
    can someone else check it for me?
    Thank you,
    Andrey.

    It's a known bug (CAR 113669)
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • My wlan doesn't work any more need help pls

    my wlan doesn't work any more need help pls

    Maybe you'd like to clarify "doesn't work".

Maybe you are looking for