mathiasen_jakob Posted November 4, 2009 Share Posted November 4, 2009 Hello, Please tell me how to pass a parameter to an sql-sentence like this:select * from t_Table where ID in $P{parameter1}ThanksJakob Link to comment Share on other sites More sharing options...
deloreanguy Posted November 4, 2009 Share Posted November 4, 2009 The IN operator requires a parenthetical notation, such as WHERE D IN (A, B, C)...I haven't tried using parms with an IN clause, but put parends around it first... Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted November 5, 2009 Share Posted November 5, 2009 the syntax is: select ... where $X{IN, colname, paramname}paramname is a parameter of type Collection or array. If null or empty, the condition is replaced by 0=0.Giulio Link to comment Share on other sites More sharing options...
tdi120 Posted November 5, 2009 Share Posted November 5, 2009 If you are not using a collection or list, like Giulio suggested, then the syntax would be: select col1,col2 from table1 where col1 IN ( $P!(parameter1) )Notice the spaces, notice the "!"The "!" mark, tells that the value should be passed raw into the sql queryThat only works with strings, because you cannot pass a list of integers, properly formatted for the query.So unless you are manually introducing the parameters as: 1,2,56,78,99you will have to use a collection, which takes me to the answer Giulio already provided.Hope that helps Alexandru Ersenie Link to comment Share on other sites More sharing options...
mathiasen_jakob Posted November 5, 2009 Author Share Posted November 5, 2009 Thanks a lot.. Just what I needed !! 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