Case statements complicated for numbers


Hi guys

I have a table of test as follows

CREATE TABLE TestTable
('Bill_date' datetime, int 'Phone_no', 'Planlvl1' varchar (10), 'PlanLvl2' varchar (12), 'revenue' varchar (3))
;

INSERT INTO TestTable
('Phone_no', 'Planlvl1', 'Bill_date', 'PlanLvl2', 'recipes')
VALUES
('2014-01-01 13:00 ', 64221, 'Bundle', 'SpecialPack1', ' $23 ' ").
('2014-01-01 13:00 ', 64221, "Bundle", "PlanA", "$32 '").
('2014-01-01 13:00 ', 65211, 'Bundle', 'SpecialPack2', ' $3 ' ").
('2014-01-01 13:00 ', 65211, 'Bundle', 'SpecialPack1', ' $23 ' ").
('2014-01-01 13:00 ', 66211, "Bundle", "PlanB", "$34 '").
('2014-01-01 13:00 ', 66211, 'Bundle', 'SpecialPack2', ' $3 ' ").
('2014-01-01 13:00 ', 66222, 'Bundle', 'SpecialPack1', ' $23 ' ").
('2014-01-01 13:00 ', 66222, 'Bundle', 'SpecialPack2', ' $3 ' ").
('2014-01-01 13:00 ', 66222, "Bundle", "PlanB", "$65 '").
('2014-01-01 13:00 ', 32444, 'Non_bundle', 'Casual1', ' $32 ' ").
('2014-01-01 13:00 ', 324441, 'Non_bundle', 'Casual2', ' $76 ' ").
('2014-01-01 13:00 ', 65444, 'Non_bundle', 'Casual1', ' $12 ' ").
('2014-01-01 13:00 ', 65444, "Bundle", "PlanB", "$98 '").
('2014-01-01 13:00 ', 54322, "Bundle", "PlanA", "$12 '").
('2014-01-01 13:00 ', 54322, 'Non_bundle', 'Casual', ' $12 ' ")
;

Basically, I have to count all phone numbers that are grouped by the plans in a way:

If PlanLvl1 = Bundle, so I look at planLvl2 and see if that phone no a 'SpecialPack %', and also another plan, their "special pack" Gets the priority and the phone is counted in the special package.

In the case when PlanLvl1 = package and not a phone has these two "packages" that their plans, and then the phone will be taken into account in the "special Pack" with higher incomes.

In the case where PalnLvl is "Bundle" and no phone has several "special packages" and a special not that ph will only be counted once under "special Pack; the higher rev against the special pack of rev lower.

Now, there is also PlanLvl1 which are "Non_Bundles", which means that they have not any "SpecialPacks", but it takes if a ph not with 'NonBundle' plan has 2 different plans under planLvl2, as the ph for eack planLvl2...

There is a scenario where a ph can have packages and bundles, and in this case, just count the ph not bunched and not in non-bottes.

This is the expected result:

Bill_date PlanLvl2 PhonenoCount

01/01/2014 SpecialPack1 3

01/01/2014 SpecialPack2 1

01/01/2014 Casual1 0

01/01/2014 Casual2 1

01/01/2014 planA 1

01/01/2014 PlanB 1

Hope this helps

Thank you guys

... However I think I have my required output involved. ...

I got your melee entry - I thought the longer phone_no was a typo

with testtable (Bill_date, Phone_no, Planlvl1, PlanLvl2, revenue) as

(select date ' 2014-01-01', 64221, 'Bundle', 'SpecialPack1', ' $23 ' double union all ')

Select date ' 2014-01-01', 64221, "Bundle", "PlanA", "$32 ' double union all.

Select date ' 2014-01-01', 65211, 'Bundle', 'SpecialPack2', ' $3 ' from dual union all.

Select date ' 2014-01-01', 65211, 'Bundle', 'SpecialPack1', ' $23 ' double union all.

Select date ' 2014-01-01', 66211, "Bundle", "PlanB", "$34 ' double union all.

Select date ' 2014-01-01', 66211, 'Bundle', 'SpecialPack2', ' $3 ' from dual union all.

Select date ' 2014-01-01', 66222, 'Bundle', 'SpecialPack1', ' $23 ' double union all.

Select date ' 2014-01-01', 66222, 'Bundle', 'SpecialPack2', ' $3 ' from dual union all.

Select date ' 2014-01-01', 66222, "Bundle", "PlanB", "$65 ' from dual union all.

Select date ' 2014-01-01', 32444, 'Non_bundle', 'Casual1', ' $32 ' double union all.

Select date ' 2014-01-01', 324441, 'Non_bundle', 'Casual2', ' $76 ' double union all.

Select date ' 2014-01-01', 65444, 'Non_bundle', 'Casual1', ' $12 ' dual union all.

Select date ' 2014-01-01', 65444, "Bundle", "PlanB", "$98 ' double union all.

Select date ' 2014-01-01', 54322, "Bundle", "PlanA", "$12 ' dual union all.

Select date ' 2014-01-01', 54322, 'Non_bundle', 'Casual1', ' $12 ' from dual.

)

Select t.bill_date, t.planlvl2, count (counted) cnt

from (select distinct bill_date, planlvl2

from testtable

) t

left outer join

(select bill_date,

-case when (instr (mess, 'Non_bundle') = 0

and instr(mess,'SpecialPack1') > 0

and instr(mess,'SpecialPack2') > 0

)

or (instr (mess, 'Non_bundle') = 0

and instr(mess,'SpecialPack') > 0

)

then regexp_substr (mess,'(: (SpecialPack\d),)', 1,1, 'i', 2).

When instr (mess, 'Bundle') = 0

then regexp_substr (mess, '(:(.+?))', 1,1, 'i', 2)

When instr(mess,'Bundle') > 0

and instr(mess,'Non_bundle') > 0

then regexp_substr (mess,'(Bundle:)(.+?),', 1,1, 'i', 2))

counted end

from (select bill_date,

phone_no,

listagg (planlvl1: ': ': planlvl2, ',') within the Group

(order by to_number (ltrim(revenue,'$')) desc) | ',' mess

from testtable

Bill_date group, phone_no

)

) c

on t.bill_date = c.bill_date

and t.planlvl2 = c.counted

T.bill_date group, t.planlvl2

order of length (t.planlvl2) desc, t.planlvl2

BILL_DATE PLANLVL2 CNT
01/01/2014 SpecialPack1 3
01/01/2014 SpecialPack2 1
01/01/2014 Casual1 1
01/01/2014 Casual2 1
01/01/2014 PlanA 1
01/01/2014 PlanB 1

The query should still be reviewed - SpecialPack2 is currently preferred bacause of its best recipes (not because if that's the name)

Concerning

Etbin

Tags: Database

Similar Questions

  • Case statement for aging buckets

    OBIEE 11 g. I am trying to create a case statement with aging buckets. Tried in the frontend and the RPD, but on the first bucket made its appearance. (1-30 days old). The other 3 buckets do not appear.

    30 - 60 days old

    60 - 90 days old

    90 - 120 days old

    There are dates in the database who meet the criteria for the other 3 buckets. This is the case statement.

    
    

    use the below the formula instead of what you pasted...

    cases where "Date of creation". ' ' Created Date ' > = TIMESTAMPADD (SQL_TSI_DAY-30, CURRENT_DATE) then 1-30 days old '

    When "Date Created". " Created Date' <= timestampadd(sql_tsi_day,="" -30,="" current_date="" )="" and="" "created="" date"."created="" date"="">= TIMESTAMPADD (SQL_TSI_DAY,-60, CURRENT_DATE) then 30-60 days old '

    When "Date Created". " Created Date' <= timestampadd(sql_tsi_day,="" -60,="" current_date="" )="" and="" "created="" date"."created="" date"="">= TIMESTAMPADD (SQL_TSI_DAY,-90, CURRENT_DATE) then from 60 to 90 days old '

    When "Date Created". " "Created Date" <= timestampadd(sql_tsi_day,="" -90,="" current_date="" )="" and="" "created="" date"."created="" date"="">= TIMESTAMPADD (SQL_TSI_DAY,-120, CURRENT_DATE) then 90-120 days old ' end

    Thank you

    AJ

  • case statement for States

    Hi all

    I am filling a text field based on what the user chooses a drop down which contains the 50 United States of America.

    So... Let's say for now I mean 'Birmingham' if the user selects "Alabama", the text field.

    The only thing I have at the moment is completely false:

    setText() function

    {

    var statechoice = State.value;

    Switch (statechoice) {}

    case 1:

    Text1.RawValue = "deposit is required in Alabama."

    breaking

    case 2:

    Text1.RawValue = "very cold and the deposit is required in Alaska."

    breaking

    by default:

    Text1.RawValue = "choose a please state";

    breaking

    }

    Must it always be the case 1, 2, 3 and so on? It can never be "case (something is true and something is equal to 7):?  I mean, what I always use integers to distinguish the cases?
    later I want to fill down based on choices that makes the user. I want to have a list of conditional statements where each conditional expresses a unique combination of choice that the user has made.
    Do you like cold food? Yes
    Lactose intolerant? NO.
    Field of text says "having a cone of ice cream for dessert."
    How can I get integer values in a drop-down? DropDown.Value? DropDown.index? dropdown.selectedIndex?
    How to combine these choices in the instructions box? If (dd1 = 1 and 4 = dd2 and dd3 = 2):?
    Sorry for this discursive question,
    I just need a good example to follow.
    Thank you very much
    Joe

    You can try something like below...

    Otherwise, the Switch statement only evaluates to the value that is passed next to the switch control...

    var statechoice = State.rawValue;
    Switch (statechoice) {}
    case "AL":
    Text1.RawValue = "deposit is required in Alabama."
      Text1.RawValue = Text1.rawValue + setText();
    break;
    case "AK":
    Text1.RawValue = "very cold and the deposit is required in Alaska."
    break;
    by default:
    Text1.RawValue = "choose a please state";
    break;
    }

    Added a function inside the same event and call this function in the switch case statements above.
    function setText() {}
    Switch (otherDropDown.rawValue) {}
    case study "Yes":
    return "selected Yes;
    break;
    by default:
    Return "No selected ';
    break;
    }
    }

    I hope this helps...

    Thank you

    Srini

  • Field values for replacement Case statement

    Hey,.
    I need assistance with a CASE statement to display some values of field based on another field value.
    This is data of table DEPT
    DEPTNO       DNAME              LOC
    10               ACCOUNTING     NEW YORK
    20               RESEARCH         DALLAS
    30               SALES               CHICAGO
    40               OPERATIONS     BOSTON
    It comes to my select statement.
    SELECT DEPTNO, DNAME,  
    (CASE LOC
        WHEN 'NEW YORK' THEN ''
      --WHEN LOC = 'NEW YORK' THEN DEPTNO = ''
      --WHEN LOC = 'NEW YORK' THEN DNAME = ''
    END) AS LOC
    FROM DEPT
    When I Uncomment the two lines I get an error message. The results are
    DEPTNO       DNAME              LOC
    10               ACCOUNTING     -
    20               RESEARCH         -
    30               SALES               -
    40               OPERATIONS     -
    I don't want to delete all the values for the LOC. I want to display a value for DEPTNO and DNAME If LOC = "NEW YORK". Has anyone ever done this before?
    Good results...
    DEPTNO       DNAME              LOC
    -                  -                      NEW YORK
    20               RESEARCH         DALLAS
    30               SALES               CHICAGO
    40               OPERATIONS     BOSTON

    Like this?

    SQL> ed
    Wrote file afiedt.buf
    
      1  SELECT CASE WHEN LOC != 'NEW YORK' THEN DEPTNO END AS DEPTNO
      2        ,CASE WHEN LOC != 'NEW YORK' THEN DNAME END AS DEPTNO
      3        ,LOC
      4* FROM DEPT
    SQL> /
    
        DEPTNO DEPTNO         LOC
    ---------- -------------- -------------
                              NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
            50 IT SUPPORT     LONDON
    
    SQL>
    
  • Months of searching for numbers on the sheet

    Hello all and thanks in advance.

    I have tabs at the top. DATA (sheet 1), JAN (sheet 2), FEB (record 3), etc. until the end of the year.

    Data sheet will be the months on the left now I want care to go to the form to correct month and takes the total of the column relative to the other leaves and place in the correct cell line. (I've been copy paste, but I know there is an easier way to do this, so I turn to the people who know the numbers unlike my lack of knowledge.)

    On the leaves of the month, I would also like to highlight the line that are sat and Sun.

    Thanks again everyone for their help.

    Rich

    In the material master

    Hi, NN,.

    You will have a Table for each month. Each Table must have a different name. Your summary table lists more than 12 months, then I would say the table name from each month is named with the name of the month AND the year.

    The monthly tables may appear on separate sheets, or the same sheet. The key, as far as the formulae are concerned, is that each Table can be identified by its name.

    The following example includes only the table for April 2016, named "APR 2016", I assumed that the total line will be row 33 on each table of data collection, but wrote the formula to allow the placement of the line totals in other places. The lines for most of the actual days have been hidden and has not been designated, as these labels have no role in the operation of the formula.

    The TOTALS is defined as a footer line. The formula, in the columns showing a value is SUM (a) where 'a' is the letter of the column to be added. (The two values of zero have been entered manually for example).

    The table has a unique formula, entered in cell B3 and filled with right and until the last line for which there is a Table whose name corresponds to the label in column A. For example, the formula has been met only 3 online.

    B3: = INDEX (APRIL 2016: $A$ 1: $ 33, MATCH $N ("TOTALS", APRIL 2016: $A, 0), GAME ($ 1 B, APRIL 2016: $1: $1.0),)

    Syntax:

    INSTRUCTION (range,-l'index of the line, column-index, index of the surface)

    range: all of the cells in the source table

    the index of the line: the number of the start line to get the value. This is provided by the first statement of the GAME.

    the index of the column: the number of the column from which to get the value. This is provided by the second statement to MATCH.

    the index of the surface: omis. By default, 1. There is only 1 area of application of this INDEX, all of the source table.

    MATCH (image search-search for, - where - method)

    EQUIV function returns the position in the list of the search for value.

    First case:

    search for: TOTALS text

    search - where: column A of table source

    method): 0 means finding the exact value.

    Second case:

    search for: the text contained in the cell of line 1 of the specified column. That form is completed on the right, the increments of the column by one for each stage.

    search - where: line 1 of table source

    method): 0 means finding the exact value.

    The formula should be changed for each new line. Three references to "APR 2016" should be changed to match the name of the table to collect this row grand totals. Once edited in column A, the formula can be filled right and automatically adapts to his new position.

    Note: The duration value in column F of the table of the month wouldn't transfer and keep the same formula in column C of the summary table. Any attempt to restore the format to match your example resulted in a triangle of error.

    Kind regards

    Barry

  • Use the control of timing DAQmx as input in case statement

    Hello

    I'm building a VI aquire sampled under tension of a sensor in continuous mode or finished.  I was going to do this, use a box with a cable of the sample mode of the VI DAQmx calendar entry to the terminal State, the idea being that I couldn't aeither a while looping the case for continuous or simple acquisition according to the setting of this command.

    However, instead of the sample mode provided for in the case of the case statement, I just get 1 and 0.

    It's a good way to achieve this, and if so how can I get my case structure working properly?

    Thank you

    Dave

    Hi Dave,.

    Apologies - I consider that the error is from the data acquisition function? I forgot that she was using the sample entry mode.

    Perhaps, then, it will be preferable to continue using the control of the ring - cases will be numbered and will correspond to the numeric value of the selection of the ring (i.e. finite samples = 0). I have attached a small example if we know not.

    Moreover, the structure of the case cannot automatically fill for each case, in which case you can right click on the structure of the case-> add the case after.

    Best regards

  • Can I use a hexadecimal string with a case statement?

    Simple question:

    Can I enter a hexadecimal string to a case statement and have the case statement see it as hex?

    I understand that I could convert the hexadecimal string to a number and then enter the hexadecimal number to the case statement but I am curious to know if I could have the case see the string itself as hex without this added feature.

    Would be nice to not have to convert all my numbers throughout my code strings

    Thank you

    -Eric

    How long are the strings? Since you mention convert in numbers, they are probably short and all of same length.

    Are there different possible channels how?

    Case header includes \-codes in the case of a label deal selector As string, so that should be enough for your use. For example this code turns the LED (.. .so that a simple string of "\00\00" of wiring would not be!)

    (See also the last sentence of the "enumerated values" section of the help).

  • Select with case statement and a formula of the IIR

    Hi, I was looking to get help regarding a statement writing box with a statement select statement all. I tried to reproduce a formula IIf access well that just wanted to check that the query I wrote is correct, any advice would be appreciated.

    [code]

    Select *.

    Of

    (

    Select name, month, duration, volume, time_spent, date1, date2,.

    -case when 'date' > = 'date1' then '1' other '0' end as departure,.

    -case when 'date' < = "date2" then '1' other '0' as end ending

    Of

    (

    Select *.

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    )

    )

    ;

    [/ code]

    I want to know is where I have my ' select name, etc, I would change that to select * to make it easier instead of typing all the field_names outside, but I don't know how to do and also what follows is 2 IIF formulas from an access database for the start of the final case statements so I just wanted check I wrote it correctly.

    [code]

    departure: IIf ([date] > = [date1], 1, 0)

    [/ code]

    [code]

    ending: IIf ([date] < = [date2], 1, 0)

    [/ code]

    Any advice would be appreciated.

    Hello

    Whenever you have any questions, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    Explain, using specific examples, how you get these results from these data.

    If the output depends on what anyone outside the application itself (for example, when it is run) and then include a few different examples and the results you want of each given the same sample data. For example, "if I run on November 19, 2013, while the results should be... because... but if I run between November 21 and November 27, then the results should be... because...". »
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

    318f20b8-a3d0-4FB4-bb0f-73785250b7d4 wrote:

    Hi, I was looking to get help regarding a statement writing box with a statement select statement all. I tried to reproduce a formula IIf access well that just wanted to check that the query I wrote is correct, any advice would be appreciated.

    [code]

    Select *.

    Of

    (

    Select name, month, duration, volume, time_spent, date1, date2,.

    -case when 'date' > = 'date1' then '1' other '0' end as departure,.

    -case when "date."<= 'date2'="" then="" '1'="" else="" '0'="" end="" as="">

    Of

    (

    Select *.

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    )

    )

    ;

    [/ code]

    I want to know is where I have my ' select name, etc, I would change that to select * to make it easier instead of typing all the field_names outside, but I don't know how to do and also what follows is 2 IIF formulas from an access database for the start of the final case statements so I just wanted check I wrote it correctly.

    [code]

    departure: IIf([date]>=[date1],1,0)

    [/ code]

    [code]

    ending: IIf ([date]<>

    [/ code]

    Any advice would be appreciated.

    DATE is not a function of Oracle; in fact, it's a terrible name for a column or function, because it blends with the DATE data type.

    In Oracle, the function SYSDATE returns the date and time, according to the clock on the database server.  So, SYSDATE can return a value as November 19, 2013 06:33:15.   If you want to midnight the same day (i.e., November 19, 2013 00:00:00) and then use TRUNC (SYSDATE).

    String literals (for example the string which consists 5 characters d, a, t, e, and 1) go inside the single quotes. Numbers and the names of columns only.

    If you want to include all the columns, more some calculated values, in a SELECT clause, then you must use a name table or alias before the *.  (See select_2 below.  To do this, assign the alias j to display online.)

    Maybe you wanted to say something like:

    Select *-it's select_1

    de)

    Select j. *-it's select_2

    , case when SYSDATE > = date1 then 1 or 0 end as departure

    , case when SYSDATE<= date2="" then="" 1="" else="" 0="" end="" as="">

    de)

    Select *-it's select_3

    of call_1 cd

    inner join call_2 ON cd.name = cl.queue cl

    ) j

    )

    ;

    As mentioned in a previous answer, you should be careful about the use of "SELECT *" in production code.

    In select_3, it would be better if you explicitly listed the columns you need.  It can improve efficiency and maintenance.  In this request, queue and the name will be always the same, so you probably don't want to include both of them in the result set, in any case.

    In select_1 and select_2, it is acceptable to use "SELECT *", assuming that select_3 is fixed.

    Moreover, there is no point in using subqueries here.  You can get the same results simply in a single query, without any subqueries.

  • Question of the CASE statement

    Is it OK to mix conditions inside the case statement? as for example:

    SUM (CASE WHEN b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245', '5345', '87894') THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    ???

    I put in parentheses between the two conditions?

    SUM (CASE WHEN (b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245 ', '5345', ' 87894')) THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    is this legal syntax? because its not complaining do not, but I want to just make sure that these things are good to use and the data comes right back.

    Thank you!

    Kodiak_Seattle wrote:
    Is it OK to mix conditions inside the case statement? as for example:

    SUM (CASE WHEN b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245', '5345', '87894') THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    ???

    Yes, you can do that. The conditions must be related somehow.

    I put in parentheses between the two conditions?

    SUM (CASE WHEN (b.SUPPLIER_NUM = 12345 AND c.VPN IN ('3245 ', '5345', ' 87894')) THEN a.TRAN_AMT ELSE 0 END) SUMSPEND_MOS

    You have no need, but if it helps you (or one who has to maintain the code) to understand it better, then go ahead. The cost can be one millisecond extra when the query is compiled (it will run everything as fast so be it), and the benefits can be enormous.

    I find that formatting code contributes much more clarity to have additional parentheses. Why not use something like that?

    SUM ( CASE
              WHEN (    b.SUPPLIER_NUM     = 12345
                AND  c.VPN           IN ('3245', '5345', '87894')
                )
          THEN a.TRAN_AMT
          ELSE 0
          END
        )          AS SUMSPEND_MOS
    

    If you have really complicated conditions, where you mix ANDS and ORs, then you should certainly use parentheses. It goes the same for the WHERE clause.

    is this legal syntax? because its not complaining do not, but I want to just make sure that these things are good to use and the data comes right back.

    The syntax is fine.
    If the data comes in good or bad is another matter. What data are, and what you mean by 'comes back good' (in other words, what results do you get off these data)?

  • call the statement box inside the case statement

    I am writing a program which requires me to run a statement box inside another case statement. Although this sounds like a simple thing, I need to be able to call the case statement using a sequence structure, where s1 sends the true value to the case, s2, a fake. Then I need to record the results of this instruction box in a text file. Attatched is a simplified version of what I'm trying to do. Please note that the way my program runs may not call the case statement without using a sequence structure, two nesting box instructions is not feasible. I hope someone out there can help me because I was stuck trying to find this for awhile.

    Thank you

    LVStudent wrote:

    [...] I can't call the case statement without using a sequence structure

    Yes you can.  You just need to be smart.

    LVStudent wrote:

    I don't think I can use a state machine to fix this.

    I think you probably can.

    With respect to your original post. What are these s1 and s2 are you talking about?  My opinion on the matter, it is that you want to select a case based on the values of several controls Boolean.  If this is correct, I do this:

    Build your Boolean controls in a table, convert the table number and insert it into the structure of your business.  No button pressed = 0, s1 = only 1, s2 = only 2 both = 3.   This works for Boolean values as much as you want and is an easy way to make a decision that depends on many entries.

  • Case statement is not spend.

    Hello

    I'm having a strange problem with a case statement.  I'm passing is a Boolean value that is set to false, but the case statement never switches to the loop of "false".  I have attached a word doc who did the screen has a step of this unique through being shot.  The photo of the top has the case highlighted with the probe #8 beside him indicate 'False. '  In the lower screen shot is the very next step that highlights the outside circle while ' loop', but the case statement is always 'True '.  Anyone seen this before?

    Gary Tyrna

    Hey Mello,

    Well, I see what you're saying and you are right, the problem is the case statement works when highlight of execution.  But I have a main case statement in the loop that either allows the state machine to execute a loop or hides them and that case is triggered for no steps to true or false.  So that was the reason why I sent the first e-mail because I could see this case change, but not the smallest.  But if this is the fix well I'll run with it and lets see case statement switch the highlight of the performance.

    Thanks again.

    Gary Tyrna

  • How can you change a menu drop-down menu in a case statement?

    Hello

    I'm trying a table find vi. This VI will be an existing xml file and once the user has selected access to its equipment, input, output and frequency it put all of these options in a string and search the XML for this exact table name and post it on one screen of output. The problem I have is my entry and exit selection must be a little different depending on the chosen equipment. I thought I could use an instruction box to change the options of selectable input and output, but I ran into snags a lot with it. For whenever I have to put a new drop of entry and exit in the drop-down menu in the case statement, he wants to put a new one in the front (I only want to enter and exit not only three I have two inputs and outputs hidden right now). I think I'm using the wrong case statement... Can someone help change my input and output, selectable options depending on the chosen equipment. Attached is my xml file, Array Find.vi (the original) and table Find_Test.vi (that's what I'm trying to change).

    Thank you

    dlovell

    Hi dlovell,

    A few changes in the attached VI:

    Requirements/possible Solutions

    • When the value of the equipment, do something
      • Add the cases to the value of equipment change event
    • Do something = decide what channels to write, to change the input and output strings
      • Read material value changed
      • Decision (case structure)
      • Channel (same method as the previous mod)

    Hope this helps

  • How to fill a table only if a case statement runs?

    Hello. I want to have a while loop with a case statement. When the case is true, it should read the analog data each iteration of the while loop via Daqmx and store these values in a table. If the case is wrong, I don't want to read all the data or to store anything else in the table. When the loop is finished, I want to have this available table to write to a file or something. How can I go about it?

    Search for a "shift register. This will hold your data. In the case of fake feed the data in the table back through without change. In the case of true add the new value in the table to "build the table" or even better "subset of the table to replace' for a defined table size.

  • If I have floating values such as 6.3 6.7, 6.9, 7.1, 7.2, how can I write a case statement to handle this

    How can I write a case statement if I want a case for x< 1.5;  ="" a="" case="" for="" 1.5=""><= x=""><= 3.7; ="" case="" for ="" 3.7="">< x="">< 7.2.....etc.  ="" my="" input="" is="" a="" floating="">

    Thank you.

    You don't seem to have set rules on inclusion, but I often use the function in the range and Coerce in these cases.

  • Case statement in the process Page

    Request Express 3.2.1.00.11

    I put the following code in an anonymous block (will return no error) for a process Page;

    BEGIN
    INSERT
      INTO DAD_ASSESSMENT_REQUEST
    ( tenure_id
    , client_id
    )
    VALUES
    ( :P10101_TENURE_ID
    , :P10101_CLIENT_ID 
    );
    END;
    

    But when I put a statement case it throws the following error;

    1 error has occurred
    ORA-06550: line 7, column 3: PL/SQL: ORA-01747: invalid user.table.column, table.column, or column specification ORA-06550: line 3, column 1: PL/SQL: SQL Statement ignored
    

    BEGIN
    INSERT
      INTO DAD_ASSESSMENT_REQUEST
    ( tenure_id
    , client_id
    , (CASE 
       WHEN (:P10101_MEASURE_OPTION = 'AREA') THEN estimated_area_ha 
       WHEN (:P10101_MEASURE_OPTION = 'LINE') THEN estimated_length_km 
     END)
    )
    VALUES
    ( :P10101_TENURE_ID
    , :P10101_CLIENT_ID 
    , :P10101_X
    );
    END;
    

    Why is this code not work and it is possible to use a case statement in a Page Apex process

    Concerning

    Ben

    Benton says:

    Request Express 3.2.1.00.11

    I put the following code in an anonymous block (will return no error) for a process Page;

    1. BEGIN
    2. INSERT
    3. IN DAD_ASSESSMENT_REQUEST
    4. (tenure_id
    5. client_id
    6. )
    7. VALUES
    8. (: P10101_TENURE_ID)
    9. ,: P10101_CLIENT_ID
    10. );
    11. END;

    But when I put a statement case it throws the following error;

    1. 1 error has occurred
    2. ORA-06550: line 7, column 3: PL/SQL: ORA-01747: specification user.table.column, table.column or invalid column ORA-06550: line 3, column 1: PL/SQL: statement ignored
    1. BEGIN
    2. INSERT
    3. IN DAD_ASSESSMENT_REQUEST
    4. (tenure_id
    5. client_id
    6. (CASE
    7. WHEN (: P10101_MEASURE_OPTION = 'SPACE') THEN estimated_area_ha
    8. WHEN (: P10101_MEASURE_OPTION = 'LINE') THEN estimated_length_km
    9. END)
    10. )
    11. VALUES
    12. (: P10101_TENURE_ID)
    13. ,: P10101_CLIENT_ID
    14. ,: P10101_X
    15. );
    16. END;

    Why is this code not work and it is possible to use a case statement in a Page Apex process

    Of course, it is possible to use a CASE statement or expression (it is the latter) in a page APEX process. However, it is not possible to use an invalid syntax while doing so. Part of a clause INSERT INTO can contain only static column names.

    In general the SQL expressions (and also the bind variable, another cause frequent errors of syntax) can be used only in

    • the projections of the SELECT queries and subqueries
    • the right side of the disposals in the SET update clause
    • the lists of VALUES of INSERTs
    • WHERE clause predicates

    ReemaPuri wrote:

    Try this

    INSERT

    IN DAD_ASSESSMENT_REQUEST

    (tenure_id

    client_id

    estimated_area_ha

    estimated_length_km

    )

    VALUES

    (: P10101_TENURE_ID)

    ,: P10101_CLIENT_ID

    , (SELECT CASE WHEN: P10101_MEASURE_OPTION = 'SPACE' AND THEN: P10101_X)

    OTHERWISE, NULL END OF DOUBLE)

    , (SELECT CASE WHEN: P10101_MEASURE_OPTION = 'LINE' THEN: P10101_X)

    OTHERWISE, NULL END OF DOUBLE)

    );

    It's a good idea, but it can be simplified, eliminating unnecessary subqueries:

    insert into dad_assessment_request (
        tenure_id
      , client_id
      , estimated_area_ha
      , estimated_length_km)
    values (
        :p10101_tenure_id
      , :p10101_client_id
      , case
          when :p10101_measure_option = 'AREA' then :p10101_x
        end
      , case
          when :p10101_measure_option = 'LINE' then :p10101_x
        end);
    

Maybe you are looking for