chetan_33 Posted August 7, 2006 Share Posted August 7, 2006 I am using iReport 1.2.5, jasper set to 1.2.0,SQL Serverand have successfully used a parameter as part of the where clause I wanted to conditionally include columns in order by clause (obviously the ones which are selected) but it fails with expressions.So I tried to simply substitute by a parameter with default values provided by iReport but it gives exception as follows java.sql.SQLException:ÂTheÂSELECTÂitemÂidentifiedÂbyÂtheÂORDERÂBYÂnumberÂ5ÂcontainsÂaÂvariableÂasÂpartÂofÂtheÂexpressionÂidentifyingÂaÂcolumnÂposition.ÂVariablesÂareÂonlyÂallowedÂwhenÂorderingÂbyÂanÂexpressionÂreferencingÂaÂcolumnÂname. ÂÂÂÂatÂnet.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365) ÂÂÂÂatÂnet.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781) ÂÂÂÂatÂnet.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224) ÂÂÂÂatÂnet.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:628) I have following in my query .......ORDER BY Name1,VKORG,Name1, PHier2, $P{PARAM_SORT_CLAUSE},JAHR, MONAT parameter has value of "PHier3 , MATNR There are 3 more parameter substitutions in whereby clause with which report worked fine till this new parameter is introduced.So cant understand what is 5 in exception. Is there any restriction on parameterising in order by clause and other parts of sql? I am trying to add capability to control sorting on a specific column and the sortorder as assc/desc Appreciate inputs Link to comment Share on other sites More sharing options...
Teodor Danciu Posted August 7, 2006 Share Posted August 7, 2006 Hi, Use the $P!{} syntax.The /demo/samples/query sample provided with the project shows how to use a parameter in the ORDER BY clause. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
chetan_33 Posted August 8, 2006 Author Share Posted August 8, 2006 Thanks that worked. But its surprising that $P{} works in where clause or part before order by and so i never looked in such a detail in sample What is the secret behind '!'. Are there any such usage specifics at other places as well I will now go ahead by replacing it with variable defintion which is more manageable So will it also require $V{}?. Link to comment Share on other sites More sharing options...
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