When a+b+c is not equal to a+c+b

Hi,
I would be pleased to have some comment on the following :
if a+b+c != a+c+b then something the + operator is not working as it should !?
SQL> select
a,b,c,a+b+c,a+c+b
from
(select date '2005-02-28' a, numtoyminterval(1,'MONTH') b, numtodsinterval(1,'DAY') c from dual);
A          B             C                   A+B+C      A+C+B
28.02.2005 +000000000-01 +000000001 00:00:00 29.03.2005 01.04.2005

Hi Laurent
As James pointed out, the behaviour with add_months is different but gives a consistent result for the 2 orders. This I can understand because of the functionality and the additional logic that can be placed in the function call.
SQL> select
  2     a+b+c,
  3     a+c+b,
  4     a+b,
  5     a+c,
  6     add_months(a,1) + 1 abc,
  7     add_months(a+1,1) acb
  8  from
  9     (select
10             date '2005-02-28' a,
11             numtoyminterval(1,'MONTH') b,
12             numtodsinterval(1,'DAY') c
13     from
14             dual
15     );
A+B+C     A+C+B     A+B       A+C       ABC       ACB
29-MAR-05 01-APR-05 28-MAR-05 01-MAR-05 01-APR-05 01-APR-05
SQL> select
  2     date '2005-03-29' - numtoyminterval(1,'MONTH')
  3  from
  4     dual;
        date '2005-03-29' - numtoyminterval(1,'MONTH')
ERROR at line 2:
ORA-01839: date not valid for month specified
SQL>
SQL> select
  2     add_months(date '2005-03-29',-1)
  3  from
  4     dual;
ADD_MONTH
28-FEB-05So based on this, I don't see how the + operator could be commutative for anything other than numbers. Dates and intervals are a special case where order of evaluation does (and should?) effect the result...aren't they?

Similar Messages

  • Multiple selection in Query Panel. Operator Does not equal generates error.

    Hi,
    I'm using Jdeveloper 11.1.1.4 and creating Oracle Fusion Web Application with ADF Business Components.
    I want to use multiple selection on LOV in ADF Query Panel with Table, but I get the following error
    when I use operator "Does not equal":
    Error: Unsupported model type.
    SelectMany does not support a model of type class java.lang.Integer.
    A simple example:
    Schema: HR
    Generate default Business Components for tables Departments and Employees.
    Model:
    Create List of Values for EmployeesView(DepartmentId)
    List Data Source: DepartmentsView1
    List Attribute: DepartmentId
    Display Attributes: DepartmentName (UI Hints)
    Create View Criteria EmployeesByDepartmentVC for EmployeesView
    Criteria Item:
    Attribute: DepartmentId
    Operator: Equals
    Operand: Literal
    Select "Support Multiple Value Selection" (UI Hints)
    ViewController:
    Create blank JSF Page: showEmployees.jspx
    Drag EmployeesByDepartmentVC from Data Controls to showEmployees.jspx
    Create Query=>ADF Query Panel with Table
    Run application.
    Press Advanced button.
    Select operator "Does not equal" and department names "Administration;Marketing"
    Press Search
    Error: Unsupported model type.
    SelectMany does not support a model of type class java.lang.Integer.
    Note: it works fine with operator "Equals"
    Best,
    Kees.

    Hi,
    I was reading:
    http://www.oracle.com/technetwork/developer-tools/jdev/jdev-11gr2-nf-404365.html#bugs_fixed_in_11.1.2.2.0
    Bugs Fixed in 11.1.2.2.0
    Bug.No. 13508184
    unsupported model type error thrown for multi select view criteria
    I have tested the use case described in this thread with JDeveloper 11.1.2.2.0 but I still get the same error.
    when I use operator "Does not equal":
    Error: Unsupported model type.
    SelectMany does not support a model of type class java.lang.Integer.
    Is there anybody who can tell me more about this bug fix?
    Thanks,
    Kees.

  • OBIEE Answe: Error when using "is not equal to/is not in" option in filters

    Hi there,
    I have a report with a column that uses EVALUATE function. I want to filter the results of the report by the values of this column. There's no problem when I use "is equal to/is in" option in the filter options. However with everything the same, when I try to apply "is not equal to/is not in" option I got an error message reading :
    "Error Codes: YQCO4T56:OPR4ONWY:U9IM8TAC:OI2DL65P
    Odbc driver returned an error (SQLExecDirectW).
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46047] Datetime value @{pv_Period_End}{@{system.currentTime}[YYYY-MM-DD]} from @{pv_Period_End}{@{system.currentTime}[YYYY-MM-DD]} does not match the specified format. (HY000)"
    The column is the following funciton:
    CAST(EVALUATE('pob.Get_PP_Status(%1, %2)',"ПРЕПИСКА".PP_ID, DATE '@{pv_Period_End}{@{system.currentTime}[YYYY-MM-DD]}' ) AS CHAR(500))
    Do you any ideas where the problem might be?
    Kind regards,
    Danail

    Thru note 1909504 the Function Module FI_TAX_CALCULATION was changed and caused the error on the system of my customer.
    Hope that helps.
    Regards
    Udo

  • User migration vom SAP DB to LDAP: Problem when userId not equal to logonId

    Hello
    I have to write a migration tool which migrates the users stored in the SAP DB to LDAP. Thereby the logon ID of the users in the SAP DB is not equal to the user ID.
    The migration works fine and in SAP Identity Management (IDM) everything is ok.
    But when I try to log onto the portal with a migrated user, the portal tells me that no portal role is assigned to the user. But the IDM shows clearly that the portal role is assigned to the user.
    Investigation showed that when I create in the LDAP a user with the same logon ID and user ID, the log onto the portal works ok. As soon the logon ID differs from the user ID, the portal does not find the assigned portal role anymore, although in IDM everything works.
    How can I solve this problem? It is important that the logon ID and the user ID are different as otherwise all the stored data has wrong references.
    Greetings
    Rolf
    Edited by: Rolf Grüninger on Jul 19, 2011 6:08 PM

    Problem solved:
    The naming attribute of the user account has to be set to the same attribute as the one of the user object and not to the user logon ID.

  • Tax does not equal 0 when tax rate is Zero

    Hi,
    We have a problem when posting an invoice through MIRO. The end user gets the message 'Tax does not equal 0 when tax rate is Zero'. I checked the tax code and it looks fine.
    Can anyone throw some light on the error?
    We are using vertex for tax calculations.
    Regards,

    Hi Raj,
    Please chek OSS NOTE 681538 .
    Check for the applicable releases and support packages from the note.
    Check from your system on what support package you are into. Goto System -> Status -> click on the magnifying glass against Component version and see what is the support pack for SAP_APPL.
    You can ask your Basis colleagues also to check if it can be applied into the system. I guess they would check it through t-code SNOTE.
    Regards
    Surya

  • Report Builder very slow when using NOt Equal

    When creating dataset I have to exclude some customers and use Not Equal option out of filters option. Everuthing is getting extremely slow.
    How to find the way to solve the problem - exclude the player and have decent performance. The reports for end-users and they are limited to drag and drop and not going to learn MDX.
    Thanks

    Hi srussky,
    According to your description, you used not equal in query of dataset and the report runs slow, right?
    When we use =, it reduces the join operation to one single matching row from each table. When we use not equal to, it massively increased the number of pairings if 99.99 % of the rows are matched.
     To troubleshoot the problem, please refer to the following steps:
    Consider replacing the not equal operator with equals (=) or inequaluity operators (>,>=,<,<=) if possible.
    Using Stored Procedures in dataset, then the query will be executed in database engine.
    Reduce the number of member siblings in the level that is being referenced in the MDX query.
    Reduce the number of member properties of the referenced member and its member siblings.
    Use Drillthrough filters in the MDX query to limit the number of rows that are returned by the MDX query.
    Use the XML/A Provider after warming the client cache of the provider.
    Use virtual dimensions.
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    If you have any feedback on our support, please click
    here.
    Wendy Fu
    TechNet Community Support

  • Showing Booking amount when it does not equal Opportuity Revenue Total

    I there a way to create a report to easily show where the booking amount of an opportunity does not equal the sum of the products in the product revenue section? I tried Sum(Product revenue), can't quite remeber the field name, but that did not work
    Also, we would like to see any opportunity that has no predict revenue associated with it, either in the same report or a different report.
    Thanks

    David,
    The Opportunity-Product subject areas contain both Opportunity Revenue fields and Opportunit-Product Revenue fields. The Opportunity-Product Revenue field located in Columns/Opportunity-Product/Revenue/Revenue will aggregate the total amount of all products for the opportunity. There is no need to SUM this field.
    Build a report and filter it based on a field that calculates the difference between the two revenue columns and you should get your desired list of opportunities.
    Now that you know where the right fields are, you other report should be a simple filter on the appropriate revenue field = 0
    Mike

  • When is 1 not equal to 1 ?

    WHENEVER YOU SEE >< in this code it means "NOT EQUALS" - the forum software removes "empty html tags"
    During one of my processes, I compare some values passed into the database with the rowcount of the number of rows I just inserted/updated:
    Here is a simplified procedure:
    procedure mark_as_done(
      in_batch_id IN NUMBER,
      in_count_a IN NUMBER,
      in_count_b IN NUMBER
      tmp_num NUMBER;
    is
      SELECT count(*) INTO tmp_num FROM stuff_to_do WHERE batch = in_batch_id;
      IF tmp_num >< (in_count_a + in_count_b) THEN
        sendErrorEmail('The number of things to do is not equal to the sum of A and B');
        RETURN;
      END IF;
      INSERT INTO done_stuff SELECT * FROM stuff_to_do WHERE batch_id = in_batch_id;
      IF SQL%ROWCOUNT >< (in_count_a + in_count_b) THEN
        sendErrorEmail('The number of things inserted into done_stuff was '||SQL%ROWCOUNT||' but the sum of A and B was '||(in_count_a + in_count_b));
      END IF;
      UPDATE stuff_to_do SET state = 'DONE' WHERE batch_id = in_batch_id;
      IF SQL%ROWCOUNT >< (in_count_a + in_count_b) THEN
        sendErrorEmail('The number of things updated to DONE was '||SQL%ROWCOUNT||' but the sum of A and B was '||(in_count_a + in_count_b));
      END IF;
    END mark_as_done;This op is done thousands of times per month. I just got 2 emails:
    >
    The number of things inserted into done_stuff was 1 but the sum of A and B was 1
    The number of things updated to DONE was 1 but the sum of A and B was 1
    Can anyone explain Oracle's inability to compared 1 < > 1 and result in TRUE ?
    Edited by: charred on Jan 28, 2009 7:23 AM
    Stupid "forum cannot handle < or > brackets even in code tags" bug. Edited < > to be ><. Please turn them round in your head. Didnt want to use != in case it is a bug with ><

    Hi,
    I have doubt, is it running without error
    procedure mark_as_done(
    in_batch_id IN NUMBER,
    in_count_a IN NUMBER,
    in_count_b IN NUMBER
    tmp_num NUMBER; --DECLARATION
    is
    SELECT count(*) INTO tmp_num --YOU ARE STORING VALUE HERE
    FROM stuff_to_do WHERE batch = in_batch_id;
    IF tmp_num (in_count_a + in_count_b) --?WHAT ARE YOU TRYING TO DO HERE?
    THEN
    sendErrorEmail('The number of things to do is not equal to the sum of A and B');
    RETURN;
    END IF;
    INSERT INTO done_stuff SELECT * FROM stuff_to_do WHERE batch_id = in_batch_id;
    IF SQL%ROWCOUNT (in_count_a + in_count_b) THEN
    sendErrorEmail('The number of things inserted into done_stuff was '||SQL%ROWCOUNT||' but the sum of A and B was '||(in_count_a + in_count_b));
    END IF;
    UPDATE stuff_to_do SET state = 'DONE' WHERE batch_id = in_batch_id;
    IF SQL%ROWCOUNT (in_count_a + in_count_b) THEN
    sendErrorEmail('The number of things updated to DONE was '||SQL%ROWCOUNT||' but the sum of A and B was '||(in_count_a + in_count_b));
    END IF;
    END mark_as_done;
    Shishu Paul

  • Unable to Create "Not Equal to" condition in Variable creation

    Hi ,
    I am getting an error while creating variable at report level,
    Well, my condition at variable creation is ----> sum(A) where [country] <> " x" ...(It is showing the results when the country is equal to x) and the converse for the same ... If I use [country] = "x" .. It is taking as country not equal to x ..
    Please suggest me on this..
    Thanks in advance ....

    Hi ,
    I am getting an error while creating variable at report level,
    Well, my condition at variable creation is ----> sum(A) where [country] <> " x" ...(It is showing the results when the country is equal to x) and the converse for the same ... If I use [country] = "x" .. It is taking as country not equal to x ..
    Please suggest me on this..
    Thanks in advance ....

  • Rounding off Issue (Net Value not equal to Net Price * quantity)

    Dear Gurus,
    Here is an interesting issue.The default calculation done in the pricing procedure is two decimal places.Now we consider a real scneario,consider the net value of 324 quantities of an item calculated is 36,049.86 .When it is divided by quantity  the resulting value of net price is 111.265 but the system shows 111.27 by rounding it off.
    Now here comes the problem,my client needs the rate to be shown on the order script to be two decimal places and the net value should be equal  quantity * net price.So if we apply this,
    324 * 111.27 = 36051.48
    But the net value calculated by the system is 36,049.86.So it can be consluded that:
    "Quantity * Net Price Shown is not Equal to Net Value calculated by the System"
    Need an urgent resolution,project is stuck on this
    Regards,
    Sam Ahmed
    Edited by: Lakshmipathi on Nov 3, 2011 12:14 PM
    Please dont add URGENT in subject or in your post

    Here is the pricing procedure,
    We start with the amount condition types
                                            Unit Price        Units Condition Value
    ZMRP     MRP                     1,700.00           10     PAC     55,080.00      
    ZTRP     Trade Price     1,445.00           10     PAC     46,818.00      
    ZDPR     Dist. Price     1,445.00           10     PAC     46,818.00         (GL)
    Using Trade Price we apply the product discount of 23%
    ZPRD     Product Discount     23.000-     %                    10,768.14-
    Then we send discount amount to the gl by using condition type ZDIS
    ZDIS      Discount Value     100.000-     %           10,768.14-      (GL)
    tHE RESULTING NET VALUE IS  36,049.86      as 46818.00 - 10,768.14
         Order Item value     111.27      1     PAC     36,049.86      
    And the Net Price is 111.27

  • Delivery cost is not equal to actual cost in sales order

    I met a strange phenomenon is the sale cost in SO is not equal to the cost in delivery order.
    I order 3 PCS material and each cost is 43.87 and the total cost is 131.61.
    However when I finished PGI the FI document shows the cost is 131.62. the diff is 0.01
    I don't know how the diff comes.
    Do you know the reason for the above issue?
    Thank you very much for your help.
    Yang

    have you checked whether there are different pricing conditions?
    in Sales order, the price is calculated based on the pricing date in the order, if you then create a new delivery, the price is re-calculated with the delivery date, but the sales order still has the old pricing information.
    Check the pricing log of the sales order and invoice (tab "conditions") to see, which pricing condition is used.
    Or is it possible that your order uses a foreign currency? SO maybe the exchange rate has changed since creating the order.
    Regards
    Ralf

  • KE5Z drilldown report does not equal grr3 report values

    Hello,
    We have a grr3 report where the COGS line is based on functional area and account ranges.  The total displayed on the GRR3 report for the COGS cell matches the values I would expect based on the specified account and functional area restrictions assigned to that cell.  When I drill into the KE5Z report (Profit Center: Actual Line Items), which is identified as a receiver report, the summed value of the "In Company Code Currency" field does not equal what is displayed in GRR3.  The GRR3 report is returning results in the same currency as the company code currency that the report is being executed for so that is not the problem.  During my investigation it looks like the functional area restrictions are not being accounted for when I drill into KE5Z.  Any recommendations on why the restrictions identified for the cell in the GRR3 report would not be carried through to the KE5Z results?  I have been playing with this for hours and have run out of ideas.  I can't determine why the COGS cell value is different than the actual line items sum.  Any help would be greatly appreciated.
    Thanks,
    Jordan

    Hi Jordan,
    in my experience the report-report interface can only pass through selections independently.
    To give an example: I had a report painter report with line 1 that had a selection on two characteristics (say cost element A and cost center B) then a second line with selection cost element C and cost center D selected and finally a line with the sum of the two lines above.
    Now when I jump to a connected line item report by double-clicking on the line with the sum, the parameters passed on are:
    cost centers: B, D
    cost element: A, C
    Therefore, the sum of my line items is not equal to the sum that I departed from, as I get line items with cost element A and cost center D, for example, a combination that was excluded from my original report.
    I hope I made the point clear.
    Another possibility is of course, that the receiving report has additional selection active (in the form used in the dril down report) that were not present in the original report
    Regards
    Nikolas
    Edited by: Nikolas John on Mar 24, 2011 9:21 AM

  • Update Record Field if Value Not Equal

    Hello All,
    I am using Toad for Oracle 10. I have a MERGE INTO Process that updates tbl_requisition based on FK - fk_allotment_id that equals parent table tbl_allotment PK - pk_allotment_id. Both tables have create, update and deletes triggers. The process is executed when a Apply Changes/update button is clicked from tbl_allotment. So, all the record data from tbl_allotment updates tbl_requisition record if the fk and pk keys are equal. My problem is if a record is updated within tbl_requisition. Now the record from tbl_requisition is different from tbl_allotment. If any value is updated from tbl_allotment for the matching pk_allotment_id = fk_allotment_id record from tbl_requisition. tbl_allotment record data will override the updated value within tbl_requisition. I would like to only update the values that were updated/changed and are not equal from tbl_allotment to tbl_requisition. Can anyone assist me with this?
    Begin
    MERGE INTO tbl_requisition req
    USING tbl_allotment alt
    ON (req.fk_allotment_id = alt.pk_allotment_id)
    WHEN MATCHED THEN
    UPDATE SET
         req.FK_JOBCODE_ID = alt.FK_JOBCODE_ID,
         req.FK_JOBCODE_DESCR = alt.FK_JOBCODE_DESCR,
         req.FK_JOBCODE_PAYRANGE = alt.FK_JOBCODE_PAYRANGE,
         req.FK_PAY_RANGE_LOW_YEARLY = alt.FK_PAY_RANGE_LOW_YEARLY,
         req.FK_DEPARTMENT_ID = alt.FK_DEPARTMENT_ID,
         req.FK_DIVISION_ID = alt.FK_DIVISION_ID,
         req.FK_NUMBER_OF_POSITIONS = alt.NUMBER_OF_POSITIONS,
         req.FK_DEPARTMENT_NAME = alt.FK_DEPARTMENT_NAME,
         req.FK_DIVISION_NAME = alt.FK_DIVISION_NAME,
         req.REPORT_UNDER = alt.REPORT_UNDER;
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        dbms_output.put_line('No data found');
    End; Thanks for reading this thread and I hope someone can provide some assistance. If the create tables or anything is needed that is not a problem to provide.

    Thanks for responding Frank and providing the EXCEPTION information also. Here are my create tables and insert statement. I changed the child table from tbl_requisition to tbl_allotment_temp, same process though.
    CREATE TABLE  "TBL_ALLOTMENT"
       (     "PK_ALLOTMENT_ID" NUMBER,
         "FK_DEPARTMENT_ID" VARCHAR2(5),
         "FK_DIVISION_ID" VARCHAR2(100),
         "FK_JOBCODE_ID" NUMBER,
         "FK_JOBCODE_DESCR" VARCHAR2(100),
         "FK_JOBCODE_PAYRANGE" NUMBER(*,0),
         "FK_PAY_RANGE_LOW_YEARLY" NUMBER(*,0),
         "NUMBER_OF_POSITIONS" NUMBER,
          CONSTRAINT "PK_ALLOTMENT_ID" PRIMARY KEY ("PK_ALLOTMENT_ID") ENABLE
    CREATE TABLE  "TBL_ALLOTMENT_TEMP"
       (     "PK_ALLOTMENT_TEMP_ID" NUMBER,
         "FK_DEPARTMENT_ID" VARCHAR2(5),
         "FK_DIVISION_ID" VARCHAR2(100),
         "FK_JOBCODE_ID" NUMBER,
         "FK_JOBCODE_DESCR" VARCHAR2(100),
         "FK_JOBCODE_PAYRANGE" NUMBER(*,0),
         "FK_PAY_RANGE_LOW_YEARLY" NUMBER(*,0),
         "NUMBER_OF_POSITIONS" NUMBER,
          CONSTRAINT "PK_ALLOTMENT_TEMP_ID" PRIMARY KEY ("PK_ALLOTMENT_TEMP_ID") ENABLE
    INSERT INTO tbl_allotment
    (FK_DEPARTMENT_ID, FK_DIVISION_ID, FK_JOBCODE_ID, FK_JOBCODE_DESCR,
    FK_JOBCODE_PAYRANGE, FK_PAY_RANGE_LOW_YEARLY, NUMBER_OF_POSITIONS)
    values
    (00002, 0000220000, 100408, 'Revenue Analyst',
      2210, 38389, 5);Once data is created for tbl_allotment, this insert statement inserts the data to tbl_allotment_temp.
    INSERT INTO tbl_allotment_temp(
         PK_ALLOTMENT_TEMP_ID,
         FK_JOBCODE_ID,
         FK_JOBCODE_DESCR,
         FK_JOBCODE_PAYRANGE,
         FK_PAY_RANGE_LOW_YEARLY,
         FK_DEPARTMENT_ID,
         FK_DIVISION_ID,
         NUMBER_OF_POSITIONS)
        VALUES (
         :P3_PK_ALLOTMENT_ID,
         :P3_FK_JOBCODE_ID,
         :P3_FK_JOBCODE_DESCR,
         :P3_FK_JOBCODE_PAYRANGE,
         :P3_FK_PAY_RANGE_LOW_YEARLY,
         :P3_FK_DEPARTMENT_ID,
         :P3_FK_DIVISION_ID,
         :P3_NUMBER_OF_POSITIONS);Once any update occurs to tbl_allotment, this process updates tbl_allotment_temp based on temp.pk_allotment_temp_id = alt.pk_allotment_id.
    Begin
    MERGE INTO tbl_allotment_temp temp
    USING tbl_allotment alt
    ON (temp.pk_allotment_temp_id = alt.pk_allotment_id)
    WHEN MATCHED THEN
    UPDATE SET
         temp.FK_DEPARTMENT_ID = NVL (alt.FK_DEPARTMENT_ID, temp.FK_DEPARTMENT_ID),
         temp.FK_DIVISION_ID = NVL (alt.FK_DIVISION_ID, temp.FK_DIVISION_ID),
         temp.FK_JOBCODE_ID = NVL (alt.FK_JOBCODE_ID,    temp.FK_JOBCODE_ID),
         temp.FK_JOBCODE_DESCR = NVL (alt.FK_JOBCODE_DESCR, temp.FK_JOBCODE_DESCR),
         temp.FK_JOBCODE_PAYRANGE = NVL (alt.FK_JOBCODE_PAYRANGE, temp.FK_JOBCODE_PAYRANGE),
         temp.FK_PAY_RANGE_LOW_YEARLY = NVL (alt.FK_PAY_RANGE_LOW_YEARLY, temp.FK_PAY_RANGE_LOW_YEARLY),
         temp.NUMBER_OF_POSITIONS = NVL (alt.NUMBER_OF_POSITIONS, temp.NUMBER_OF_POSITIONS);
    End;Once the data is created within tbl_allotment the data is also inserted within tbl_allotment_temp. If tbl_allotment_temp.NUMBER_OF_POSITIONS value is changed from 5 to 10 is fine. The problem is when a update occurs within tbl_allotment and the updated field is not NUMBER_OF_POSITIONS. The changed field values from tbl_allotment should only update the field data within tbl_allotment_temp.
    UPDATE tbl_allotment_temp
    SET
    NUMBER_OF_POSITIONS = 10
    UPDATE tbl_allotment
    SET
    FK_JOBCODE_DESCR = 'Revenue Test'Now within tbl_allotment_temp only field FK_JOBCODE_DESCR should be updated to Revenue Test but my MERGE INTO process will update all the field values. So the updated NUMBER_OF_POSITIONS value 10 will now be 5. I would only like to update any changed value from tbl_allotment to tbl_allotment_temp. If any record value from tbl_allotment_temp was changed that value should not be updated from the MERGE INTO Process within tbl_allotment unless those values have been updated within tbl_allotment. Let me know if this is not clear so I can clarity more Frank.
    Edited by: Charles A on Aug 29, 2011 8:41 AM

  • Warning Message only if 1 to 3 fields do not equal 100%

    I have 3 potential fields that will be completed.  If Field1 (Primary Beneficiary) is 100%, then the user will leave Fields 2 and 3 empty.  If Fields 1 and 2 equal 100%, then Field 3 will be empty.  Otherwise they will have values in Fields 1, 2, and 3.  Regardless, they should not be able to continue completing the rest of the form until the sum of these three fields equal 100%.  Therefore I did modify the form as follows, but two issues: it throws the error message up even when first entering a value in Field 1.  This script need NOT run until all 3 fields have been tabbed through, or they click on the next section of the form to continue completing.  The "Total 100" (name of this particular field) is in the Tab Order to appear after "Beneficiary 3 Benefit Percent" field.  And secondly, it still permits the user to continue rather than returning to Field1 even if the total does not equal 100%.  Your assistance is greatly appreciated!  PS:  How do I mark that the post was either helpful or correct?
    Rita
    event.value = ''; // clear field
    // get the values of Beneficiary Benefit fields 1, 2 and 3 as string
    var sField1 = this.getField("Beneficiary 1 Benefit Percent").value.toString();
    var sField2 = this.getField("Beneficiary 2 Benefit Percent").value.toString();
    var sField3 = this.getField("Beneficiary 3 Benefit Percent").value.toString();
    // adjust for a field being 100 and others null
    if (sField1 == 100 & sField2 == '' & sField3 == '') sField2 = "0" , sField3 = "0";
    if (sField2 == 100 & sField1 == '' & sField3 == '') sField3 = "0" , sField1 = "0";
    // do only if Beneficiary Benefit fields 1, 2 and 3 are not null
    if(sField1 != '' & sField2 != '' & sField3 != '') {
    event.value = Number(sField1) + Number(sField2)+ Number(sField3);
    if (event.value != 100) app.alert("The sum of Benefit percent must equal 100.", 1, 0);
    this.getField("field 1").setFocus();

    Two problems just from a first glance at this line:
    if (sField1 == 100 & sField2 == '' & sField3 == '') sField2 = "0" , sField3 = "0";
    1. You're comparing a string to a number
    2. You're separating commands with a comma and not placing {} around the block of commands.
    It needs to be something like this:
    if (sField1 == "100" & sField2 == "" & sField3 == "") {sField2 = "0"; sField3 = "0";}
    There are probably more errors, but start by fixing those.
    Also, you should probably post which error message you're getting.

  • Why it is not equal?

    Integer i = new Integer (42);
    Long l = new Long (42);
    if(i.equals(1))
         System.out.println("Equal");
    else
          System.out.println("NOT Equal");Why it is Not Equal?can you explain me?

    When you do
    i.equals(l) - equals method of the Integer class will be called.
    and equals method in Integer class is like dis
    public boolean equals(Object obj) {
         if (obj instanceof Integer) {
         //compare the two objects and return the result
         return false;
    The two objects will be compared only if both of them are Integer types, other wise it will simply return false.
    www.free-java-tutorials.com

Maybe you are looking for