Jump to content
Changes to the Jaspersoft community edition download ×

Using case statement and sequence value


ehssame

Recommended Posts

Hello

 

I am using iReports 1.3.0 with JasperReports 1.3.0

 

1. I have a SQL statement for getting report values and inside the SQL statement I have a scenario like this

 

select a,b,c,CASE WHEN d="Y" e * 2

WHEN d="N" e * 4

ELSE -1

END, f,g from

someTable

where ......someConditions

 

I can run the SQL in iReports and it gives the Output OK

but when I run the same from the java code it errors out giving the exception

"net.sf.jasperreports.engine.JRException: Unknown column name : CASEWHEND=YTHENE*2WHEND=NTHENEE*4ELSE-1END

at net.sf.jasperreports.engine.JRResultSetDataSource.getColumnIndex(JRResultSetDataSource.java:357)

at net.sf.jasperreports.engine.JRResultSetDataSource.getFieldValue(JRResultSetDataSource.java:113)

at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:727)

at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:983)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:126)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:750)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:647)

at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:363)"

 

Any reasons why this could be happening ?

Any alternate ways to do it so that it runs OK from the Java code

 

2. In the same report I want to show a sequence number , now this sequence number has to be taken from the Db ...how can I embed the 2nd SQL (or is there any other way to do it ) so that I can get the sequence number ?

 

3. I am using the CSV output and I have noticed that whenever I put in static text in quotes for eg:- "ABC" the output comes out with an extra pair of quotes ""ABC"" . Any thoughts why ?

 

Thanks in advance

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

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...