Increment operator

hi
i have a small code snippet
int i=10;
i=i++;
System.out.println(i);as per my knowledge it should result *11*, but it gives *10*,
could you please tell me the reason for this why it is so ?
ashish

In contrary to C or C++, the meaning of i=i++ is well defined in Java.
It is better avoided though!
This i=i++ stuff gets regularly discussed.
http://forums.sun.com/thread.jspa?threadID=231270&tstart=122941
http://forums.sun.com/thread.jspa?threadID=441193&tstart=72796

Similar Messages

  • Post Increment Operator Question

    I had written a small program to test the working of Post increment operator.
    public static void main(String[] args)
         int a = 4;
         a = a++;
         System.out.println ( a );
    I expected the output to be '5', but the output given is '4'.
    Can anyone tell me to how this works in Java ?

    There is a big difference between a++ and ++a.
    a++ means increment a AFTER you have performed the line.
    ++a mean increment a BEFORE you perform the line.
    class Test
    public static void main(String[] args)
    int a = 4;
    a = ++a; //returns a = 5
    // a = a++; //returns a = 4
    //a++; //returns a = 5
    //++a; //returns a = 5
    System.out.println ( a );
    }

  • Post increment operator i++

    I can't seem to figure out why the following is outputting 2,2,3 and not 2,3,4. Having searched the Java Language Spec and reading ... (http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#39438)
    ... it is still not clear. The key line probably is "The value of the postfix increment expression is the value of the variable before the new value is stored." I still think that the second output should have been 3 and not 2. Could someone explain this to me? Thanks.
    Here is the code that I tried:
    int i;
    i = 2;
    System.out.println(i);
    i = i++; // the line which I don't understand
    System.out.println(i);
    i++;
    System.out.println(i);

    The key is to understand the difference between the
    value of the expression and the value of the
    variable.
    i = i++;What that particular bit of devil-spawn does is
    this:
    1) Get the current value of i. The value of the
    postfix increment expression is the value of the
    variable before the new value is stored. So we
    have to get the "before it's incremented" value. This
    is the value of the expression i++.
    2) Increment i. This doesn't alter the value of the
    expression that was obtained in step 1.
    3) Take the value of the expression that was
    retrieved in step 1 (the value of i before being
    incremented) and stuff it into i.
    If you had int i = 2;
    int j;
    j = i++; Would you expect j to be 2 or 3? It will be 2. And
    the same reason that j is 2 here makes i 2 if you put
    i on the left of the equals.When the expression is "i = i + 1" compiled, it should be divided into two sub expressions :
    1.) i = i; //As postfix defination says use value first and then increment
    2)i = i + 1//Increment i;
    so, accordingly, the value of i after first step should be 0 and then after second step it is 1(C,C++ behaviour).
    so, the statement i = i++ must result into the value 1 for i, not 0.
    even in C#.net the value of i is 0 after the execution of above statement.

  • J-CONTENTS & INCREMENT OPERATOR

    I have 2-questions:-
    1. What are the contents of Core Java & Adv. Java?
    Is swing part of Core Java OR Adv. Java?
    2. Let int a=1;
    after execution of statement a=a+++a+a++; value of a will be 5
    after execution of statement a=++a+a+a++; vaue of a will be 6
    after execution of statement a=a+a+++a++; value of a will be 4
    Please Explaine me the logic behind it.
    Thanks & Regards,
    GAJESH TRIPATHI
    09252708020

    gajesh wrote:
    I have 2-questions:-
    1. What are the contents of Core Java & Adv. Java?
    Is swing part of Core Java OR Adv. Java?Huh? There is no official "core" vs. "advanced" (which is what I assume you mean by "adv"). Swing is part of the core API.
    2. Let int a=1;
    after execution of statement a=a+++a+a++; value of a will be 5
    after execution of statement a=++a+a+a++; vaue of a will be 6
    after execution of statement a=a+a+++a++; value of a will be 4
    Please Explaine me the logic behind it.No. That's ridiculous code. You'll never see that for real.
    Instead just learn about the difference between pre-increment (++x) and post-increment (x++).
    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/op1.html

  • Behaviour of post increment/decrement operator

    int i = 1;
    i = ++i;
    System.out.println( i ); //output is 2
    i = i++;
    System.out.println( i ); // output is 2, WHY?

    Well, it seems that you didn't get the point at all.
    I know how to do the increment operation. What I
    intended to know is the behavior in this scenario.
    And you got that in reply 2.I assumed the answer to be that. but i was only trying to be sure.
    I know that such codes r not in common use and they are meaningless too, but such codes do come up in various quizzes, etc. to test ur knowledge. we always learn WHAT not to do, but we seldom try to know WHY not to do it. in our endeavor to learn advanced topics we tend to ignore the basics.
    Coming back to the original code can someone tell me whether this is a well defined behavior unlike c/c++ where the behavior of such codes are undefined. as far as i know java is a strongly typed language, where ambiguities have been eliminated (believe i am not wrong on this). Can i expect the same results on all compilers??
    and i hope that the forum behaves in a sane manner in future. Instead of blatantly dismissing a post, let people give reasons for it.
    Thanks

  • Operator precedence: prefix vs postfix incremental

    Hello pal,
    I am confused whether postfix incremental operator has more precedence that the prefix incremental operator or not.
    The following URL shows that postfix incremental operator has superior precedence.
    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/expressions.html
    I wrote a simple program to test the concept,however, it looks like they have equal precedence.
    public class Precedence {
            public static void main(String[] args) {
                    int i, k;
                    k = 10;
                    i = ++k * k++;
                    System.out.println("k = 10;");
                    System.out.println("i = ++k * k++;" + " = " + i);
                    k = 10;
                    i = k++ * ++k;
                    System.out.println("k = 10;");
                    System.out.println("i = k++ * ++k;" + " = " + i);
    }The output surprises me, though. (Note that I run the program on IBM JRE 1.3.1 build cn131w-20020403 ORB130.)
    k = 10;
    i = ++k * k++; = 121
    k = 10;
    i = k++ * ++k; = 120
    Question: Is this a correct behaviour ... or my test program is wrong?

    Yes, this is correct behavior.
    k = 10;
    i = ++k * k++;
    ++k is incremented to 11, but k++ is not because its a postfix increment, it is assigned after i. So this ends up being 11 * 11 which gets you 121.
    k = 10;
    i = k++ * ++k;
    k++ is assign after the operator, so it remains 10. ++k is a prefix increment, so this becomes 11, but the postfix increment makes it 12. So this ends up being 10 * 12, which becomes 120.
    It all makes sense if you look at this code. It's actually what's happening:
    public class Precedence {
            public static void main(String[] args) {
                    int i, k, j;
                    j = 0;
                    k = 10;
                    i = ++k;
                    i = i * k++;
                    System.out.println("k = 10;");
                    System.out.println("i = ++k * k++;" + " = " + i);
                    k = 10;
                    i = k++;
                    i = i * ++k;
                    System.out.println("k = 10;");
                    System.out.println("i = k++ * ++k;" + " = " + i);

  • (Error in documentation?) Math operator precedence problem

    Hello,
    I apologize in advance, while I do know programming (I'm a PHP and Perl programmer) I'm fairly new to Java so this may well be a silly question, but that's why I am here. I hope you'll show me where my error is so I can finally set this to rest before it drives me mad :)
    (Also, I hope I'm posting this in the right forum?)
    So, I am taking a Java class, and the question in the homework related to operand precendence. When dealing with multiplication, division and addition, things were fine, the documentation is clear and it also makes sense math-wise (multiplication comes before addition, etc etc).
    However, we got this exercise to solve:
    If u=2, v=3, w=5, x=7 and y=11, find the value assuming int variables:
    u++ / v+u++ *w
    Now, according to the operator precedence table (http://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html) the unary operator u++ comes first, before multiplication, division and addition.
    This would mean I could rewrite the exercise as:
    ((u+1)/v) + ((u+1)*w) = (3/3) + (4*5) = 1+20 = 21
    However, if I run this in Java, the result I get is 15.
    I tried breaking up the result for the two values in the Java code, so I could see where the problem is with my calculation.
    For
    System.out.println(u++ /v);
    I get 0
    For
    System.out.println("u++ *w");
    I get 15
    My professor suggested I attempt to change the values from int to float, so I can see if the division came out to be something illogical. I did so, and now I get:
    For
    System.out.println(u++ /v);
    I get 0.66667
    For
    System.out.println("u++ *w");
    I get 15.0000
    Which means that for the first operation (the division) the division happens on 2/3 (which is 0.6667) and only afterwards the u value is increased. That is, the u++ operation is done after the division, not before. The same happens with the multiplication; when that is carried out, the value of u is now 3 (after it was raised by one in the previous operation) and the first to be carried out is the multiplication (3*5=15) and only then the u++.
    That is entirely against the documentation.
    This is the script I wrote to test the issue:
    public class MathTest {
         public static void main (String [] args) {
              float u=2, v=3, w=5, x=7, y=11;
              System.out.println("Initial value for 'u': " + u);
              float tmp1 = u++ /v;
              System.out.println("u++ /v = " + tmp1);
              System.out.println("First ++ value for 'u': " + u);
              float tmp2 = u++ *w;
              System.out.println("u++ *w= " + tmp2);
              System.out.println("Second ++ value for 'u': " + u);
              System.out.println(tmp1+tmp2);
    The output:
    Initial value for 'u': 2.0
    u++ /v = 1.0
    First ++ value for 'u': 3.0
    u++ *w= 20.0
    Second ++ value for 'u': 4.0
    21.0
    Clearly, the ++ operation is done after the division and after the multiplication.
    Am I missing something here? Is the documentation wrong, or have I missed something obvious? This is driving me crazy!
    Thanks in advance,
    Mori

    >
    The fact that u++ is evaluated but in the calculation itself the "previously stored" value of u is used is completely confusing.
    >
    Yes it can be confusing - and no one is claiming otherwise. Here are some more thread links from other users about the same issue.
    Re: Code Behavior is different in C and Java.
    Re: diffcult to understand expression computaion having operator such as i++
    Operator Precedence for Increment Operator
    >
    So, when they explain that ++ has a higher precedence, the natural thing to consider is that you "do that first" and then do the rest.
    >
    And, as you have discovered, that would be wrong and, to a large degree, is the nut of the issue.
    What you just said illustrates the difference between 'precedence' and 'evaluation order'. Precedence determines which operators are evaluated first. Evaluation order determines the order that the 'operands' of those operators are evaluated. Those are two different, but related, things.
    See Chapter 15 Expressions
    >
    This chapter specifies the meanings of expressions and the rules for their evaluation.
    >
    Sections in the chapter specify the requirements - note the word 'guarantees' in the quoted text - see 15.7.1
    Also read carefully section 15.7.2
    >
    15.7. Evaluation Order
    The Java programming language guarantees that the operands of operators appear to be evaluated in a specific evaluation order, namely, from left to right.
    15.7.1. Evaluate Left-Hand Operand First
    The left-hand operand of a binary operator appears to be fully evaluated before any part of the right-hand operand is evaluated.
    If the operator is a compound-assignment operator (§15.26.2), then evaluation of
    the left-hand operand includes both remembering the variable that the left-hand
    operand denotes and fetching and saving that variable's value for use in the implied
    binary operation.
    15.7.2. Evaluate Operands before Operation
    The Java programming language guarantees that every operand of an operator (except the conditional operators &&, ||, and ? appears to be fully evaluated before any part of the operation itself is performed.
    15.7.3. Evaluation Respects Parentheses and Precedence
    The Java programming language respects the order of evaluation indicated explicitly by parentheses and implicitly by operator precedence.
    >
    So when there are multiple operators in an expression 'precedence' determines which is evaluated first. And, the chart in your link shows 'postfix' is at the top of the list.
    But, as the quote from the java language spec shows, the result of 'postfix' is the ORIGINAL value before incrementation. If it makes it easier for then consider that this 'original' value is saved on the stack or a temp variable for use in the calculation for that operand.
    Then the evalution order determines how the calculation proceeds.
    It may help to look at a different, simpler, but still confusing example. What should the value of 'test' be in this example?
    i = 0;
    test = i++; The value of 'test' will be zero. The value of i++ is the 'original' value before incrementing and that 'original' value is assigned to 'test'.
    At the risk of further confusion here are the actual JVM instructions executed for your example. I just used
    javap -c -l Test1to disassemble this. I manually added the actual source code so you can try to follow this
            int u = 2;
       4:iconst_2       
       5:istore  5
            int v = 3;
       7:iconst_3       
       8:istore          6
            int w = 5;
      10:iconst_5       
      11:istore          7
            int z;
            z = z = u++ / v + u++ * w;
       13:  iload   5
       15:  iinc    5, 1
       18:  iload   6
       20:  idiv
       21:  iload   5
       23:  iinc    5, 1
       26:  iload   7
       28:  imul
       29:  iadd
       30:  dup
       31:  istore  8
       33:  istore  8The Java Virtual Machine Specification has all of the JVM instructions and what they do.
    http://docs.oracle.com/javase/specs/jvms/se7/jvms7.pdf
    Your assignment to z and formula starts with line 13: above
    13: iload 5 - 'Load int from local variable' page 466
    15: iinc 5, 1 - 'Increment local variable by constant' page 465
    18: iload 6 - another load
    20: idiv - do the division page
    21: iload 5 - load variable 5 again
    23: iinc 5, 1 - inc variable 5 again
    26: iload 7 - load variable 7
    28: imul - do the multiply
    29: iadd - do the addition
    30: dup - duplicate the top stack value and put it on the stack
    31: istore 8 - store the duplicated top stack value
    33: istore 8 - store the original top stack value
    Note the description of 'iload'
    >
    The value of the local variable at index
    is pushed onto the operand stack.
    >
    IMPORTANT - now note the description of 'iinc'
    >
    The value const is first sign-extended to an int, and then
    the local variable at index is incremented by that amount.
    >
    The 'iload' loads the ORIGINAL value of the variable and saves it on the stack.
    Then the 'iinc' increments the VARIABLE value - it DOES NOT increment the ORIGINAL value which is now on the stack.
    Now note the description of 'idiv'
    >
    The values are popped
    from the operand stack. The int result is the value of the Java
    programming language expression value1 / value2. The result is
    pushed onto the operand stack.
    >
    The two values on the stack include the ORIGINAL value of the variable - not the incremented value.
    The above three instructions explain the result you are seeing. For postfix the value is loaded onto the stack and then the variable itself (not the loaded original value) is incremented.
    Then you can see what this line does
      21:  iload   5 - load variable 5 againIt loads the variable again. This IS the incremented value. It was incremented by the 'iinc' on line 15 that I discussed above.
    Sorry to get so detailed but this question seems to come up a lot and maybe now you have enough information and doc links to explore this to any level of detail that you want.

  • X increment

    for(int x = 0 ; x < 10 ; ++x)  // x++    Whats the difference between these two types of increments?  The sop is starting with 0 to 9 both the ways.
                   System.out.println("x = " + x);
              }Edited by: bobz on 11-Dec-2009 16:23

    bobz wrote:
    for(int x = 0 ; x < 10 ; ++x)  // x++
    // Whats the difference between these two types of increments?
    You would notice a difference only if you used the side effect of the operator, which side effect differs between the two forms.
    For example:
    int y = -1;
    for (int x = 0; x < 10; y = ++x)
      // Use y here
    }Then change the above to use y = x++ and notice the difference where y is used in the loop.
    Note that I would never write a loop like above, and rarely ever write code that depends on the side-effect. So in almost all of my practice, I can use the pre-increment operator and post-increment operator interchangeably.

  • JAVA operator precedence table is wrong.

    I can not understand why JAVA auto-increment/decrement operator does not follow the rules of Operator Precedence table at http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html
    The precedent order is as follow:
    postfix: expr++ expr--
    unary: ++expr --expr +expr -expr ~ !
    multiplicative: * / %
    From the above we know that x++/x-- is higher then ++x/--x and multiplicative is the lower then both.
    I tested the following in JAVA:
    int y,x = 2;
    y = --x * x++;
    System.out.println(x); //Output is 1.
    Why?
    Theoretically, x++ must be performed before --x, finally then the multiplication (*) and the answer should be
    x++ value=2, stored variable=3
    --x value=2, stored variable=2
    Therefore 2 * 2 = 4.
    Why JAVA is not following the rules that it setup for itself??
    After much research, my conclusion is JAVA Operator Precedence table in java.sun.com website is wrong. The right version should be the same as this website: http://www.sorcon.com/java2/precedence.htm.
    Please run your example code in JAVA before you want to prove me wrong.
    Thank you.

    Hi jsalonen, thank you for your reply. Yes, I see your theory but sorry to say that I don't agree with you. Let's take your example -x++ for our discussion below:
    First let's agree with this:
    x = 2;
    y = -x;
    System.out.println("y = " + y); // y = -2
    System.out.println("x = " + x); // x = 2
    From the above, we can see that by using the negation operator doesn't mean that we have changed the value of x variable. The system just assigns the value of x to the expression but still keeping the value of variable x. That's why we got the output above, agree?
    Now, let's evaluate your example:
    int y, x = 2;
    y = -x++;
    System.out.println("y = " + y); // -2
    System.out.println("x = " + x); // 3
    Hence below is the sequence of process:
    1. -x is evaluated first. Value in variable x is assigned to the expression. At this point the value of x is 2 and this value get negated. However the variable x still storing 2.
    2. Now x++ get evaluated, since this is a postfix increment operator, the value will get assigned first then increase. However x is already assigned, we can not assign it twice, just like if you perform x++ first, you have assigned x then increase and you didn't assign it again for the negation operator. If you did, x would be 3 and get negated to -3. Note that system also cannot perform 2++ because 2 is not a variable. Therefore it is logical to say that x is assigned to the expression and got negated by negation operator then increase the varaible x by 1. So here we increase the value of x by 1 and the result is 3. Therefore variable x is storing 3.
    Now, try the follwing
    x = 2;
    y = -x + x++;
    What is the value of x after -x? It's 2. Remember 2 is assign back to expression but x still retained the original value. If not we would expect x++ to be (-2)++, right?
    But see the output for yourself:
    System.out.println("y = " + y); // 0
    System.out.println("x = " + x); // 3
    As for the subexpression theory, sorry to say that I don't agree with you as well. See the expression below:
    y = -x + x++;
    We can identify that there are 4 operators in this statement, right? (assignment operator, negation operator, addition operator and increment operator)
    since JAVA has defined all the operators in the table and already given each of them a priory and associativity, I don't see any subexpression here. If yes why didn't they mention about subexpression rule in the table? Shouldn't that be defined explicitly so that it doesn't confuse people?
    In conclusion, I still think that JAVA need to correct the operators precedence table at http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html so that they don't confused people for another 10 years. :) Moreover the table is not complete because it did not include . and [ ] and (params) operators.

  • Difference between Pre and Post Incrementing a variable

    I have a problem understanding the nuances between i++ and ++i.
    I have run several loops and changed the position of the "++". I noticed that sometimes the out put differs and sometimes the output remains the same.
    Is there a rule of thumb as to whether a variable show be post or pre incremented?
    Thanks

    Thank you all.
    After I asked the question, I did a little research and found this (from JGuru shortcourse):
    Note that x++ and ++x are equivalent in standalone contexts where the only task is to increment a variable by one,that is, contexts where the ultimate evaluation is ignored:
    int x = 4;
    x++; // same effect as ++x
    System.out.println("x = " + x);
    This code produces the output:
    x = 5;
    The next part after this is:
    In the following context, the placement of the increment operator is important:
    int x = 4;
    int y = x++;
    int z = ++x;
    System.out.println(
    "x = " + x + " y = " + y + " z = " + z);
    This code produces the output:
    x = 6 y = 4 z = 6
    ======================================================================
    I thought the out put would be x = 4, y = 6, z = 4.
    I totally lost! How do I interpet this correctly?

  • I had a doubt in jdeveloper11g

    first watch out the example.
    eg : select starting_number from tablename1;
    starting_number // field name
    1000 // user defined.
    after saving the data. perform increment operation.
    starting number // field name
    1001 //auto increment takes by with help of code.
    Most often peoples using sequence number for generating unique number.
    My idea is :
    i will define the start number as 1000 and perform increment operation .does not mention end number(i.e) it will be infinity.
    this starting number field is in defined in a table. while am commit the data in the UI . unique number must be generated.(number generation based on the field what it contains)
    how to handle this?
    but i tried in the following manner:
    In SessionEJBClient - In the main function
    table_ name b; //b - object of that table;
    String str1 = b.getNextnum(); // getting number from the table
    int num = Integer.parseInt(str1); // convert it.
    num = num+1; // increment one by one
    String str2 = new Integer(num).toString();
    b.setProsNextId(str2); // assign to the table
    by using
    tx.commit // update the newly generated number to corresponding table.
    it's working .
    but it unable to show in user interface.
    how can i communicate Session Client - UI. Is it Possible to do this.
    how to show the generated number in UI. if any one know.please guide that will be great.
    Edited by: 871573 on Jul 11, 2011 4:05 AM
    Edited by: 871573 on Jul 11, 2011 7:56 AM
    Edited by: 871573 on Jul 11, 2011 8:05 AM

    sir,
    i tried it. its fine. in previous post.something i tried. itz working unable to complete it. sessionclient and ui interaction is not takes places.
    if you don mine can u say?
    can u guide? or suggest any other ideas. for my previous post.

  • Problem in date functions

    Using:
    Jdev 11.1.1.5.0-adfbc
    problem description:
    problem in function not properly working
    Resource:
    this is my vo query which is based on one eo
    SELECT LegalDocDetailsEO.LDD_BE,
           LegalDocDetailsEO.LDD_UNIT,
           LegalDocDetailsEO.LDD_SUPLR_ID,
           LegalDocDetailsEO.LDD_CUST_ID,
           LegalDocDetailsEO.LDD_EMP_ID,
           LegalDocDetailsEO.LDD_DOC_ID,
           LegalDocDetailsEO.LDD_DOC_NO,
           LegalDocDetailsEO.LDD_ISSUED_AT,
           LegalDocDetailsEO.LDD_ISSUED_ON,
           LegalDocDetailsEO.LDD_VALID_FRQ,
           LegalDocDetailsEO.LDD_VALID_DUR,
    (case when LDD_VALID_FRQ='D'  then LDD_ISSUED_ON +  LDD_VALID_DUR                       //D-Date
          when LDD_VALID_FRQ='M'   then add_months(LDD_ISSUED_ON,LDD_VALID_DUR)        //M -Month  //Y-Year
          else add_months(LDD_ISSUED_ON,LDD_VALID_DUR*12)
    end ) as  LDD_EXP_ON,
           LegalDocDetailsEO.LDD_STATUS,
           LegalDocDetailsEO.LDD_SL_FLG,
           LegalDocDetailsEO.LDD_VEHICLE_ID,
           LegalDocDetailsEO.LDD_BFCRY_TYPE,
           LegalDocDetailsEO.LDD_EMPDEPNT_NO,
           LegalDocDetailsEO.LDD_ASSET_ID,
           LegalDocDetailsEO.LDD_PROD_UNIT,
           LegalDocDetailsEO.LDD_PROD_ID,
           LegalDocDetailsEO.LDD_PROD_REV,
           LegalDocDetailsEO.LDD_CRE_BY,
           LegalDocDetailsEO.LDD_CRE_DATE,
           LegalDocDetailsEO.LDD_UPD_BY,
           LegalDocDetailsEO.LDD_UPD_DATE,
           LegalDocDetailsEO.ROWID
    FROM LEGAL_DOC_DETAILS LegalDocDetailsEO
    WHERE LegalDocDetailsEO.LDD_BE = :pbuthis vo exposed as af:table
    <af:panelBox
                           binding="#{backingBeanScope.cfg0060.pb18}" id="pb18"
                           showDisclosure="false">
                <f:facet name="toolbar">
                  <af:group binding="#{backingBeanScope.cfg0060.g6}" id="g6">
                    <af:toolbar binding="#{backingBeanScope.cfg0060.t19}" id="t19">
                      <af:commandToolbarButton actionListener="#{bindings.CreateInsert13.execute}"
                                               text="Insert"
                                               disabled="#{!bindings.CreateInsert13.enabled}"
                                               binding="#{backingBeanScope.cfg0060.ctb90}"
                                               id="ctb90"/>
                      <af:commandToolbarButton
                                               text="Save"
                                               binding="#{backingBeanScope.cfg0060.ctb91}"
                                               id="ctb91"
                                               action="#{backingBeanScope.cfg0060.*ctb91_action2*}"
                                               partialTriggers="pc5:t18"/>
                      <af:commandToolbarButton text="Clear"
                                               binding="#{backingBeanScope.cfg0060.ctb92}"
                                               id="ctb92" icon="/icons/clear.png"/>
                     <af:commandToolbarButton text="Rollback"
                                               binding="#{backingBeanScope.cfg0060.ctb94}"
                                               id="ctb94"
                                             icon="/icons/rollback.png"/>
                      <af:commandToolbarButton text="Additional Details"
                                               binding="#{backingBeanScope.cfg0060.ctb95}"
                                               id="ctb95"/>
                      <af:commandToolbarButton text="Activate"
                                               binding="#{backingBeanScope.cfg0060.ctb96}"
                                               id="ctb96"
                                               icon="/icons/confirm.png"/>
                    </af:toolbar>
                  </af:group>
                </f:facet>
                <af:panelCollection binding="#{backingBeanScope.cfg0060.pc5}"
                                    id="pc5" styleClass="AFStretchWidth">
                  <f:facet name="menus"/>
                  <f:facet name="toolbar"/>
                  <f:facet name="statusbar"/>
                  <af:table value="#{bindings.LegalDocDetails1VO2.collectionModel}"
                            var="row"
                            rows="#{bindings.LegalDocDetails1VO2.rangeSize}"
                            emptyText="#{bindings.LegalDocDetails1VO2.viewable ? 'No data to display.' : 'Access Denied.'}"
                            fetchSize="#{bindings.LegalDocDetails1VO2.rangeSize}"
                            rowBandingInterval="0"
                            filterModel="#{bindings.LegalDocDetails1VO2Query.queryDescriptor}"
                            queryListener="#{bindings.LegalDocDetails1VO2Query.processQuery}"
                            filterVisible="true" varStatus="vs"
                            selectedRowKeys="#{bindings.LegalDocDetails1VO2.collectionModel.selectedRow}"
                            selectionListener="#{bindings.LegalDocDetails1VO2.collectionModel.makeCurrent}"
                            rowSelection="single"
                            binding="#{backingBeanScope.cfg0060.t18}" id="t18"
                            partialTriggers=":::ctb90">
                    <af:column sortProperty="LddDocId" filterable="true"
                               sortable="true"
                               headerText="#{bindings.LegalDocDetails1VO2.hints.LddDocId.label}"
                               id="c19">
                      <af:inputText value="#{row.bindings.LddDocId.inputValue}"
                                    label="#{bindings.LegalDocDetails1VO2.hints.LddDocId.label}"
                                    required="#{bindings.LegalDocDetails1VO2.hints.LddDocId.mandatory}"
                                    columns="#{bindings.LegalDocDetails1VO2.hints.LddDocId.displayWidth}"
                                    maximumLength="#{bindings.LegalDocDetails1VO2.hints.LddDocId.precision}"
                                    shortDesc="#{bindings.LegalDocDetails1VO2.hints.LddDocId.tooltip}"
                                    id="it144">
                        <f:validator binding="#{row.bindings.LddDocId.validator}"/>
                      </af:inputText>
                    </af:column>
                    <af:column sortProperty="LdDocIdDesc" filterable="true"
                               sortable="true"
                               headerText="#{bindings.LegalDocDetails1VO2.hints.LdDocIdDesc.label}"
                               id="c22">
                      <af:inputText value="#{row.bindings.LdDocIdDesc.inputValue}"
                                    label="#{bindings.LegalDocDetails1VO2.hints.LdDocIdDesc.label}"
                                    required="#{bindings.LegalDocDetails1VO2.hints.LdDocIdDesc.mandatory}"
                                    columns="#{bindings.LegalDocDetails1VO2.hints.LdDocIdDesc.displayWidth}"
                                    maximumLength="#{bindings.LegalDocDetails1VO2.hints.LdDocIdDesc.precision}"
                                    shortDesc="#{bindings.LegalDocDetails1VO2.hints.LdDocIdDesc.tooltip}"
                                    id="it145">
                        <f:validator binding="#{row.bindings.LdDocIdDesc.validator}"/>
                      </af:inputText>
                    </af:column>
                    <af:column sortProperty="LddDocNo" filterable="true"
                               sortable="true"
                               headerText="#{bindings.LegalDocDetails1VO2.hints.LddDocNo.label}"
                               id="c21">
                      <af:inputText value="#{row.bindings.LddDocNo.inputValue}"
                                    label="#{bindings.LegalDocDetails1VO2.hints.LddDocNo.label}"
                                    required="#{bindings.LegalDocDetails1VO2.hints.LddDocNo.mandatory}"
                                    columns="#{bindings.LegalDocDetails1VO2.hints.LddDocNo.displayWidth}"
                                    maximumLength="#{bindings.LegalDocDetails1VO2.hints.LddDocNo.precision}"
                                    shortDesc="#{bindings.LegalDocDetails1VO2.hints.LddDocNo.tooltip}"
                                    id="it146">
                        <f:validator binding="#{row.bindings.LddDocNo.validator}"/>
                      </af:inputText>
                    </af:column>
                    <af:column sortProperty="LddIssuedAt" filterable="true"
                               sortable="true"
                               headerText="#{bindings.LegalDocDetails1VO2.hints.LddIssuedAt.label}"
                               id="c15">
                      <af:inputText value="#{row.bindings.LddIssuedAt.inputValue}"
                                    label="#{bindings.LegalDocDetails1VO2.hints.LddIssuedAt.label}"
                                    required="#{bindings.LegalDocDetails1VO2.hints.LddIssuedAt.mandatory}"
                                    columns="#{bindings.LegalDocDetails1VO2.hints.LddIssuedAt.displayWidth}"
                                    maximumLength="#{bindings.LegalDocDetails1VO2.hints.LddIssuedAt.precision}"
                                    shortDesc="#{bindings.LegalDocDetails1VO2.hints.LddIssuedAt.tooltip}"
                                    id="it147">
                        <f:validator binding="#{row.bindings.LddIssuedAt.validator}"/>
                      </af:inputText>
                    </af:column>
                    <af:column sortProperty="LddIssuedOn" filterable="true"
                               sortable="true"
                               headerText="#{bindings.LegalDocDetails1VO2.hints.LddIssuedOn.label}"
                               id="c17">
                      <f:facet name="filter">
                        <af:inputDate value="#{vs.filterCriteria.LddIssuedOn}"
                                      binding="#{backingBeanScope.cfg0060.id7}"
                                      id="id7"/>
                      </f:facet>
                      <af:inputDate value="#{row.bindings.LddIssuedOn.inputValue}"
                                    label="#{bindings.LegalDocDetails1VO2.hints.LddIssuedOn.label}"
                                    required="#{bindings.LegalDocDetails1VO2.hints.LddIssuedOn.mandatory}"
                                    shortDesc="#{bindings.LegalDocDetails1VO2.hints.LddIssuedOn.tooltip}"
                                    id="id10">
                        <f:validator binding="#{row.bindings.LddIssuedOn.validator}"/>
                        <af:convertDateTime pattern="#{bindings.LegalDocDetails1VO2.hints.LddIssuedOn.format}"/>
                      </af:inputDate>
                    </af:column>
                    <af:column sortProperty="LddValidFrq" filterable="true"
                               sortable="true"
                               headerText="#{bindings.LegalDocDetails1VO2.hints.LddValidFrq.label}"
                               id="c20">
                      <af:selectOneChoice value="#{row.bindings.LddValidFrq.inputValue}"
                                          label="#{row.bindings.LddValidFrq.label}"
                                          required="#{bindings.LegalDocDetails1VO2.hints.LddValidFrq.mandatory}"
                                          shortDesc="#{bindings.LegalDocDetails1VO2.hints.LddValidFrq.tooltip}"
                                          id="soc12" autoSubmit="true">
                        <f:selectItems value="#{row.bindings.LddValidFrq.items}"
                                       id="si13"/>
                      </af:selectOneChoice>
                    </af:column>
                    <af:column sortProperty="LddValidDur" filterable="true"
                               sortable="true"
                               headerText="#{bindings.LegalDocDetails1VO2.hints.LddValidDur.label}"
                               id="c18">
                      <af:inputText value="#{row.bindings.LddValidDur.inputValue}"
                                    label="#{bindings.LegalDocDetails1VO2.hints.LddValidDur.label}"
                                    required="#{bindings.LegalDocDetails1VO2.hints.LddValidDur.mandatory}"
                                    columns="#{bindings.LegalDocDetails1VO2.hints.LddValidDur.displayWidth}"
                                    maximumLength="#{bindings.LegalDocDetails1VO2.hints.LddValidDur.precision}"
                                    shortDesc="#{bindings.LegalDocDetails1VO2.hints.LddValidDur.tooltip}"
                                    id="it148" autoSubmit="true"
                                    partialTriggers="soc12">
                        <f:validator binding="#{row.bindings.LddValidDur.validator}"/>
                        <af:convertNumber groupingUsed="false"
                                          pattern="#{bindings.LegalDocDetails1VO2.hints.LddValidDur.format}"/>
                      </af:inputText>
                    </af:column>
                    <af:column sortProperty="LddExpOn" filterable="true"
                               sortable="true"
                               headerText="#{bindings.LegalDocDetails1VO2.hints.LddExpOn.label}"
                               id="c16">
                      <f:facet name="filter">
                        <af:inputDate value="#{vs.filterCriteria.LddExpOn}"
                                      binding="#{backingBeanScope.cfg0060.id8}"
                                      id="id8"/>
                      </f:facet>
                      <af:inputDate value="#{row.bindings.LddExpOn.inputValue}"
                                    label="#{bindings.LegalDocDetails1VO2.hints.LddExpOn.label}"
                                    required="#{bindings.LegalDocDetails1VO2.hints.LddExpOn.mandatory}"
                                    shortDesc="#{bindings.LegalDocDetails1VO2.hints.LddExpOn.tooltip}"
                                    id="id9" partialTriggers="it148">
                        <f:validator binding="#{row.bindings.LddExpOn.validator}"/>
                        <af:convertDateTime pattern="#{bindings.LegalDocDetails1VO2.hints.LddExpOn.format}"/>
                      </af:inputDate>
                    </af:column>
                    <af:column sortProperty="LddStatus" filterable="true"
                               sortable="true"
                               headerText="#{bindings.LegalDocDetails1VO2.hints.LddStatus.label}"
                               id="c14">
                      <af:selectOneChoice value="#{row.bindings.LddStatus.inputValue}"
                                          label="#{row.bindings.LddStatus.label}"
                                          required="#{bindings.LegalDocDetails1VO2.hints.LddStatus.mandatory}"
                                          shortDesc="#{bindings.LegalDocDetails1VO2.hints.LddStatus.tooltip}"
                                          id="soc13">
                        <f:selectItems value="#{row.bindings.LddStatus.items}"
                                       id="si12"/>
                      </af:selectOneChoice>
                    </af:column>
                  </af:table>
                </af:panelCollection>
              </af:panelBox>
        public String ctb91_action2() {
            BindingContainer bindings = getBindings();
            DCIteratorBinding dciter2;
            dciter2 = (DCIteratorBinding) bindings.get("LegalDocDetails1VO2Iterator");
            ViewObject vo2 = dciter2.getViewObject();
            vo2.clearCache();
            vo2.executeQuery();
            //dciter2.executeQuery();
            OperationBinding operationBinding = bindings.getOperationBinding("Commit");
            Object result = operationBinding.execute();
            if (!operationBinding.getErrors().isEmpty()) {
                return null;
            return null;
        }this is my save button code.
    while pressing save button date,month,year increment operation takes place.
    i did like this:
    date issued : 3/10/1999
    validtiy type : months /days /years in select one choice
    validty time : 1 if i give 1 means
    date expires on : *4*/10/1999 it should be generates by pressing save button.
    by my issues:
    first time pressing button
    date expires on : *23*/10/1999 wrongly generated. each every first time default adding 10 to date. i dont have default value. why it's happening
    eventhough used clearcache. but it's not perforing correctly in first time
    by second time or third time... n tmes means
    date expires on : *4*/10/1999 it correctly generating.
    see pics.
    inputdate: 2/18/2012:
    wrongly generating : http://imageshack.us/photo/my-images/210/testttt.png/ in this pics see expires on : 2/28/2012
    correctly generating : http://imageshack.us/photo/my-images/341/testtsds.png/ in this pics see expires on : 2/20/2012
    i followed one of my thread: JDeveloper and ADF
    Edited by: subu123 on Feb 24, 2012 6:27 AM

    thank you sir. for visting my thread. i understood. how can i over come that?
    SELECT LegalDocDetailsEO.LDD_BE,
           LegalDocDetailsEO.LDD_UNIT,
           LegalDocDetailsEO.LDD_SUPLR_ID,
           LegalDocDetailsEO.LDD_CUST_ID,
           LegalDocDetailsEO.LDD_EMP_ID,
           LegalDocDetailsEO.LDD_DOC_ID,
           LegalDocDetailsEO.LDD_DOC_NO,
           LegalDocDetailsEO.LDD_ISSUED_AT,
           LegalDocDetailsEO.LDD_ISSUED_ON,
           LegalDocDetailsEO.LDD_VALID_FRQ,
           LegalDocDetailsEO.LDD_VALID_DUR,
    (case when LDD_VALID_FRQ='D'  then LDD_ISSUED_ON +  LDD_VALID_DUR                       //D-Date
          when LDD_VALID_FRQ='M'   then add_months(LDD_ISSUED_ON,LDD_VALID_DUR)        //M -Month  //Y-Year
          else add_months(LDD_ISSUED_ON,LDD_VALID_DUR*12)
    end ) as  LDD_EXP_ON,
           LegalDocDetailsEO.LDD_STATUS,
           LegalDocDetailsEO.LDD_SL_FLG,
           LegalDocDetailsEO.LDD_VEHICLE_ID,
           LegalDocDetailsEO.LDD_BFCRY_TYPE,
           LegalDocDetailsEO.LDD_EMPDEPNT_NO,
           LegalDocDetailsEO.LDD_ASSET_ID,
           LegalDocDetailsEO.LDD_PROD_UNIT,
           LegalDocDetailsEO.LDD_PROD_ID,
           LegalDocDetailsEO.LDD_PROD_REV,
           LegalDocDetailsEO.LDD_CRE_BY,
           LegalDocDetailsEO.LDD_CRE_DATE,
           LegalDocDetailsEO.LDD_UPD_BY,
           LegalDocDetailsEO.LDD_UPD_DATE,
           LegalDocDetailsEO.ROWID
    FROM LEGAL_DOC_DETAILS LegalDocDetailsEO
    WHERE LegalDocDetailsEO.LDD_BE = :pbui want to excute this vo. by pressing button. so only wrote like that.
    why am going excutes means?
    if am entering date and choosing select one choice means. by pressing button the button excutes vo and prorbably i get my output.
    is there any other way??? to attain my target..
    Edited by: subu123 on Mar 8, 2012 7:45 AM

  • How to give for a text field 'max+1' value instead of sequence .

    HI All,
    I have a requirement like ,
    For my text field i applied sequence by using groovy expression.Now i need to change that to 'max+' value of table Grid and display in the text field. Can please suggest me how can i implement .(JDev 11.1.1.3 v)
    Regards,
    Sindhu.

    hi user,
    if you want perform some increment operation . in auto means. donot prefer these thread given below..
    there is lot thread of for creating sequence. based on the sequence it works perfect.
    if i understud correctly means follow this
    Increment operation // it perfoms some increment operation. not using sequennce.
    button press
    compliation problem // have a look at this
    if cumes under cirumstance for multiple user on that scree or ui . probabaly this idea(max)or (some increment) will fails.
    i i will prefer sequqnecs._
    IN ADDITION INFO TO USER
    JOHN SAYIGN EXACTLY
    Edited by: Erp on Sep 25, 2011 9:46 PM

  • Writing scripts to edit or parse txt file How To?

    Not sure if this is the correct forum for programming type question. If not someone point me in the right direction?
    I'm a programming student and I'd like to teach myself some scripting skills over the summer break.
    In particular, I've got a txt file I'd like to split into three txt files. A google calendar file that I'd like to divide into three separate calendars.
    I know what strings I want to put where. My problem is what scripting language am I trying to use? Applescript? Something else?
    Any suggestions or ideas? Recommendations on reading materials or sample scripts I should look at?
    Thanks for the help.

    Perl is a huge programming language. A more expedient project would be to learn some basic shell commands such as sed, awk, tr and cut. The sed command is optimized for linewise operations, awk is optimized for columnwise operations and tr is a basic character translation tool especially useful when feeding Mac files into a UNIX command.
    Setting up sed and awk commands to read and write files is a big part of learning, especially since shell commands cannot normally write to a file in situ.
    Applescript is not ideal for text manipulation as it is slow, uses a bulky delimiter system and has irritating file access limitations. However it can be a powerful interface for the above mention shell commands. Applescript offers an ideal way to assemble shell commands with user-input variables. Of course, shell commands cannot be interactive with Applescript, so you learn to do incremental operations on text files.
    Another handy use for Applescript is to send your command to Terminal, which makes an ideal output display.

  • FOR Loop Exception Handling

    Given the following code:
    for x in my_cursor loop
        begin
            <<stmt_1>>
            <<stmt_2>>
        exception
            when others then
                <<log_error>>
        end;
    end loop;Say there are 5 x's in my_cursor. On element x3, stmt_1 works fine but stmt_2 throws an exception. I'd like to rollback ONLY the work done on x3 (in this case, stmt_1), then continue the loop from the next element, x4. Can this be achieved with some combination of savepoint/rollback?

    As I said, you can put the increment operation at the end of the block when you know no more exceptions could be raised, i.e.
    declare
        cnt number;
        ex  exception;
    begin
        cnt := 0;
        for x in 1..5 loop
            begin
                savepoint s;
                insert into test_tbl values(1/(3-x));
                cnt := cnt+1;
            exception
                when others then
                    rollback to savepoint s;
            end;
        end loop;
        dbms_output.put_line('cnt='||cnt);
    end;You could also increment the counter outside of the PL/SQL block, i.e.
    declare
        cnt number;
        ex  exception;
        num_success number;
    begin
        cnt := 0;
        for x in 1..5 loop
            begin
                num_success := 0;
                savepoint s;
                insert into test_tbl values(1/(3-x));
                num_success := sql%rowcount;
            exception
                when others then
                    rollback to savepoint s;
            end;
            cnt := cnt + num_success;
        end loop;
        dbms_output.put_line('cnt='||cnt);
    end;And you can refactor your code so that the components to hide some of this complexity, i.e.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure try_insert_test_tbl(
      2    p_val in number,
      3    p_num_success out number )
      4  as
      5    divide_by_zero exception;
      6    pragma exception_init( divide_by_zero, -1476 );
      7  begin
      8    savepoint s;
      9    insert into test_tbl values( 1/(3-p_val ) );
    10    p_num_success := sql%rowcount;
    11  exception
    12    when divide_by_zero
    13    then
    14      p_num_success := 0;
    15* end;
    SQL> /
    Procedure created.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2      cnt number;
      3      ex  exception;
      4      num_success number;
      5  begin
      6      cnt := 0;
      7      for x in 1..5 loop
      8          try_insert_test_tbl( x, num_success );
      9          cnt := cnt + num_success;
    10      end loop;
    11      dbms_output.put_line('cnt='||cnt);
    12* end;
    SQL> /
    cnt=4
    PL/SQL procedure successfully completed.There is no way for DCL statements to affect the state of PL/SQL variables. But you can generally structure your code in such a way that this is unnecessary.
    Justin

Maybe you are looking for

  • Big text showing in PDF from flex input

    Hi, I have a problem printing data to PDF from SQL. I'm using Rich text editor as it allows the user to add bullets, bold etc... and I'm using font Family arial and font size 12 in my flex form. Now when the data goes into DB it saves all the html ta

  • Chart not displaying data during preview mode

    Hi I hope you can help me with the following issue. I have created a dashboard in Xcelsius however during preview mode the chart is not showing the data. The cells which the chart is looking at are containing formulas to update based on the input of

  • Speed up the URL and Time out

    I have a database of links I use a statment to read of them pass them to a URL and read the site to extract links from there, if it the URL is broken it takes me 10 minutes to go to the next one, I have 200 odd links any help as to speed this up... i

  • IPhone 4 Reusing Same Picture Numbers

    Love my iPhone 4, less a few problems that I have as others, but this one really irks me. Seems that everytime I remove photos from my iPhone 4 that the next set of photos I take start with the same numbers as previously. For example, when I take sev

  • Squeaky MacBook hinge and hinge is also loose?

    My MacBook Pro is 8 months old, the past two months I have noticed that whenever I open or shut my screen it makes a clear squeaking noise. I am new to Mac's and my friend (who is much more experienced with Apple products) told me it's not normal and