Concatenate 0 to an Integer value.
hello experts..
i want to check the length of the variable if the length of the variable is equal to 1 then i want to concatenate 0 to that
number.
i tried like this, i took the value into string variable then cheked the length of the string. and concatenat the 0 to that string and i used the Integer.parseInt() to convert string into integer. when 0 is concatenate to that string then is show correctly but when use Integer.parseInt() then it shows number without concatenated.
so please help m experts.
If you are in java code, then the class java.text.DecimalFormat will be useful.
Giving the jsp solution:
<fmt:formatNumber value="${numberToDisplay}" minIntegerDigits="2"/>Heres a jsp page to try it out with:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<h2>Number format tag</h2>
<table>
<c:forEach begin="1" end="25" var="i">
<tr>
<td>${i}</td>
<td><fmt:formatNumber value="${i}" minIntegerDigits="2"/></td>
<td><fmt:formatNumber value="${i}" pattern="00"/></td>
</tr>
</c:forEach>
</table>cheers,
evnafets
Similar Messages
-
Getting integer values from a JTable
Hello
The table's cells contain integer values. I would like to save each one of theme them in an array of integers.
The problem is, I don't know how to do so. I tried to use the getValueAt method, but I always get error messages.
I tried something like:
Object o = table.getModel().getValueAt(i, j);
a[x]=Integer.parseInt(o.toString());Please help.
Thank you. :)WalterLaan wrote:
The next line in the exception stacktrace contains a class name and a line number. So go to that class source file and that line number and fix the problem there.Yes, guenouni, we're not mind readers. You need to be clearer and give precise details. The single best way to get the most useful possible help is to take a few minutes and write and post a SSCCE . If you do that, it will show your serious. -
Passing multiple integer values as parameter in SSRS
Hello,
I am trying to pass a comma separated multiple integer value parameter in SSRS report and it errors out complaining that it is not able to convert the nvarchar value to datatype int. But it works fine when I pass a single value. Here is the code I am using
for the report and I am stuck at passing multiple values.
SELECT
id,count(*) as cnt
from table
and ID in (@id) group by id
eg: if I pass 10,20,30 then I would get error however if I pass 10 then it works fine
Is there a different method to pass multiple integer values?
Thanks for your help.A comma is, of course, a textual character and not an integer, thus the error you are getting. Multi-value parameters can be used for this.
Select "Allow multiple values"and set data type to Integer. Multi-value parameters deliver the values as an array. The query interface is smart enough to convert them to the proper syntax (comma-delimited) automatically so a statement like:
WHERE Field IN (@id)
where the parameter has an array of values {1, 2, and 3} is interpreted as:
WHERE Field IN (1,2,3)
You do not need to manually convert it in a transact SQL query. That is not the case for displaying the value array in your report. If you wish to display the array (described above) in your report as "1, 2, 3", you will need to use a join expression:
=Join(@id, ", ")
As DJ described, the other part to a multivalue parameter is the Available values. These can be set explicitly but given your example, I think it would be best to create a new dataset that retrieves a distinct list of the IDs that can be retrieved, perhaps
something like:
SELECT DISTINCT GroupName, GroupID
FROM table
WHERE [criteria]
Set the available values to use this query with GroupName (or whatever user-friendly field you choose for your dataset) as the label and the id as the value. The label field should be something the the target report user can easily identify the correct group
using.
If you don't want to or can't use a multivalue parameter for some reason then you will need to manipulate your parameter value prior to consuming it in your query. When you add the parameter to the TSql query and save the dataset, SSRS adds it to the Parameters
property of the dataset. Open the dataset properties and select the parameters tab. You should see your parameter in the list. click the expression builder (fx) button next to the value and enter this expression:
=Split(@id,",")
Note that the second element of the expression is the delimiter. If your text input has comma-space as a delimiter (1, 2, 3 vs 1,2,3) then that element must include ", ". My example just has comma so if you use that with a string "1, 2, 3"then
the resulting array will still have 3 elements but the 2nd and 3rd elements of the array will have a preceding space which will cause your dataset to error with the same error. As long as there are no non-numeric characters in any of the elements, the split6
will create the text array, SSRS will dynamically generate the correct "IN"syntax (comma separated) and SQL will convert the elements from VARCHAR to INT on the fly.
"You will find a fortune, though it will not be the one you seek." -
Blind Seer, O Brother Where Art Thou
Please Mark posts as answers or helpful so that others may find the fortune they seek. -
Help with passing integer value in A.S.S
I get an NSinternal script error while trying to pass this value can anyone help?
Also I wonder if it is possible to pass the value to a matrix
on clicked theObject
tell button "checkbox" of window 1
if integer value = 1 then
set button "checkbox2" of window 1 to integer value = 1
else
set integer value to 0
end if
end tell
end clicked
I also tried:
if state of button "checkbox" of window1 is 1 then
set the state of button "checkbox2" of window1 to 1
end if
Message was edited by: Doug BassettI've been following this thread and trying to figure out how to make this work. I was getting inconsistent results or errors with most of the code that has been posted. But I finally got it working... at least on a Leopard machine (not sure if this could have changed between Tiger and Leopard so your mileage may vary).
What I found was that a checkbox button that's located directly in a window seems to have a state that's equal to 0 when it's unchecked and 1 when it's checked. But a checkbox cell that's contained within a matrix seems to have a state that's set to either _off state_ or _on state_. Trying to set a cell's state to 0 or 1 simply wasn't working right for me. So I get the state of the "selectall" checkbox button (which is a 0/1) and transform it to either "off state" or "on state" before setting the states of the checkbox cells in the matrix.
Here's my code:
on clicked theObject
set n to name of theObject
if n = "selectall" then
set s to state of theObject
log "state: " & s
if s = 0 then
set newState to off state
else
set newState to on state
end if
repeat with i from 1 to count of cells of matrix "directories" of window "main"
tell cell i of matrix "directories" of window "main"
set state to newState
end tell
end repeat
return
end if
if n = "logStatesBtn" then
logStates()
return
end if
end clicked
on logStates()
log "Logging states:"
set s to state of button "selectall" of window "main"
log "selectall checkbox: " & s
repeat with i from 1 to count of cells of matrix "directories" of window "main"
tell cell i of matrix "directories" of window "main"
set s to state
end tell
log "Cell " & i & ": " & s
end repeat
end logStates
Note the "logStates" handler is just something I connected up to a "logStatesBtn" button in my window that lets me spit out the states of all the checkboxes into the console log. This is how I actually discovered that the cells were set to "off state" or "on state".
Steve -
How to set a default integer value in a form
I have a form defined as follows:
=================================================
public static class ProjectForm extends FormData
private int idx;
private String name;
private String projectNumber;
private String description;
public void setIdx(int index)
this.idx = idx;
public int getIdx(){
return this.idx;
public void setName(String name)
this.name = name;
public String getName()
return this.name;
public void setDescription(String description)
this.description = description;
public String getDescription()
return this.description;
public void setProjectNumber(String projectNumber)
this.projectNumber = projectNumber;
public String getProjectNumber()
return this.projectNumber;
======================================================
When I add a new entry into the database, I have no issues. However, when I want to modify an entry I run into some issues with the idx entry. For some reason, I cannot set a default value into the netui:label tag. My jsp code is as follows:
===================================================
<tr valign="top">
<td>
Index:
</td>
<td>
<netui:label value="{actionForm.idx}"
defaultValue="{pageFlow.project.idx}"/>
</td>
</tr>
<tr valign="top">
<td>
Name:
</td>
<td>
<netui:textBox dataSource="{actionForm.name}"
defaultValue="{pageFlow.project.name}"/>
</td>
</tr>
<tr valign="top">
<td>
ProjectNumber:
</td>
<td>
<netui:textBox dataSource="{actionForm.projectNumber}"
defaultValue="{pageFlow.project.projNum}"/>
</td>
<tr valign="top">
<td>
Description:
</td>
<td>
<netui:textBox dataSource="{actionForm.description}"
defaultValue="{pageFlow.project.description}"/>
</td>
</tr>
======================================================
The the project class is passes into the page and has the appropriate values. The name, project number and description fields work as I would expect. However, the idx value is alway '0'. If I print out pageFlow.project.idx it has the correct value.
How do I fix this? My feeling is that it is related to the form field being an int and not a string. The default parameter indicates that is only works with null values, and ints default to zero. Do I need to use an Integer value instead in the form, or just stay away from non-string form fields.
Thank for the help!!
--JohnIn the action which displays the edit page just set the form idx value before displaying the jsp.
-
Read integer values from spreadsheet and display the values in a table
Hi all,
I have integer values to read from a spreadsheet and display them in a table. I am using 'Read from spreadsheet file' in 'integer' mode. I would like to display these values in a table. The problem is that the table takes only 2d-array of string as input but not integer.
It works fine if I change the mode of 'Read from spreadsheet file' from 'integer' to 'string' but I want to read integers and have to use the integer values for further calculations. Please give any suggestions on displaying integers to a table.
Thank you.
Solved!
Go to Solution.No don't take element by element just convert as a whole. See the attached example
Good luck
The best solution is the one you find it by yourself -
Hi
My company just started a new project that implies migrating every hour operational data from a mysql database located at another company to our main DB (oracle10gR2). Between these two DB, we have an oracle XE DB which contains the database links to both DB and a procedure to get (from mysql) and insert (oracle10g) the values. What happens is that in the mysql DB, the values have decimals and, when i select the table in oracle, i only see integer values (no decimals). Here is an example of the select i use:
SELECT "v_hour", "v_date", "v_type", "v_tabstamp","v_value"
FROM "tab1"@mysql;
How can i work around this problem?
Many thanks!Maybe just a HS_LANGUAGE setting issue.
You could try that:
1a) in the gateway init file, please set HS_LANGUAGE=GERMAN_GERMANY.WE8ISO8859P1
2a) now open a new SQL*Plus session ans select from your table using the gateway based database link
=> if the values are now including the decimal part then your foreign database is set up to use a comma as the decimal separator and you have to make sure that the HS_LANGUAGE contains a territory that uses as decimal separator a comma.
If you still do not get the decimal values, then change it to:
1b) HS_LANGUAGE=american_america.we8iso8859P1
2b) Make sure you start again a new SQL*Plus session (the gateway init file is only read when you use the database link in your session for the first time (or explicit closed it before). Select again from your table.
=> is the decimal part now visible?
More details can be found in the gateway note: Gateway and Decimal Digits(Doc ID 1453148.1) available from My Oracle Support portal.
- Klaus -
Concatenate text to field value in report header
I'm trying to concatenate text to field value in a textbox in the report header but am getting an error. Here's how I'm doing it:
=First(Fields!Pp_Name.Value, "dsProspect") & "Prospect"
and the error says the report definition is invalid. An unexpected error occurred while compiling expressions. Native compiler return value '[BC30179] class 'Textbox.....
any idea why this wont compile?
Thank you.Hi moondaddy,
Generally, the error message always occurred when there are two distinct text boxes with the same name that only differ in their name by casing in report. When Reporting Services generates VB code for these textboxes during report publishing, the compilation
fails because VB class names are considered case-insensitive.
So this issue is not related to the expression (the format is correct) you post, it related to the Textbox name that the error message said. In order to fix this issue, please rename one of the textboxes.
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
If you have any feedback on our support, please click here.
Katherine Xiong
TechNet Community Support -
Convert an integer value that was created with the Excel DATEVALUE formula to a valid date?
Hello everyone,
How can I convert an integer value that was created with the Excel DATEVALUE formula to a valid date in SSIS?
Is this even possible?
For example:
=DATEVALUE("8/22/2008") will format the cell to display 39682.
Reading the column as a string to get the int value (39682) - how can I turn this into a valid date using SSIS and then importing the real date to sql server?
Thank you!You can use Script component for this and convert your integer values to Date. An example here is following:
CultureInfo provider = CultureInfo.InvariantCulture;
string dateString = "08082010";
string format = "MMddyyyy";
DateTime result = DateTime.ParseExact(dateString, format, provider);
Source: http://stackoverflow.com/questions/2441405/converting-8-digit-number-to-datetime-type
Vikash Kumar Singh || www.singhvikash.in -
Change integer value to string?
Hi all,
I was wondering if it is possible to change an integer value to a string. I saw in this forum that a string can be changed to an integer using parseInt and I was wondering if there is a similar method for going the other way.
Regards.try this
Integer.toString(intvalue);
where intvalue is an int like 5.
hope this helps.
Takis -
How to display integer values and decimal values in same column in a table
hi
in my report amount column is there in that column integer values (2234) and decimal values (3562.34)
i want to print this values as 1000 separate as like 2,234 as integer and 3,562.34 as decimal
but this values print like 2,234.00 as integer and 3,562.34 as decimalHi akilreddy,
Per my understanding you have an field which data type may be "float" in the DB, so it have value which format like "2234" and "3562.34" in the same column, now you want to format them differently in the report, right?
I have tested on my local environement and you can use the expression in the custom format in the Textbox properties to do this:
Right click the field which you want to add the format and select the "Text Box Properties"
Select the "Number" on the left pane and using expression below in the Custom format:
=IIF(Split(Fields!yourfieldname.Value,".").Length=2,"#,###.##",Nothing)
Or you can just use "#,###.##" in the format.
Preview you will go the result like below:
If you still have any problem, please feel free to ask.
Regards
Vicky Liu
Vicky Liu
TechNet Community Support -
Putting integer value of 163 into byte array
I have an integer value of 163. I need to put that into a byte array. When i do, it puts it as -93. Whats wrong? and how can i put it in correctly?
Hi,
You cannot store 163 in a byte variable. In Java a byte variable will have only 8 bits and its value range will be from -128 to +127. In a byte variable you cannot store a value which is out of this range. If you try to cast an integer value which is out of this range to byte then you will get unexpected results (But you can find what the result will be). -
Wanna send integer value by reference in function
I wanna send integer value by reference thro' function. Here's the code going.
class test
basic b = new basic();
test()
test2.Fuction(b.value);
class basic
int value;
basic(){}
//////here i want value to be affected by Function.I don't want it affected by value, but by reference.
class test2
public static void Function(int value)
value++;If you want to update the value in your b object, then you have to pass the reference of that object to test2.Function(..). Here is one way to do it:
class test {
basic b = new basic();
test() {
test2.Function(b);
class test2 {
public static void Function(basic b) {
b.value++;
}It's a good idea to follow the java naming convention. Classes should begin with an upper case letter. Methods and variable names with a lover case letter (but final static variables with all upper case letters). -
You could use DecimalData with scale 0.
Alexis Hassler
OOsphere France
(33) 4 37 49 01 28
-----Message d'origine-----
De: Kasrul Islam [SMTP:kasrul.islamchordiant.com]
Date: vendredi 3 mars 2000 21:04
A: kamranaminyahoo.com
Objet: (forte-users) Large integer values
Hi,
Can anyone out there help with a little problem, I have string of numbers
that I have extracted out of a file, the numbers are all over 10 digits
when I try to convert this string into a Integer the number gets changed to
something weird for example.
Txt : TextData = new(Value = '12345');
mInt : IntegerData = new(Value = Txt.IntegerValue);
this works fine but when I try a number like this :
Txt : TextData = new(Value = '951475978067');
mInt : IntegerData = new(Value = Txt.IntegerValue);
then I get the following value in my integerdata object : 2147483647 any
help will be appreciated, I really need to get the above value as an
integer because I need to do some calculations with it.
Thanks in advance.
Kasrul Islam.
<< Fichier: ATT00000.html>> -
Toplink seems to be inconsistent with SQL aggregate functions when running a report query on an integer field.
My code is similar to this:
// Toplink version 9.0.4.2
ReportQuery report = new ReportQuery(Person.class);
ExpressionBuilder builder =
report.getExpressionBuilder();
report.addAverage("id-ave",builder.get("id"));
report.addMinimum("id-min",builder.get("id"));
report.addMaximum("id-max",builder.get("id"));
report.addStandardDeviation("id-std",builder.get("id"));
report.addSum("id-sum",builder.get("id"));
report.addVariance("id-var",builder.get("id"));
results = session.executeQuery(toplinkQuery);
After running a report, Toplink returns all of the requested values as java.lang.Integer types.
This is not a problem for sum, min, and max, because these values should always be integers. But for average, variance, and standard deviation, floating point values are a likely result. The Toplink returned integer values are rounded down to the nearest whole number.
Running the equivalent SQL on Oracle 9i returns floating point results. The SQL is something like
SELECT AVG(ID), MIN(ID), MAX(ID), STDDEV(ID), SUM(ID), VARIANCE(ID) FROM PERSON
Is this the defined behavoir of Toplink, or is it a bug? I haven't tried the SQL on different database vendors. Maybe the SQL executes differently for other vendors and Toplink chose integer values so that results would be consistent. But I have not seen any documentation indicating so.
-JYes this is an issue with ReportQuery, currently it tries to convert the values to their attribute type, but should not be doing so for these functions.
I have logged this problem internally, but if you need a solution to the problem, please contact Oracle support.
Workarounds would be:
- In you DatabaseLogin turn off data-optimization, i.e. login.dontUseDataOptimization();
- Use custom SQL with the report query, or a DataReadQuery. -
Integer values and decimal values in weblient UI - Display mode
Hello,
i have developed an custom assignmentblock with some custom fields.
Some of this fields are integer values and text values.
Some other fields are decimal values.
I face the issue that this decimal values are in display mode right-aligned all other fields are left-aligned.
In edit mode all values are right-alligned.
How can i change this behaviour? All values left-alligned in display mode!
Otherwise this looks strange.
Thank you
Kind regards
ManfredHi,
Decimal values will be displayed right-aligned. To change that you need to modify the GET_M method.
In get_m method, you have to change the attr datatype to string.
Data: attr type string.
Data: dref type ref to data.
Get reference of attr into dref.
Regards,
Arun
Edited by: Arun Kumar on May 14, 2010 3:03 PM
Maybe you are looking for
-
Exporting large report to Excel format (90K lines)
Hi, I am trying to export a 90K line report to excel format and I get that error messsage: Description : Une erreur d'application s'est produite sur le serveur. Les paramètres d'erreur personnalisés actuels pour cette application empêchent l'affichag
-
Java error message when trying to use browser locks phone
I have a Bold 9650 and when I go to the internet, I get an error message that says, "Uncaughtexception:java.lang.illegalArgumentException" It won't go away from the screen when I click on OK. I can say OK over and over until about 15-30 minutes later
-
Html will not display in safari
hey folks, i have to create a webpage for a class. i used textedit to type up the code (and made sure it was in plain text). the page loads just fine in camino and firefox, however safari (and internet explorer) just display a blank white page (but i
-
Requirements are not fulfilled for condition PI01
Dear SD guru, When i create sales order,it prompt that 'Requirements are not fulfilled for condition PI01'. For the specifical requirement,i use the intercompany processing.I want two invoices in this sale document,onr for customer,
-
Share variable value between java script and jsp
Hi, Firends: In my old web page I used a static array to hold a set of values, and now I want to use dynamic value from datbase. I created a bean to process database data and return resultset value to an array string. I convert my html page into jsp