Multiple choices in a SELECT list or a DECODE block?

I know I have a lot of questions lately, but I am fairly new to Oracle.
I have this query - it looks awful, but I just want to refer to the DECODE line. This line works, but I have more than one word that is valid. There are actually 3 or 4. Is there a way to allow several choices to be OK? For example, instead of just 'South', what if I wanted North, East, or West to be valid as well?
     CURSOR ALOC_VALID_CURSOR IS
     SELECT SUBSTR(six.SWITCH,1,8) AS COLUMNALOC
     ,six.OCN
     ,one.OCN_NAME
      ,decode(sign(instr(upper(one.OCN_NAME),upper('South'))),1,'Nuvox switch only','Yes') Valid     FROM TRAFFIC.LERG_6 @ traffp six
     ,TRAFFIC.LERG_1 @ traffp one
     WHERE one.ocn_# = six.ocn
     AND SUBSTR(six.SWITCH,1,8) IN ( v_ALoc )
     GROUP BY SUBSTR(six.SWITCH,1,8)
     ,six.OCN
     ,one.OCN_NAME;

SQL> WITH one AS (
  2  SELECT 'South' ocn_name FROM dual UNION ALL
  3  SELECT 'Nord' ocn_name FROM dual UNION ALL
  4  SELECT 'West' ocn_name FROM dual UNION ALL
  5  SELECT 'East' ocn_name FROM dual UNION ALL
  6  SELECT 'Bananas' ocn_name FROM dual UNION ALL
  7  SELECT NULL FROM dual
  8  )
  9  SELECT ocn_name,
10  decode(1,sign(instr(upper(one.OCN_NAME),'SOUTH')),'Nuvox switch only',
11           sign(instr(upper(one.OCN_NAME),'NORD')),'Nuvox switch only',
12           sign(instr(upper(one.OCN_NAME),'WEST')),'Nuvox switch only',
13           sign(instr(upper(one.OCN_NAME),'EAST')),'Nuvox switch only','Yes'
14  ) ocn_name_check,
15  decode(upper(one.OCN_NAME),
16         REPLACE(
17         REPLACE(
18         REPLACE(
19         REPLACE(upper(one.OCN_NAME),'SOUTH'),
20         'NORD'),'WEST'),'EAST'),'Yes','Nuvox switch only') ocn_name_check
21  FROM one
22  /
OCN_NAM OCN_NAME_CHECK    OCN_NAME_CHECK
South   Nuvox switch only Nuvox switch only
Nord    Nuvox switch only Nuvox switch only
West    Nuvox switch only Nuvox switch only
East    Nuvox switch only Nuvox switch only
Bananas Yes               Yes
        Yes               Yes
6 rows selected.However, my personal choice would be to create a view using a case statement ( due to readability) and use this view in plsql code.
Best regards
Maxim

Similar Messages

  • Select multiple values in mult-select list

    I have the following query as the source for a multi-select page item:
    SELECT person.person_id
    FROM person, pers_proj_task
    WHERE pers_proj_task.person_id = person.person_id
    AND pers_proj_task.project_id = :P3_PROJECT_ID
    The query returns two records and the page item's session value is 4:3, but only the value 4 is highlighted in the mulit-select list. How can I get both values to be highlighted?

    Got it to work for a multi-select item by following Dimitri's post which uses a shuttle example. It was still only highlighting one value, but I tried Patrick Wolf's suggestion from the comments on Dimitri's post to put the pl/sql block in the source of the item rather than as a computation and it worked.
    So I now have a multi-select list which has default values pulled from a LOV. The items that are highlighted by default are selected by using the following pl/sql block in the "source/value or expression" of the :P3_PERSON_ID multi-select item:
    declare
    person_list apex_application_global.vc_arr2;
    i number := 1;
    begin
    for r in ( SELECT person.person_id
    FROM person, pers_proj_task
    WHERE pers_proj_task.person_id = person.person_id
    AND pers_proj_task.project_id = :P3_PROJECT_ID)
    loop
    person_list(i) := r.person_id;
    i := i + 1;
    end loop;
    return APEX_UTIL.TABLE_TO_STRING(person_list,':');
    end;
    Thanks to Amanda, ArtS, Dimitri and Patrick.
    Jeremy

  • Resolved: Use value from select list in pl/sql block

    Hello,
    I have a form with a select list: P18_BONUSTYPE, the values of which come from a LOV.
    When the user clicks a button, a page process is used to insert a row into a table.
    When I use the :P18_BONUSTYPE bind variable in my insert statement I get an error "Invalid number" I get an "Invalid number" error. I assume that APEX is using the displayed text in that bind variable, not its actual (html option) value.
    I checked the HTML of the page, and the correct values are in the select list.
    Can someone tell me how to get the value into a bind variable that can be used in a pl/sql block for a page process?
    Thanks
    Message was edited by:
    Neeko
    Issue was a value in another item.

    Did you tried changing the value using "to_number"? (i.e. to_number(:P18_BONUSTYPE)).
    Max.

  • Multiple Choices in either Dropdown list or List box

    I'm working on a form which will need to be reviewed and accepted by multiple people. I'd like to have a dropdown list or list box with all the known names of those reviewing, where all names can be selected, one by each reviewer so eventually all names will be picked, and the form approved.
    Open to any help I can get. This is new territory for me. Thanks in advance,
    gb

    err... should it be allowed to deselect?
    If yes I'd do it with checkboxes, if not I'd do it with a dropdownlist that populates calculated Textfields.
    Though there already was a solution for multiple selections of a dropdownlist in the past... I'll search it, if you want.
    Any more requirements? (F.ex. should the next user be not able to see who has already had it?)

  • Apex_item select list to be displayed with multiple default values

    I am using APEX 4.2.
    For one of our requirements , we are displaying a report which uses "apex_item.select_list_from_query" multiselect field.
    The above function accepts a parameter, 'p_value' using which we can specify the default value to be highlighted.
    Is there any way to highlight multiple values on the select list by default, when the page is loaded, based on a sql output.
    Sample Scenario:
    Say colour is a multiselect field. Full list of values available : R, B, G, Y, O
    On day1, for record1 i am choosing R and B. which I am saving in the backend when the page is submitted.
    On day2 : I login again to see the report. When the report is loaded, I should see the values 'R' and 'B' highlighted or in a different font format , differentiated from the rest.
    Thanks in advance for your replies.
    Regards,
    Raasi
    Edited by: 878815 on Mar 11, 2013 10:23 PM

    878815 wrote:
    I am using apex_item.select_list_from query. and then a piece of javascript to concatenate as a colon delimited string. This is the function I am using in the report sql,
    apex_item.hidden(20,null)||apex_item.select_list_from_query(6,null,'<sql>','multiple size = "6" onChange="Multi(this)"','NO' ) as col_1I think 'multiple size' is a custom attribute and APEX have no clue about it.
    javascript code:
    function Multi(p_this)
    var l_selected=html_SelectValue(p_this);
    if (l_selected.constructor == Array) l_selected=l_selected.join(':');
    p_this.parentNode.firstChild.value = l_selected;
    return l_selected;
    };What is this apex_item.hidden used for.. placeholder?
    May be populate the hidden item with default value as colon delimited string and on page load use some JavaScript to read that string and set/highlight the select list.
    It would be easy if you can replicate the issue on apex.oracle.com

  • Pass Select list value to URL as a parameter

    I am trying to pass the selected value from a select list via a button to a URL.
    &P_VALUE=&P_VALUE.
    P_VALUE is set to USER SESSION.
    It shows as prevous session value. If I show the the session value is not set to the selected value.
    If I call a PDF report via a button, it displays the correct value and the session values is correct.
    If I select the button for the URL again, is shows the previous value.
    When I go back to the form and call select the button again, the correct parameter is passed to the URL.
    Any Ideas?
    Thanks,
    Jerry

    If you use substitution at the time, the button gets generated, you don't have the new value - the button is generated with the rest of the page, and then later the user changes value of the select list. You have two choices:
    1)Use Select list with submit - and transfer the user to second page using branch (which get's calculated after submit when select list has already the new value)
    2)Use Javascript to catch the onChange/onClick event of SelectList, read the current value and do the redirect from JavaScript.

  • Cascading select lists - HELP

    I keep missing something from the samples i have seen on the internet on cascading select lists
    I simple need one select list to determine the choices of another select list, Please use simple terms.
    Thanks for your help. Please need asap.

    Hi,
    OK - first you should have a hidden item on page 2 that will receive the country code (I'll stick with my example, if that's ok) - say P2_COUNTRY_CODE.
    Now create two select lists - say P2_STATE_CODE and P2_CITY_CODE.
    It helps if you ensure that the P2_STATE_CODE list is set with a default value to ensure that the list can be filtered correctly. Create a Computation, to run in the "Before Header" process point and conditional on P2_STATE_CODE being null (Condition Type: Value of Item in Expression 1 is NULL; Expression 1: P2_STATE_CODE). Set the value to a "Static Assignment" of something that won't appear in the list (eg, ZZ for strings or -1 for numerics). You can do this on the Cities list as well if you like. Both lists should be set to display null values and have something like -Select- as the null display text.
    Your States list should be created as a Select List with Submit with a List of Values based on a SQL statement:
    SELECT STATE_NAME d, STATE_CODE r FROM STATES WHERE COUNTRY_CODE = :P2_COUNTRY_CODEYour Cities list is a normal Select List with a List of Values based on a SQL statement:
    SELECT CITY_NAME d, CITY_CODE r FROM CITIES
    WHERE COUNTRY_CODE = :P2_COUNTRY_CODE
    AND (:P2_STATE_CODE = 'ZZ' OR STATE_CODE = :P2_STATE_CODE)Now, when the user selects a country from page 1, the country code is passed into P2_COUNTRY_CODE before page 2 is loaded. The default values for P2_STATE_CODE and P2_CITY_CODE are set and the lists are generated - the Cities list will display all cities for the Country selected as the States list will only show the default of ZZ and this "matches" every city in the country. Then, when the user selects an item on the States list, the page is submitted and the value for P2_STATE_CODE is updated in session. As the Cities list is based on this value, when the page is reloaded, it will be updated to filter based on the P2_COUNTRY_CODE and P2_STATE_CODE values.
    The only thing you have to ensure is that P2_STATE_CODE and P2_CITY_CODE are cleared from cache when you no longer need the page - you can do this in the branch back to page 1.
    Andy

  • How to enter the following question as a multiple choice

    Hi everyone,
    I have the following question and a couple of limitations. Can you help me?
    How do I do this?
    Allocate the terms to the units
    A
    B
    C
    1
    Heat Capacity
    F
    W
    2
    Heat Quantility
    Q
    Wh
    3
    Heat Current Density
    q
    W/m²
    4
    Heat Flow
    F
    J/s
    5
    Heat Energy
    Q
    J
    Question: Which unit and which Welche Einheit und welches formula symbol label the term (A1 to A5 will be randomly shown) [multiple answers are possible]?
    Answers: (B, C  1 to 5) are shown as Mulitple Choice
    Assessment:
    Question A1, correct Answer B,C 1 and 4
    Question A2, correct Answer B,C 2 and 5
    Question A3, correct Answer B,C 3
    Question A4, correct Answer B,C 1 and 4
    Question A5, correct Answer B,C 2 and 5
    If the answer is wrong a text and a graphic has to be shown.
    If not everything is possible here are the questions I am struggling with:
    1) How do I script to show a graphic once the wrong caption is shown?
    2) How can I script to find out which Multiple Choice item is selected (a number or alike, so that I can script to find out if a certain number combined with a certain term is combined?
    3) How can I script something random (if random(4) == 1 then myVar="heat capacity")?
    4) How do I combine an advanced action to an answer?
    Thanks a lot
    MR_TD

    Hello again,
    Certainly not yet an answer to all your questions, have been musing a little bit already but had to do some work for college too.
    You could use the default Multiple Choice question slide, with possibility for more than one answer. Showing a correct and a incorrect caption is not a problem. But you also want to show a graphic after that, thus after the user clicks on the slide or enters Yes (normal way to continue). Can the graphic be on another slide? Than you could insert this slide immediately after the question slide and program that when the answer is correct the user jumps over this slide. If you report to a LMS, you could report everything, so that the answers will be visible on the LMS-report. This would be the easiest way. I do not see any solution (for the moment) to have the questions 'randomized'. Shuffling is possible on some question slides, but you want to shuffle the question slides themselves. Perhaps: create a pool with the question slides and get questions out of that pool, they will then automatically be unpredictible.
    The other more complex way: create your own question slides with text captions, click boxes, advanced actions that populate some user variables. Do see possibilites, except again for the randomizing, the shuffling of the questions slides. Showing first a caption, then a graphic on the slide, based on the correct/incorrect answers is certainly possible. Storing the exact answers in user variables would be possible too: what do you exactly want to do with this 'knowledge'?
    Perhaps I'll get some fresh ideas tomorrow,
    Lilybiri

  • Multiple select list in Safari 8.1 is broken again

    Multiple select list is broken again in iOS 8.0.* and 8.1 Safari.
    Few temp solutions can be found here until apple fixes this issue again.
    Multiple Select box does not retain selected choice
    Multiple Select on Safari - iPhone iOS 7

    Reinstalling OS X Without Erasing the Drive
    Boot to the Recovery HD: Restart the computer and after the chime press and hold down the COMMAND and R keys until the menu screen appears. Alternatively, restart the computer and after the chime press and hold down the OPTION key until the boot manager screen appears. Select the Recovery HD and click on the downward pointing arrow button.
    Repair the Hard Drive and Permissions: Upon startup select Disk Utility from the main menu. Repair the Hard Drive and Permissions as follows.
    When the recovery menu appears select Disk Utility. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the main menu.
    Reinstall OS X: Select Reinstall OS X and click on the Continue button.
    Note: You will need an active Internet connection. I suggest using Ethernet if possible because it is three times faster than wireless.
    Also see:
    Reinstall OS X Without Erasing the Drive
    OS X Yosemite- Reinstall OS X
    OS X Mavericks- Reinstall OS X
    OS X Mountain Lion- Reinstall OS X
    OS X Lion- Reinstall Mac OS X
         Note: You will need an active Internet connection. I suggest using Ethernet
                     if possible because it is three times faster than wireless.

  • Populate a Floating Field from Multiple Choices in a Drop Down List

    Hi, folks, it's been a while which means things have been going smoothly. But what I'm trying to do at the moment has me stumped.
    I have a form that was originally made with a long section of checkboxes that our agents would check if the answers applied to the client's case. This meant that the client had a whole bunch of information that didn't apply to them on the form so I thought would be clearer for the client if the agent would select only those items that pertained to them in a List Box. I used a List Box for multiple choices because several choices could apply to their case. And I wanted those selections to relayout to a floating text field in a paragraph but for the life of me, I can't seem to make that happen. I tried switching to a Drop Down Field and that allows only one selection to relayout.
    The paragrah reads "To proceed, we need the following information or the documents identified below:" and then the 15 items would be listed with the checkboxes.
    Any suggestions as to how I should do this?

    What if you leave them as checkboxes and just put a pre-print event in each of the 15 items to make them visible or hidden based on their value?
    Like this:
    Jo

  • How to make a keyboard navigating multiple choice list in Flash and control it through actionscript?

    i am making an rpg style game in actionscript 3.0 and i want to make a multiple choice list. I know how to make the list with buttons and how to control it. My question is, how do you make a list that can be navigated using the keyborad arrows? What i am after is being able to hit up, and down to highlight the buttons and enter to chose the button.

    You'll need to make the buttons as movieclips so that you can control which display state they are in (highlighted versus not).
    Then you need to set up a listener for the keyboard keys so that you can have the selected button change and the execute if the Enter is pressed.  Here is a basic setup for a keyboard listener that shows how to detect the three keys you mentioned...
    stage.addEventListener(KeyboardEvent.KEY_DOWN,keyIsDown);
    function keyIsDown(e:KeyboardEvent):void  {
             if (e.keyCode == Keyboard.DOWN) {
                     trace("DOWN");
             } else if (e.keyCode == Keyboard.UP) {
                     trace("UP");
             } else if (e.keyCode == Keyboard.ENTER) {
                     trace("ENTER");

  • Multiple-Selection List Box Values in Multiple Columns

    I am using InfoPath 2010 with SharePoint 2013. I have a form with a multiple-selection list box which has A LOT of choices. Instead of displaying all the choices in one column, is it possible to display the values of my list box in several
    columns? 

    Hi Andrea,
    I agree with Brij, one multiple-selection list box is associated with one list field, we cannot use the one multiple selection list box value for other multiple selection list boxes, we need to create multiple choices for each multiple-selection list box
    control in InfoPath form.
    Thanks
    Daniel Yang
    TechNet Community Support

  • Set focus on item that selected in multiple-selection list box field in infopath

    Hi
    I have  multiple-selection list box field in infopath that have for example 40 items. (I customize sharepoint list with infopath),then
     publish infopath form in to sharepoint list. users want to add new item,when they selected or checked each item in multiple selection list box, after that automatically control focus on first item, but I want to focus remain on that item
    I was selected. Why this happen?! I also set postback settings to “never” in multiple-selection list box properties. But didn’t work.
    Thanks.

    Hi,
    According to your post, my understanding is that you wanted  to find several columns based on user selection of checkboxes in one of the Multiple-selection List Box.
    I recommend to customize the form to concatenate values from choice field (with multiple values) into single line text box, and then hide the fields based on the text box value.
    We can follow the steps as following:
    Add a text box control(filed 3) on the form to hold the value selection in the multiple selection list box.
    Set the default value for the text box control as
    substring-after(eval(eval(Value, 'concat(., ";")'), ".."), ";")
    (you need to change the ‘Value’ in the formula to your multiple selection list box name: filed1).
    Add the conditional formatting on the flied: flied 3 does not contain value (you need to change the ‘Value’ in the formula to your multiple selection list box value.).
    In addition, you can add Formatting action to hide the text box control.
    Here are the result screenshots for you to take a look at:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to select multiple addresses from the contacts list to send an email?

    How do I select multiple addresses from the contacts list at one time to send an email. Each time I select one, the address book closes and I have to touch the "+" key to open it back to select another address. Is there a way to select all of them at one time instead of making a group? Thanks.

    Yes, once you select a person from your Contacts app, you either need to select more from the '+' button or you can tap in the 'to:' field and type in the first few letters of a contact and select from the list. Kinda bummer but gotta make do.

  • How can i display Value in Report which i select from Multiple select list

    Dear All,
    i am using multiple select List in form with report page.
    When i create new Entry with select Multiple value in Multiple Select List then in report Value display me in below format
    my SQL Query are
    select NAME D, CODE R from  COUNTRY_MAS WHERE ACTIVE_FLG ='Y' order by NAME
    AS:AI:AG:AM these are return value .i want to display NAME in report .
    How can i do this ?
    Thanks
    Edited by: Vedant on Apr 25, 2012 11:14 PM

    Short answer, use the apex_util.string_to_table to convert to a table; then you can either iterate through the table to generate a string of names, or accomplish the same with a bulk operation.
    http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_util.htm#CHDFEEJD
    Encapsulate all this within a pl/sql function.

Maybe you are looking for