Jump to content

sorting problem


ktrinad

Recommended Posts

By: vivek srinivasan - viveksrinivasan

sorting problem

2003-10-17 10:38

Hi,

i have a report which has emp# stored as a string in the database.When i sort the emp# in the ascending order i get the values like 15,154,157,16,161,168,19,191,192 etc.....

I would like to sort it like

15,16,19,154,157......

How do i do this. I reports is not allowing me to convert a string variable into integer.The way i am tried converting it is Integer.parseInt($F{empno})

Please help..

Thx,

Vivek

 

 

 

 

By: Mark Rhodes - mrhodes2

RE: sorting problem

2003-10-17 10:49

you must sort the records in your query

 

... order by convert(int,emp#)

 

 

 

 

By: weckamc - weckamc

RE: sorting problem

2004-11-26 00:12

I have the same problem as viveksrinivasan.

But when I try to add the convert function to my query the following error occurs:

 

Invalid data type for conversion function.

 

But my field is also a String...

 

 

 

 

By: Kat - travel_kat

RE: sorting problem

2004-11-28 20:04

Have you tried converting the string to a non object type before doing anything with it?

 

ie:

Integer.parseInt(String.valueOf($F{empno}))

 

 

 

 

By: weckamc - weckamc

RE: sorting problem

2004-11-29 00:19

How can I convert the string before the query?

 

 

 

 

By: Andrew McLaughlin - pik0

RE: sorting problem

2004-11-29 09:12

Since the employee number is string and since you are sorting at the database level, it sorts the data as left-justified. You should have made the empno field numeric. Depending on what variant of SQL you are using, you may be able to substitute an expression in place of the column reference that would allow you to right justify the data or perhaps convert to integer.

 

Good luck,

Piko

 

 

 

 

By: weckamc - weckamc

RE: sorting problem

2005-01-04 02:58

Because of special circumstances it is not possible for me to get the fields as integer.

 

Is there a possibility to sort the data after retrieving it (e.g. with a scriptlet)???

 

 

 

 

By: subsphoto - sunsphoto

RE: sorting problem

2005-01-07 03:15

Dear all,

 

Can the sorting be done on the ireport(Not the database)?

 

Thank you for your time and effort!

 

 

 

 

 

By: weckamc - weckamc

RE: sorting problem

2005-01-11 02:43

Yeah, sorting in ireport would also solve my problem...is there any way to reach this (eg with snippets)???

 

 

 

 

By: Mike Warne - mwarne

RE: sorting problem

2005-01-11 12:17

If you can't tell your database to sort it properly, You will have to create a work-around. You could possibly write a custom datasource class that implements JRDatasource. The datasource could read all the records you wish to select from JDBC, and then you could sort the employee number using Java code, and store the sorted records in a list. The datasource would then provide the records in sorted order to JasperReports. -- Check the JasperReports web site for details on custom datasources.

 

If you do decide to do this, and you have large dataset to retrieve -- you may run into memory problems.

 

However, I would first check the database to see if you can change the way it sourts your character string data.

 

Mike.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...