Case help

I'm using 9.2.0.5.0
I have a case in a where clause. The select is:
SELECT description,dist
FROM posdist
WHERE posname LIKE 'NAPOS'
AND to_char(nvl(active,9)) in CASE 2
WHEN 1
THEN '1'
WHEN 3
THEN '9'
WHEN 2
THEN (1,9)
END;
The column "active" is numeric. This query is going to end up being used as a dynamic statement in HTML DB. The case condition is going to be a field on the screen that the user will make a selection. The actual return value possibilities are 1 and NULL.
A value of 1 is active
A value of NULL is inactive
I am casting the column as a character because I was getting non-numeric errors from the last condition (WHEN 2) and the screen will return the values as character. I'm using the NVL function just to make the NULL's a 9 just so that they're easier to work with and compare.
The user may want both Active and Inactive records. This is my problem. I made the return value from the screen for INACTIVE a 3 to make the CASE easier to work with instead of trying to work with "nulls". As it stands now, the values of 1 and 3 works. The statement fails on the last condition - when the value is 2.
What I would like the where clause to be, of course, is when the value is 2 then the case resolve the last condition as: AND to_char(nvl(active,9)) in (1,9);
Again, when the values are 1 or 3 I get the correct records back.
Can someone help me out?
Thanks,
Joe

The only options for using IN are to have a static list or a query as your right hand operand. Obviously a static list won't accomplish what you want, but a query will. You allow 1 if the value you're considering is 1 or 3, and you allow 9 if the value you're considering is 1 or 2.
SELECT 1 FROM dual WHERE :x IN (1, 3)
UNION ALL
SELECT 9 FROM dual WHERE :x IN (1, 2)So then you can re-write your query as,
create table posdist (
posname  varchar2(30),
active  number,
dist  varchar2(30),
description  varchar2(80));
insert into posdist values ('NAPOS', 1, 'A', 'The letter A');
insert into posdist values ('NAPOS', 2, 'B', 'The letter B');
insert into posdist values ('NAPOS', 3, 'C', 'The letter C');
insert into posdist values ('NAPOS', 4, 'D', 'The letter D');
insert into posdist values ('NAPOS', 5, 'E', 'The letter E');
insert into posdist values ('NAPOS', 6, 'F', 'The letter F');
insert into posdist values ('NAPOS', 7, 'G', 'The letter G');
insert into posdist values ('NAPOS', 8, 'H', 'The letter H');
insert into posdist values ('NAPOS', 9, 'I', 'The letter I');
insert into posdist values ('NAPOS', 10, 'J', 'The letter J');
SELECT rownum
  FROM dual
COMMIT;
SQL> VAR x VARCHAR2
SQL>
SQL> exec :x := 2;
PL/SQL procedure successfully completed.
SQL>
SQL> SELECT description,
  2         dist
  3    FROM posdist
  4   WHERE posname LIKE 'NAPOS'
  5     AND TO_CHAR (NVL (active, 9)) IN (
  6           SELECT '1' FROM DUAL WHERE :x IN (1, 3)
  7           UNION ALL
  8           SELECT '9' FROM DUAL WHERE :x IN (1, 2)
  9         );
DESCRIPTION
DIST
The letter I
Inull

Similar Messages

  • Macbook 2009 case help

    Hey guys, I want to buy this keyboard cover / hard case for my 2009 Macbook (its a 13.3 inch). It says its  for a 13.3 inch Macbook pro, will it fit? I saw some listings for similiar covers that specifically said it wouldnt fit but this particulary one doesn't say anything at all. I don't want to waste any money, I just can't get a for sure answer if it will fit or not. Thanks for any help,
    here's the amazon listing of the cover I want : http://www.amazon.com/gp/product/B005N57X20
    my model ID if needed : A1181

    As the A1181 is a little taller and a rather less streamlined shape compared to the Pro models, I would strongly suggest that this case is not going to fit. If possible you need to find one that states that it is made for the A1181. 

  • IPhone5/5s charger case- HELP

    I bought an iPhone5/5s charger case from eBay for my iPhone 5s. When I use it, it says that 'This cable or accessory is not certified and may not work reliably with this iPhone'. Can anyone help me to fix it please?
    I am going to go to Jessie J's concert wednesday, I need it to work because the battery dies very quick and I need to contact my mum after.
    Can anyone help me please?

    the latest update does this .. stops all third party unauthorised data charger cords. best go buy another from any authorised retail selling apple products store.

  • Dropped iPhone in Case-Help

    Hey guys,I used my iphone 4S and had a cse on it (thinking that the case would work), i dropped it  and know it wont come on.
    Any help would be nessecary. Thnaks.

    Sorry to hear of this, you can try resetting it by holding the sleep/wake button and the home button until the apple reappears but if that does't work you may be out of luck. these phones are delicate, you know.

  • MIN by CASE (HELP)

    TABLE A
    ID     TERM     UNITED
    1     604     LOP
    1     604     MA
    9     704     SC
    9     603     CI
    9     704     BPO
    3     603     LOS
    2     603     KIR
    1     603     SSK
    1     602     MNO
    TABLE B
    ID     CITY
    1     (null)
    1     (null)
    9     603
    9     603
    9     603
    3     (null)
    2     (null)
    1     (null)
    1     (null)
    I WANT:
    ID     TERM
    1     604
    9     (null)
    3     603
    2     603
    1     602
    So where there is a UNITED and NO CITY then display lowest TERM.
    BUT IF there IS A UNITED AND CITY then NULL (eg ID 9)
    What i had:
    SELECT A.ID, min(A.TERM) as TERM
    FROM TABLE A, TABLE B
    WHERE A.ID = B.ID
    AND A.UNITED IS NOT NULL
    AND B.CITY IS NULL
    GROUP BY A.ID
    ORDER BY A.ID
    which gets me:
    ID     TERM     UNITED     CITY
    1     604     LOP     (null)
    1     604     MA     (null)
    1     603     LOS     (null)
    3     603     KIR     (null)
    2     603     SSK     (null)
    1     602     MNO     (null)
    It Does not disply ID 99999
    I know why but i dont know how to ad a case statement to bypass it.
    Can any one help?
    Thank you.
    Edited by: 927374 on 12/04/2012 23:11
    Edited by: 927374 on 12/04/2012 23:13
    Edited by: 927374 on 12/04/2012 23:14

    I am not sure why you expect this row :
    ID     TERM
    1     604Shouldn't the lowest TERM for ID 1 be 602 ?
    may be :
    SQL> ed
    Wrote file afiedt.buf
      1  with tab_a as
      2  (
      3  select 1 ID, 604 term, 'LOP' united from dual union all
      4  select 1, 604, 'MA' from dual union all
      5  select 9, 704, 'SC' from dual union all
      6  select 9, 603, 'CI' from dual union all
      7  select 9, 704, 'BPO' from dual union all
      8  select 3, 603, 'LOS' from dual union all
      9  select 2, 603, 'KIR' from dual union all
    10  select 1, 603, 'SSK' from dual union all
    11  select 1, 602, 'MNO' from dual
    12  ),
    13  tab_b as
    14  (
    15  select 1 id, null city  from dual union all
    16  select 1, null  from dual union all
    17  select 9, 603 from dual union all
    18  select 9, 603 from dual union all
    19  select 9, 603 from dual union all
    20  select 3, null from dual union all
    21  select 2, null  from dual union all
    22  select 1, null  from dual union all
    23  select 1, null  from dual
    24  )
    25  select id,
    26         min(term) term
    27  from   (select a.id,
    28                 a.united,
    29                 Nvl2(b.city, min(null), min(a.term)) term
    30          from   tab_a a,
    31                 tab_b b
    32          where  a.id = b.id
    33          group  by a.id,
    34                    a.united,
    35                    b.city
    36          order  by a.id)
    37* group  by id
    SQL> /
            ID TERM
             1 602
             2 603
             3 603
             9
    4 rows selected.

  • **** iPod Nano- CASE HELP! ****

    I simply have a question concerning an iPod Nano case. This case that I am referring to flips open to reveal the iPod inside. Now, to keep that flap closed, there is a magnet. I am just wondering if having a magnet that close to the iPod Nano could possibly cause any sort of damage. Thanks in advance for your help. =)

    I had a look at this case sounds good, but when checked it out on the web, saw this review.
    I tend to agree, if doesn't protect the screen what use is it.
    Another thing to add about the review, sounds a little like they were promoting this web site, when checking it out, did have a review but has been archived, and they expected to buy $$ to read the cramy opinion.
    If you click RainDayMagazine you notice they only posted on this topic and identical in each stream, purely promoters not ipod users helping others. Although does help find out about cases, finds all the posts on the subject.
    I stick clear of this case. One last thing, you cant see your ipod either through the metal finish of this case.
    Google search on iKeychain case:-
    There have been a lot of rumblings in the Apple community about how easily the iPod Nano’s screen gets scratched so I am surprised that iLounge rewarded this case with an 8 even though it doesn’t offer any protection to the screen. It’s a very stylish case and the keychain aspect of it makes it very chic, but if I can’t read the screen due to it being scratched up then the case serves me no purpose.
    You have to assume that because this case fits on a keychain it will be surrounded by keys and from what I have learned through extensive research over the past 17 months is that keys scratch stuff, .....
    Who be stupid enough to run over their ipod really, please.

  • Cluster + case help

    Hello,
    I am trying to learn clusters and the unbundle by name function using a case structure. For some reason my output cluster's wire is broken and it says the error is incorrect data type, but I am multiplying by a scalar, I do not understand why the error is happening and what to do to fix it.
    Also I have a problem with the case structure. So I want the case structure do something if it is false (As displayed). But, I don't want it to do anything if the case structure is true. How would I go about in wiring and setting up the block diagram for the true case structure?
    I have attached pictures of my front panel and block diagram.
    Hopefully I was clear in my question, if not just let me know!
    I appreciate all help! thank you!
    Solved!
    Go to Solution.
    Attachments:
    block diagram.png ‏103 KB
    front panel.png ‏86 KB

    I want the true case statement to do nothing. I literally just want an if false then this. If true then do nothing. 
    Then put nothing into the TRUE case.  It really is just as simple as that.
    Put something into the FALSE case.
    Do note that *-IF-* you have something coming OUT of the FALSE case (an output from something inside the false case coming thru the case "wall", then you have to supply something for that wire in the TRUE case as well.
    That can be just a default value, or a zero, empty string, whatever, but you have to supply a value.
    But that's ONLY if that wire goes thru the "wall".
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Error : cannot set up certs for trusted CAs, help !

    Hi !
    I am attempting to use the javax.crypto classes in order to decrypt and encrypt
    information.
    But i get the follow message when i change the executing directory :
    -> cannot set up certs for trusted CAs
    If i decompress all follow jar files:
    jce1_2_1.jar;
    sunjce_provider.jar;
    local_policy.jar;
    US_export_policy.jar;
    my applicattion doesn't work. ...
    But if i use jar files, everything is ok and only in a "unique" directories ....
    Why ?
    [email protected]

    Hi Sri,
    I am working on a similar problem. In fact, while I write a simple stand-alone program, everything works fine for me.
    As soon as I embed the very same class into my application, I also get the error you see. The major difference I see between my application and the stand-alone program is the class loading, which my application does via its specialized class loaders. However, I failed to catch the encryption code in my class loader between the call to
    SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(k);
    and the error.
    You have any idea how to track the issue down?
    Regards,
    Jack

  • Macbook Air Case - HELP

    Hello!
    I had my macbook air for about a month when it was splashed with water and completely died the cost of repair was 1300 more then the actual laptop. With this being said dose anyone know of a good WATERPROOF hard shell case of soft sleeve. I have looked on this support comunity/ google/ amazon / ebay and have yet to find one.

    There isn't a case out there which will allow you to use the MacBook Air and offer waterproof protection.
    There is a process called Liquipel or HZO Waterblock, which repels water from electronics itself. There are plenty of Youtube videos that show Liquipel in action.
    They offer the waterproofing service for smart phones and tablets, but not laptops YET.
    Hopefully, soon.

  • Crooked Display & Case, HELP!

    My top screen case doesn't align with my bottom case exactly. The screen closes slightly tilted to the right. Im worried that the hinge for the screen will break faster because something may not exactly be aligned and wear faster.
    I bought this on October 23rd. Can the AppleStore fix it or replace it?

    Contact Apple. I believe the nominal exchange period is 14 days, but I'm not sure. And if it is really bad, they may do a replacement -- or send it for a repair.
    I had my original black MB (2006) repaired twice in 27 months; one was for a failed superdrive and the other wi-fi outage (they replace a major board and gave me a new top case, keyboard and trackpad). In each case it was sent from CA to TN and I had it back in less than a week.
    Phil

  • Swith case help!!!

    i have a piece of code that display the mesage,
    class hose{
         public static void main(String[] args){
              int height, weight;
              final int none=0 ,A=1,B=2,C=3,D=4,E=5,F=6;
         System.out.print("Enter your height : ");
         height=Keyboard.readInt();
         System.out.print("weight : ");
         weight=Keyboard.readInt();
         int x=(int)Math.floor(height/10.0-weight/50.0-2.4);
         int y=(int)Math.floor(height/4.0-weight/20.0-20.5);
         int s=none;
         switch(y){
         case 0:if (x==1) s=A; break;
         case 1:if(x==1) s=B;break;
         case 2: switch(x){
              case 0:s=E;break;
              case 1:s=C;break;
              break;
         case 3:switch(x){
              case 0: s=F;break;
              case 1: s=D;break;
         System.out.print("Your size is ");
         switch(s){
         case A: System.out.println("A");break;
         case B: System.out.println("B");break;
         case C: System.out.println("C");break;
         case D: System.out.println("D");break;
         case E: System.out.println("E");break;
         case F: System.out.println("F");break;
         System.out.println(".");
    expected result :
    Enter your height : 68
    weight : 148
    Your size is D .
    but now the result is
    Enter your height : 68
    weight : 148
    Your size is .
    (it won't display the "D" there, what 's wrong?)

    try to run this and you'll see what happens. My guess is that s is never set to a value, so you'll never go into the right case statement
    class hose {
         public static String getInput(){
              String line = "";  
              java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));  
              try {
                        line = reader.readLine();  
              }catch(Exception e)   {
                        System.err.println("Error while reading: " + e.getMessage());  
              return line;
         public static void main(String[] args){
              int height;
              int weight;
              final int none=0;
              final int A=1;
              final int B=2;
              final int C=3;
              final int D=4;
              final int E=5;
              final int F=6;
              System.out.print("Enter your height : ");
              height=Integer.parseInt(getInput());
                   //height=Keyboard.readInt();
              System.out.print("weight : ");
                   //weight=Keyboard.readInt();
              weight=Integer.parseInt(getInput());
              int x=(int)Math.floor(height/10.0-weight/50.0-2.4);
              System.out.println("x = "+x);
              int y=(int)Math.floor(height/4.0-weight/20.0-20.5);
              System.out.println("y = "+y);
              int s=none;
              switch(y){
                   case 0:
                        if (x==1) s=A;
                        System.out.println("case is 0");
                        break;
                   case 1:
                        if(x==1) s=B;
                        System.out.println("case is 1");
                        break;
                   case 2:
                        System.out.println("case is 2");
                        switch(x){
                             case 0:s=E;break;
                             case 1:s=C;break;
                   case 3:
                        System.out.println("case is 3");
                        switch(x){
                             case 0: s=F;break;
                             case 1: s=D;break;
              System.out.print("Your size is ");
              switch(s){
                   case A: System.out.println("A");break;
                   case B: System.out.println("B");break;
                   case C: System.out.println("C");break;
                   case D: System.out.println("D");break;
                   case E: System.out.println("E");break;
                   case F: System.out.println("F");break;
              System.out.println(".");
    }

  • Wierd case, HELP!

    Hi, in my project, I need to renew Canvas3D on a JPanel, whenever I click on button, I'll call "remove then add(new XXX)", where XXX is a class extends JPanel, and add a new canvas3D on it. The problem is, I can't always see canvas3d being renewed, sometimes it simple become blank. And, the serious problem is, after I click the button 15-18 times, the program Died or jump to DOS. is this a memory issue or limited resource?
    ANYONE HELP!!!
    btw, I didn't add anything in scenegraph, simple new a canvas3d(getpreferredGraphics...) then new a simpleUniverse(canvas), add(canvas).

    well, I think I've tried to removealllocales and all referrence. However, I'm quite sure that my program didn't have any links with the 3d stuffs after I close the popup window, so they should be released, no matter how complecated linkage within the 3d stuffs. And, supprisingly, when I close the window, I'm watching the memory manager, there is more memory consumed(1~15)mega) when I close the popup window! and System.gc() did nothing. I agree it's a resource problem, but why I can't free those memory? nothing in J3dApi document tells me how to free or at least tells me I need to remove before I close it.

  • Business Case - help

    Hello,
    We have a client who wants to use PO for Hotel reservation, where the PO booking a number of nights full inclusive.
    Now when the invoice comes it will include the Food, beverage...etc. which is not predictable ahead at the PO preparation time.
    How such business case can be satisfied in Oracle Purchasing? What happens to Matching? (4-way matching).
    Regards,
    Firas Al Tamimi

    Hi
    Check this note at the time of PO make the entries of food ,beverage with some notional rate by making them as inventory items and at the time of matching make price correction on the ap invoices
    see the following note:-
    How To Correct Unit Price In Received Po
    Doc ID: Note:266335.1 Type: PROBLEM
    Last Revision Date: 06-OCT-2004 Status: PUBLISHED
    The information in this article applies to:
    Oracle Purchasing - Version: 11.5.8
    This problem can occur on any platform.
    Symptoms
    You received against a purchase order with serialized items and the
    purchase order unit price is wrong. You want to know how to correct the
    purchase order unit price after it has been received.
    Cause
    Fully received against a PO and has noticed an incorrect price on
    one of the line items on the PO
    Fix
    To implement the solution, please execute the following steps. There are several suggestions
    within the functionality of the application that can be used to correct the PO line price:
    1. Simple price correction can be made in AP while invoicing against the PO. Select
    Price Correction while in the Invoicing form when matching to the PO.
    Accounts Payables listed the process to create the Price Correction as:
    1) Create an Debit memo or Credit Memo Invoice for the
    appropriate Supplier for debit amount to reduce the previous
    matched quantity
    2) Click the [Match] Button.
    3) In the Invoice Match Find window enter the Invoice
    number (standard) and/or the Po number in the appropriate
    fields and click the [Find] button.
    Both can be used because it is possible that only one or
    the other number is available.
    4) In the Match to Invoice window
    a) check the far left box that has no heading.
    b) Enter the debit amount in the Credit Amount field
    c) Click the [Distribute] Button
    5) In the Match to Invoice Distribution window
    a) check the far left box that has no heading.
    b) check the Price Correction check box (Note that Credit
    Quantity is grayed out)
    c) Enter the debit amount in the Credit Amount.
    d) Click the Final match box if required.
    e) Click OK.
    6) Back in the Match to Invoice window, click the [Match] button.
    This issue is typically handled in AP with a price correction made when invoicing.
    This is the recommended functionality and is what most customers do to handle price corrections
    or variances between the PO and invoices.
    OR
    2. Make a receiving correction of the receiving quantity and correct the receipts to 0 quantity. The problem is that these are serialized items and this particular solution may become awkward in handling the serialized items, but it is supposed to handle the serialized items. When
    the correction is complete, Correct the price on the PO and re-receive it.

  • Iphone 4 Canada shipment & Cases HELP

    Anyone seeing any updates on their Iphone 4 online CANADA orders??? Also what is the best case to get from the case program?? and how long does it take to come. Should I buy another case before my iphone 4 arrives?

    Adlinajolie wrote:
    is there any way that if it is relocked, that apple can do something to unlock it again?.
    There is a possibility that you were sold a phone and it was locked by mistake. It did happen on launch day and a few times after that I am aware of. When I bought my unlocked phone from Apple the guy sales guy had a card with a number of codes on it, ones for locked carriers and the unlocked code for activation.
    Now, if this did happen I'm not sure what to suggest unless you can get the phone back to the store and have them look into it.

  • SQL Decode or Case Help

    Hi.,
    Just confused why the below statement is not producing the correct output..its printing as Hello.
      select decode(to_char(sysdate,'Day'),'Mon','Hi','Hello')
      from dualBut this statement is getting me correct result..
      select decode(to_char(sysdate,'dd'),'26','Hi','Hello')
      from dualAny explantions?..anything to do with to_char ?
    Thanks

    Rather than using TRIM, just use the correct format mask to tell TO_CHAR that you do not want it padded with spaces...
    SQL> select to_char(sysdate,'Day'), length(to_char(sysdate,'Day')) from dual;
    TO_CHAR(S LENGTH(TO_CHAR(SYSDATE,'DAY'))
    Monday                                 9
    SQL> select to_char(sysdate,'fmDay'), length(to_char(sysdate,'fmDay')) from dual;
    TO_CHAR(S LENGTH(TO_CHAR(SYSDATE,'FMDAY'))
    Monday                                   6

Maybe you are looking for

  • Return data from all columns apart from a certain data type.

    Bit stuck on something, hope somebody here can help: I want to do a 'select * from ' a table, to return all columns except ones of a certain datatype. ie. I want to return data from all columns, excluding columns of datatype 'SDO_GEOMETRY'. This give

  • Vendor Invoice Output to non-SAP Application

    Hello,   We want to send the posting status of Vendor Invoices to a non-SAP application. What is the appropriate output condition type, Message type and IDOC type that we can use? Thanks, Venu

  • How can i import and order photo books from older iPhoto versions?

    I have made a photobook which i have not ordered at apple yet. It's on another macbook still running iphoto 07 (unable to update iphoto, because to old for Mavericks)... Somehow i can't import this album on my laptop running iphoto 9.5.1 and order it

  • Newbie Flash Banners Help

    First I am new to Flash and have mostly worked in PS. I have created several animated banners in flash.  The file sizes are large.  I am trying to find a what is the best format and settings to use export these for upload into an website affiliate pr

  • MUVO V200 Help Required

    Hi, I recently purchased a MUVO V200 with 52 mb memory. My first problem was the FM radio would not work, but I have since put this down to it requiring more power from the batteries than standard music. Bit of a pain as my rechargable batteries, eve