PDA

View Full Version : dynamic queries?



tchao
10-09-2003, 11:24 AM
hi.
i'm trying to use a request.getParameter variable
in the where clause of my query.
is that possible?
i want to dynamically choose how to slice the cube
here's my attempt which doesnt work
<%
String brandid = request.getParameter("brandid");
%>
<jp:mondrianQuery id="query01" jdbcDriver="oracle.jdbc.driver.OracleDriver" jdbcUrl="jdbc:oracle:oci8:salesdemo_test3/password@b2ixdb" catalogUri="/WEB-INF/queries/Dashboard.xml">
select
{[Measures].[Stories], [Measures].[Mentions] } on columns,
{[MediaSegments].[All Sources] } ON rows
from [Sources] where [Brand].[1].[<%=brandid%>]
</jp:mondrianQuery>

sgwood
10-09-2003, 05:13 PM
Again, this is a JPivot question.
Create a tag that takes query01 and your brandid as parameters. Take TableComponentTag as a guide.
Create your own Component, created by yourTag.createComponent. see TableComponent
Your Component constructor needs to do something like:
myMemberTree = (MemberTree) this.olapModel.getExtension(MemberTree.ID);
myChangeSlicer = (ChangeSlicer) this.olapModel.getExtension(ChangeSlicer.ID);
Find the Member related to your brandId.
Then set the Slicer, like:
Member[] slicerMembers = new Member[1];
slicerMembers[0] = brandIdMember;
myChangeSlicer.setSlicer(slicerMembers);

avix
10-10-2003, 10:53 AM
One possibility, as Sherman suggested, is to create a custom tag that modifies the Query via API.
Another would be to modify the query string as you tried. There are 3 issues (at least):
1. make sure that the <jp:mondrian ../> tag is executed only if the "brandid" parameter is present because otherwise navigation would be impossible (see your other mail). This might be something like (please check)
<c:if test="param:brandid">
<jp:mondrian.../>
</c:if>
2. in WEB-INF/jpivot/jpivot-tags.tld change the
<body-content>tagdependent</body-content>
to
<body-content>JSP</body-content>
3. Let me know me if this works :-)
Regards,
Andreas