• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using JSTL SQL Tag

 
C Shinde
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am using the JSTL SQL Tag, I am interested in passing a param to this query which is got from another query run earlier, is there any restriction on the type of the parameter that I can pass to the query?

For ex:

<sql:query var="bookrs" dataSource="jdbc/SampleDB">
select * from app.book where book_id = ?
<sql:param value="${catrow.BOOK_ID}" />
</sql:query>

catrow.BOOK_ID - param got from running another query earlier on.
Here BOOK_ID is an integer the JSP, catrow.BOOK_ID, object is existing in the outer loop so it is valid. Though in the editor this param value is highlighted in yellow saying this is an invalid attribute, dont know why?
Basically this does not work.
Any help appreciated.

Chetan
 
C Shinde
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok to add to this, I have seen people normally use the sql:param with the parameters that they pass across pages. What I was doing is getting some data from the backend in 1 query and then using that as an input to another query. Now there could be people questioning me as to why I would do this, will this 2 data sets was like master details kind of data and and yes everyone visiting the page will see all the master he will not see all the detail, so only the master he selects will he see its detail.

Chetan
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless you're doing some really, *really* preliminary prototyping, the sql tags shouldn't be used at *all*.

Without knowing anything about the parameter it's impossible to help--if it's accessible via JSTL (can you display it?) it should be usable as a parameter... though to be honest, I've never, ever used the sql tags.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!