Jump to content
We've recently updated our Privacy Statement, available here ×

Fetching the N-th row from the query.


hekuran23

Recommended Posts

Wanted to ask if it's possible in Jasper Reporting to do the following:

 

 

Query Result:

 

ID      Name

------- ------------

1001    NICK

1010    BOB

1022    TOM


 

I have text in REPORT that needs to fetch all the names,

 

The creditor, Nick with id 1001, bla bla bla bla, and the Guarantor BOB with id 1010 Bla bla bla bla, and guy who vouches TOM with ID 1022, bla bla lba.

 

Is it possible to fetch the second of third row of query in Variable.

 

I tried like this but NO LUCK. I put this on Variable Expression: 

($F{ID} == 1001) ? $F{NAME} : ""

 

Thank you very much in advance, appreciate your time.

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Shouldn't you be doing this in your SQL statement? Getting Nick's id and Nick's Guarantor and the guy who vouches in one sql statement?

If the rows you're fetching is always 3 and in that particular order, just create variables. Remember, variables are evaluated in order they appear in the outline view.

Link to comment
Share on other sites

Hozawa, Thank you very much for your effort.

 

Actually I'm new in Jasper Report, and don't have much knowledge. I could concatenate whole statement in one line, but I do not know how to fetch the second line and put in the report, I tried to do this "$F{ID} == 1001" in variables, but it's only TRUE when you put the ID of First row, and gives the name, but once you put a variable with id 1010, it does not fetch the name but only returns NULL.

 

Could you help me solve this.

 

Thank you.

 

Link to comment
Share on other sites

For just 2 rows, create 2 variables $V{Customer} and $V{Guarantor} in this order in Outline view.

Set $V{Customer} = $V{Guarantor}

$V{Guarantor} = $F{Name}

JasperReports evaluates variables top down according to Outline view so $V{Customer} will be set to what $V{Guarnator} was before it's updated with $F{Name}

Link to comment
Share on other sites

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