I am puzzling if it is possible to add decimal values which I get from a stored procedure together and get all decimals within the loop added together as one value.  For example:  &lt;c:forEach var="row" items="${ aStoredProcedure }"&gt; &lt;fmt:formatNumber value="${ row.decimalNumber }"pattern="#,##0.00"/&gt; &lt;br&gt; &lt;/c:forEach&gt;   This prints out the values of each decimalNumber of each row onto their own lines in the form of common currency. I need a way to get all these decimalNumbers added together with each other, and I only need the final sum of them all. Can this be accomplished in JSP? any help is appreciated.
33695
I have a Java bean like this:  class Person {   int age;   String name; }   I'd like to iterate over a collection of these beans in a JSP, showing each person in a HTML table row, and in the last row of the table I'd like to show the total of all the ages.  The code to generate the table rows will look something like this:  &lt;c:forEach var="person" items="${personList}"&gt;   &lt;tr&gt;&lt;td&gt;${person.name}&lt;td&gt;&lt;td&gt;${person.age}&lt;/td&gt;&lt;/tr&gt; &lt;/c:forEach&gt;   However, I'm struggling to find a way to calculate the age total that will be shown in the final row without resorting to scriptlet code, any suggestions?
85947
How do you write a number with two decimal places for sql server?
31102
The example below throws an InvalidOperationException, "Collection was modified; enumeration operation may not execute." when executing the code.   var urls = new List&lt;string&gt;(); urls.Add("http://www.google.com");  foreach (string url in urls) {     // Get all links from the url     List&lt;string&gt; newUrls = GetLinks(url);      urls.AddRange(newUrls); // &lt;-- This is really the problematic row, adding values to the collection I'm looping }   How can I rewrite this in a better way? I'm guessing a recursive solution?
105039
The following code works:  \def \robble {robble} \def \robbles {\robble\robble}   But the following but doesn't:  \def \robbles {robble} \def \robbles {\robbles robble}   The overall goal is to get robbles to be robblerobble. I need something like the second example, where I am appending on to the current value of a variable. The way it is written right now causes a stack overflow. Is there a way to append to variables in LaTeX?
107704
I have data like multiples of 40. 40 80 120 160 200 and so on.    I would like to label every record that is a multiple of 100.  I have tried a couple of methods and can't get them to work either as a query in the label or as a select statement.  "STATION" =  %00   RIGHT ("STATION", 2) =  00     I get invalid SQL statement. Does anyone see what I am doing wrong?    Respectfully I did search and did not see any of the example questions you presented.  However it still does not answer my question, re-stated, what am I doing wrong?
33779
I came across some very strange behaviour when working with a Map with Decimal keys today. It seems like the Decimal type can't handle Integer assignments properly, but allows them nonetheless. I've written some example code demonstrating the problem:  Map&lt;Decimal, String&gt; m = new Map&lt;Decimal, String&gt;(); m.put(1234, 'Integer key');  m.put(1234.0, 'Decimal key'); m.put(1234.5, 'Decimal Unique key');  System.debug(m.get(1234));      // =&gt; Integer key, why was this not overwritten if 1234 == 1234.0? System.debug(m.get(1234.0));    // =&gt; Decimal key System.debug(m.get(1234.5));    // =&gt; Decimal Unique key  System.debug(m);        //Order of insertion matters, newest value does not override existing one but is not shown on map printout... for(Decimal d : m.keySet()){     System.debug(d);    //...unless you print it out yourself, because this loop shows all the keys }  //Sanity check System.debug(1234 == 1234.0); //True  //Digging deeper Decimal fake_d = 1234; Decimal real_d = 1234.0; Integer real_i = 1234; //Integer fake_i = 1234.0; //Illegal assignment, typechecking only works one way, it seems  //More sanity checks System.debug(fake_d == real_d); //True (Except when used in a Map, apparently) System.debug(fake_d == real_i); //True  System.debug(m.get(real_i)); // =&gt; Integer key System.debug(m.get(fake_d)); // =&gt; Integer key, even with fake_d explicitely declared as a Decimal type, it still pretends to be an Integer. System.debug(m.get(real_d)); // =&gt; Decimal key   I found this behaviour when I tried to fetch a value from a map using a Decimal sObject field, only to find that the keys I used to populate the Map (coming from a different Decimal field) were interpreted as Integers since they had no real decimal digits.  Maybe using Decimals as Map keys is not supported for some reason? Is it expected behaviour for 1234 and 1234.0 being distinct values in this case or is this an oversight in the Map implementation?
60603
I have a user with a query from an SQL Database that returns a series of string in this form:  000123123.23000 000123123.23000 000123123.23000 000123123.23000 000123123.23000   These are really numbers, however they cannot be summed.  The correct way to fix this might be to cast the data in the SQL query, but then the Excel query viewer can't display it. As a workaround I do    = &lt;CELL&gt; +1 -1.   Is there a more elegant solution?
69850
I have the following code:  Using cmd As SqlCommand = Connection.CreateCommand     cmd.CommandText = "UPDATE someTable SET Value = @Value"     cmd.CommandText &amp;= " WHERE Id = @Id"     cmd.Parameters.AddWithValue("@Id", 1234)     cmd.Parameters.AddWithValue("@Value", "myValue")     cmd.ExecuteNonQuery End Using   I wonder if there is any way to get the final SQL statment as a String, which should look like this:  UPDATE someTable SET Value = "myValue" WHERE Id = 1234   If anyone wonders why I would do this:   for logging (failed) statements for having the possibility to copy &amp; paste it to the Enterprise Manager for testing purposes
2534
I am trying to calculate field test2 with only the numeric values from a string field test. The entire script is like:    def makestr(test)      list=[]      for s in test:          if s.isdigit():              list.append(s)      for a in list:          str=''.join(list)     But I keep getting an error:    Any ideas?
32185
I'm trying to determine the best way to truncate or drop extra decimal places in SQL without rounding.  For example:  declare @value decimal(18,2)  set @value = 123.456   This will automatically round @value to be 123.46, which is good in most cases.  However, for this project, I don't need that.  Is there a simple way to truncate the decimals I don't need?  I know I can use the left() function and convert back to a decimal.  Are there any other ways?
51498
&lt;table&gt;          &lt;apex:repeat value="{!dataList}" var="List" id="dataTable"&gt;             &lt;tr&gt;                  &lt;th&gt;   Name &lt;/th&gt;                &lt;th&gt;   Status&lt;/th&gt;             &lt;/tr&gt;              &lt;tr&gt;                  &lt;td&gt;   &lt;apex:inputField value="{!List.Name}"/&gt; &lt;/td&gt;                &lt;td&gt;    &lt;apex:inputField value="{!List.Status__c}"/&gt;&lt;/td&gt;             &lt;/tr&gt;           &lt;/apex:repeat&gt;   &lt;/table&gt;     I want all rows to display horizontally not vertically i.e. in the same line one after another instead of in next line. How can this be done? The headings and values, both should be repeated horizontally.
63306
How can we extract the decimal part of a floating point number and store the decimal part and the integer part into two separate integer variables?
1992
While working in a Java app, I recently needed to assemble a comma-delimited list of values to pass to another web service without knowing how many elements there would be in advance. The best I could come up with off the top of my head was something like this:  public String appendWithDelimiter( String original, String addition, String delimiter ) {     if ( original.equals( "" ) ) {         return addition;     } else {         return original + delimiter + addition;     } }  String parameterString = ""; if ( condition ) parameterString = appendWithDelimiter( parameterString, "elementName", "," ); if ( anotherCondition ) parameterString = appendWithDelimiter( parameterString, "anotherElementName", "," );   I realize this isn't particularly efficient, since there are strings being created all over the place, but I was going for clarity more than optimization.  In Ruby, I can do something like this instead, which feels much more elegant:  parameterArray = []; parameterArray &lt;&lt; "elementName" if condition; parameterArray &lt;&lt; "anotherElementName" if anotherCondition; parameterString = parameterArray.join(",");   But since Java lacks a join command, I couldn't figure out anything equivalent.  So, what's the best way to do this in Java?
38898
I need to format a decimal value into a string where I always display at lease 2 decimals and at most 4.   So for example  "34.49596" would be "34.4959"  "49.3" would be "49.30"   Can this be done using the String.format command? Or is there an easier/better way to do this in Java.
21755
I am working on a multi-currency application. For the purpose of simplifying this question, we will not be considering currency conversion (hence I have deliberately left AsAt : datetime out of the equation). In a number of places I need to store monetary values (e.g. 1.23 USD). I understand that I need to store both the amount (1.23), and the currency (CurrencyID with FK to Currency table having ISOAlpha3Code = USD). My question is, how should I best encapsulate and isolate these two data from the other columns in the table (TableX) to which the monetary value relates?  As I see it, I have three options:   I store two columns in TableX, one being the Amount (numeric(p,s)) and one being the CurrencyID (FK). I add an XOR check constraint on the two columns to TableX. (DBMS dependent) I create a CLR UDT (or equivalent) representing Currency, storing both Amount and CurrencyID. I store one Currency type column on TableX containing the monetary value. I create a MonetaryAmount table with three columns: MonetaryAmountID (surrogate PK), CurrencyID (FK), and Amount. I add MonetaryAmountID (FK) to TableX.   I dislike #1 because I have used this pattern before and nobody has understood that the two data are part of the one complex datum; also, it's not normalized. I dislike #2 because it breaks 1NF, it is DBMS specific, and it will likely be difficult/expensive to enforce referential integrity on Currency. I'm rather ambivalent towards #3 - it feels over-engineered and will probably be computationally expensive, but it is correctly normalized.  #3 also has the added complexity of whether to place a unique constraint on the (CurrencyID, Amount) combination, thereby making it an ad-hoc reference table and better normalizing it. I believe it would be best not to do this, as whilst MonetaryAmounts may correlate, they are distinct in nature.  Any experience you can share (or alternatives you can suggest) would be appreciated. I would especially like to hear from genuine database architectural gurus.
34531
Using LINQ to SQL, I have an Order class with a collection of OrderDetails.  The Order Details has a property called LineTotal which gets Qnty x ItemPrice.   I know how to do a new LINQ query of the database to find the order total, but as I already have the collection of OrderDetails from the DB, is there a simple method to return the sum of the LineTotal directly from the collection?  I'd like to add the order total as a property of my Order class. I imagine I could loop through the collection and calculate the sum with a for each Order.OrderDetail, but I'm guessing there is a better way.
70173
While working on a project, I came across a JS-script created by a former employee that basically creates a report in the form of  Name : Value Name2 : Value2   etc.  The peoblem is that the values can sometimes be floats (with different precision), integers, or even in the form 2.20011E+17. What I want to output are pure integers. I don't know a lot of JavaScript, though.  How would I go about writing a method that takes these sometimes-floats and makes them integers?