fequepe Posted February 11, 2016 Posted February 11, 2016 Hi Community,First of all I would like to thank in advance for the time you waste helping me.I would like to parse data of 1 field received via SQL query in different fields in a JASPER report.Possible results of the SQL Query stored in the field INS_AUTH:FLAG: NLD AUTHORITY: SFTRESTRE INSPCTR_IDENT: John CampbellFLAG: ESP AUTHORITY: NAVY INSPCTR_IDENT: ESP1254 FLAG: ESP AUTHORITY: NAVY INSPCTR_IDENT: ESP1997 What I want to do:|FLAG_1|AUTHORITY_1|INSPCTR_IDENT_1|FLAG_2|AUTHORITY_2|INSPCTR_IDENT_2||NLD|SFTRESTRE|John Campbell|NULL|NULL|NULL||ESP|NAVY|ESP1254|ESP|NAVY|ESP1997|If I want to display all the content of the SQL field I use the following function with success:$F{_THIS}.get( "INS_AUTH" ) The problem is which functions I should use to create the additionals 6 fields in Jasper:INS_AUTH -> $F{_THIS}.get( "INS_AUTH" )FLAG_1 ->AUTHORITY_1 ->INSPCTR_IDENT_1 ->FLAG_2 ->AUTHORITY_2->INSPCTR_IDENT_2 ->
fequepe Posted February 11, 2016 Author Posted February 11, 2016 I have this situation more or less solved using the following code:$F{_THIS}.get( "INS_AUTH" ).toString().split(" [A-Z_]+: ")[1]$F{_THIS}.get( "INS_AUTH" ).toString().split(" [A-Z_]+: ")[2]$F{_THIS}.get( "INS_AUTH" ).toString().split(" [A-Z_]+: ")[3]$F{_THIS}.get( "INS_AUTH" ).toString().split(" [A-Z_]+: ")[4]$F{_THIS}.get( "INS_AUTH" ).toString().split(" [A-Z_]+: ")[5] The problem now is that in some cases the fields [3],[4] and [5] don't exist and the systems doesn't displays the result :($F{_THIS}.get( "INS_AUTH" ).toString().split(" [A-Z_]+: ")[6]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now