Question

How to query based on a parameter?

Asked by: williampeck

I have a .jsp pages that returns an Oracle query, works great.

I want the page to load by querying everything, then the user clicks a button and this filters the query.

So I need a variable, sourcesToQuery, on startup will be ('PRD','CLI','MEM',CLM',PCLM',PRV')

so the query will say

where subject_area in <%= sourcesToQuery%>

When they click the Claims button, then
sourcesToQuery = ('CLM','PCLM')

so something like

onLoad: set sourcesToQuery =  ('PRD','CLI','MEM',CLM',PCLM',PRV')

then when they click on the Claims button, it filters by sourcesToQuery in ('CLM','PCLM')

I know what I want to do but no idea how to do it. I am looking at other .jsp files that use parameters but can't get it working.

Below is the entire page, it works great if I don't try to filter

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
 
<sql:query var="load_status" dataSource="jdbc/EDW">
  select case s1.subj_area_cd
             when 'PRD' then 'a' when 'CLI' then 'b' when 'MEM' then case s1.srce_sys_cd when '141' then 'j' else'c' end when 'IDM' then 'd' 
	     when 'CLM' then 'e' when 'PCLM' then case s1.srce_sys_cd when '140' then 'j' else 'f' end when 'PRV' then 'g' else 'i' end   
       	      ||'-'||lower(substr(s1.srce_sys_nm,1,2)) as Logical_Sort
  ,s1.subj_area_cd as Subj, s1.srce_sys_nm ||' - '||s1.srce_sys_cd as Source_Nm,  initcap(s1.freq) as Freq
        ,case s1.last_step_run_nm 
                          when 'init'                        then 'Ready'
                          when 'transfer'                    then 'Loading'
                          when 'cleaned'                     then 'Loading'
                          when 'cleaned failed'              then 'Load failed - data errors'
                          when 'stage2'                      then 'Loaded (to Stage 2)'
                          when 'stage2 failed'               then 'Load failed (to Stage 2)'
                          when 'stage2 approved'             then 'Load Approved (from Stage 2)'
                          when 'stage3i'                     then 'Loaded (to Stage 3i)'
                          when 'stage3i failed'              then 'Load failed (to Stage 3i)'
                          when 'stage3i approved'            then 'Load Approved (from Stage 3i)'
                          when 'ods'                         then 'Loading'
                          when 'ods failed'                  then 'Load failed'
                          when 'ods unlinked'                then 'ODS loadedthen'
                          when 'ods approved'                then 'Load Approved'
                          when 'ods mailed'                  then 'ODS mailed'
                          when 'ods failed mailed'           then 'ODS failed'
                          when 'intgn failed'                then 'Integration(s) failed'
                          when 'intgn'   		     then 'Integrations running'
                          when 'intgn approved'		     then 'Integrations approved'
                          when 'intgn mailed'   	     then 'Integrations mailed'
                          when 'intgn failed mailed'   	     then 'Integrations failed' 
                          when 'intgn ready'   		     then 'ODS approved'
                          when 'intgn running'		     then 'Integrations running'
                          when 'cdr'   			     then 'Loading to CDR'
                          when 'cdr failed'   		     then 'CDR load failed'
                          when 'cdr approved'   	     then 'CDR approved'
                          when 'cdr mailed'   		     then 'CDR loaded'
                          when 'cdr failed mailed'	     then 'CDR load failed'
                          when 'cdr analysis'   	     then 'Analysis running'
                          when 'cdr analysis failed'   	     then 'Analysis failed'
                          when 'cdr analysis completed'	     then 'Ready for reporting'
                          else s1.ods_last_step_run_nm                   
                          end as CDR_Step
  ,' ' /* replace(to_char(to_date(ops$imedw.loader_stats(s1.srce_sys_cd,'ODS_CDR_LOAD_DATE',s1.mth_last_load_dt,s1.subj_area_cd, ''),'yyyymmdd'),'Mon dd'),' 0',' ') ||
  ops$imedw.loader_stats(s1.srce_sys_cd,'ODS_CDR_LOAD_HOURS',s1.mth_last_load_dt,s1.subj_area_cd, '') */ as CDR_Dt_Hrs
  ,s1.cdr_rpt_mth as CDR_Month
    ,nvl(replace(to_char(s1.mth_last_load_dt,'Mon dd'),' 0',' '),'n/a') as Exp_Last_Load
  ,decode(ops$imedw.loader_stats(s1.srce_sys_cd,'ODS_LOAD',trunc(s1.mth_last_load_dt),s1.subj_area_cd, ''),'Green','Yes','&nbspNo ') as Received
  ,ops$imedw.loader_stats(s1.srce_sys_cd,'ODS_LOAD',trunc(s1.mth_last_load_dt),s1.subj_area_cd,'') as ReceivedColor
  ,ops$imedw.loader_stats(s1.srce_sys_cd,'INTEGRATION',sysdate,s1.subj_area_cd, s1.cdr_rpt_mth) as Intgn_Status
  ,ops$imedw.loader_stats(s1.srce_sys_cd,'CDR APPROVAL',sysdate,s1.subj_area_cd, s1.cdr_rpt_mth) as CDR_Approved
  ,ops$imedw.loader_stats(s1.srce_sys_cd,'ANALYZE',sysdate,s1.subj_area_cd, s1.cdr_rpt_mth) as CDR_Analyzed
  ,case s1.srce_sys_cd
	when '035' then '<a href="http://xpc-114400/edw/ods_reports.jsp?SUBJ=CLM&SRCE=035&CYCLE=200901">ODS Totals - Old</a>'
	else ops$imedw.loader_stats(s1.srce_sys_cd,'ODS APPROVAL',s1.mth_last_load_dt,s1.subj_area_cd,s1.cdr_rpt_mth)
   end||case s1.srce_sys_cd
           when '035' then '<br/><a href="http://xpc-114400/bill/ods_totals.jsp">Please Approve - New</a>'
           else ' ' 
        end as ODS_Approval
  ,s1.subj_area_cd as Subj_Cd, s1.srce_sys_cd as Source_Cd
from ods.subj_area_srce_load_stus s1 
where s1.stus_nm = 'active' 
 and  s1.subj_area_cd in <%= sourcesToQuery %>
order by 1
</sql:query>
 
<c:set var="Srce" value="" scope="session"  />
<c:set var="Subj" value="" scope="session"  />
<c:set var="Month" value="" scope="session"  />
<c:set var="sourcesToQuery" value = "('PRD','CLI','MEM','IDM','CLM','PCLM','PRV')" scope="session" />
 
 
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
 
	<title>EDW: CDR Load Status</title>
	
	<link rel="stylesheet" href="jquery/tablesorter/themes/blue/style.css" type="text/css" id="" media="print, projection, screen" />
 
	<script type="text/javascript" src="jquery/tablesorter/jquery-latest.js"></script> 
	<script type="text/javascript" src="jquery/tablesorter/jquery.tablesorter.js"></script> 
	
	<script type="text/javascript" id="js">
	$(document).ready(function() 
    		{         
		$("#statusEDW").tablesorter();     
    		} 
	); 
	</script>
 
    <script type="text/javascript">
        function underConstMsg() {
          message = "Under Construction . . .";
        alert(message);
      }
    </script>
 
    <script type="text/javascript">
        function clmPclmFilter() {
          sourcesToQuery = "('CLM','PCLM')";
	  message ("Claim / P-Claim filter under construction . . .");
      }
    </script>
 
 
 
	<script type="text/javascript">
	function setODS_ApprovalColor(userStatus) {
	    switch (userStatus) {
 
              case "Under Review":
                 document.getElementById("ODS_Approval").className = "Yellow";
 
              case "Not Loaded":
                 document.getElementById("ODS_Approval").className = "Normal";
 
              default:
                 document.getElementById("ODS_Approval").className = "Normal";
	    }
	}	
	</script>
 
</head>
<body>
<c:set var="sourcesToQuery" value = "('PRD','CLI','MEM','IDM','CLM','PCLM','PRV')" scope="session" />
 
<h1>EDW: CDR Load Status<br/>January 2009</h1>
    <form id="EDW_submit" action="http://xpc-114400/bill/cdr_status.jsp">
      <table>
          <tr>
	    <th></th>
            <td>
              <input type="submit" value="All" onclick="underConstMsg()"/>
	      <input type="submit" value="Client / Product" onclick="underConstMsg()" />
	      <input type="submit" value="Member / X-Walk IDM" onclick="underConstMsg()" />
	      <input type="submit" value="Claim / P-Claim" onclick="clmPclmFilter()" />
	      <input type="submit" value="Provider" onclick="underConstMsg()" />
	      <a href="ods_status.jsp" alt="ODS Status">(Link to ODS Status)</a>
            </td>
          </tr>
        </table>
      </form>
 
<table class="tablesorter" id="statusEDW" align="center" cellpadding="5">
 
<thead>
<tr>
	<th>Logical<br/>Sort</th>
	<th>Subject<br/> Area</th>
	<th>Source</th>
	<th>Freq.</th>
	<th>Expected <br/> Last File</th>
	<th>Last File<br/>Received?</th>
	<th>ODS Approval</th>
	<th>Intgn Status</th>
	<th>CDR Step</th>
	<th>CDR Approval</th>
	<th>CDR Analyzed</th>
</tr>
</thead>
 
 
<tbody>
<c:forEach var="ls" items="${load_status.rows}">
  <c:set var="Srce" value="${ls.Source_Cd}"  scope="session"  />
  <c:set var="Subj" value="${ls.Subj_Cd}" scope="session"  />
  <c:set var="Month" value="${ls.CDR_MTH}"      scope="session"  />
 
  <c:set var="LSubj" value="${stg.lower_subj}"  scope="session"  />
  <c:set var="Cyc"  value="${stg.load_cyc}"     scope="session"  />
  <c:set var="Stg"  value="${stg.load_stg}"     scope="session"  />
  <c:set var="DCyc"  value="${stg.disp_cyc}"    scope="session"  />
<tr>
	<td>${ls.Logical_Sort}</td>
	<td>${ls.Subj}</td>
	<td>${ls.Source_Nm}</td>
	<td>${ls.Freq}</td>
	<td>${ls.Exp_Last_Load}</td>
	<td><span class="${ls.ReceivedColor}"> ${ls.Received}</span></td>
	<td id="ODS_Approval"><span class="Normal"> ${ls.ODS_Approval}</span></td>
	<td>${ls.Intgn_Status}</td>
	<td>${ls.CDR_Step}</td>
	<td>${ls.CDR_Approved}</td>
	<td>${ls.CDR_Analyzed}</td>
</tr>
</c:forEach>
 
</tbody>
</table>
 
</body>
</html>

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-02-10 at 18:35:02ID24131992
Tags

jsp

,

HTML

,

javascript

Topics

JavaScript

,

Extensible HTML (XHTML)

,

Hypertext Markup Language (HTML)

Participating Experts
1
Points
0
Comments
3

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. OnLoad
    Whats the syntax for the OnLoad handler. I want to load a page into another target frame, and pass it a query string. Also how do you do this with framesets
  2. Oracle Reports -  Parameters
    Hi, How Can I pass a value to from Oracle Forms to ORacle Reports, and how to suppress the parameter form? Please help me !
  3. Why oracle.exe using so much "Mem Usage" and "VM …
    I have been noticing this recently in my computer: Eventhough I'm not running any application or program related to ORACLE, oracle.exe gives me high number of memory and virtual memory size. The last time I checked the task manager right after I restarted my computer: The &q...
  4. checklist box onload keep checkboxs checked
    onload keeping all the checkboxlist checked

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: fsze88Posted on 2009-02-10 at 20:15:13ID: 23608188

I don't know what exactly you means, but js getURLParam function may help you
it can read URL and parameters from current URL.....

<script language="javascript">
function getURLParam(strParamName){
  var aParam;
  var strReturn = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")+1);
    var aQueryString = strQueryString.split("&");
    for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
      aParam = aQueryString[iParam].split("=");
      if (aParam[0] == strParamName){
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
} 
 
//alert(window.location.href);
//alert(getURLParam('zip'));
</script>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:

Select allOpen in new window

 

by: williampeckPosted on 2009-02-11 at 04:23:01ID: 23610573

In this case, I'm not getting the parameters from the URL (but perhaps I have to do it that way).

a. I want to startup my page (query) by using this variable:
          where subj_area_cd = sourcesToQuery

          and sourcesToQuery = ('PRD','CLI','CLM','MEM','PCLM') which is set in onLoad (or something like that)

   so - how do I set the variable sourcesToQuery on startup ? The user comes in with just the URL (no params)

         - then if they click the "Claim" button, I set sourcesToQuery = ('CLM','PCLM') and re-query the page.

Since I am totally new to this, maybe I'm off track.

Based on what you are saying, and strictly using parameters, the starting URL should be

http://www.myWebPage.org?SOURCES=('PRD',CLI',MEM','CLM',PCLM'), so I'd have to grab the parm and use it in my where clause

then when they click the Claim button, the URL says ?SOURCES=('CLM','PCLM')

It makes sense to me that after clicking the claims button the URL looks like this: http://www.myWebPage.org?SOURCES=('CLM',PCLM')

but it seems goofy to me the the starting URL would be http://www.myWebPage.org?SOURCES=('PRD',CLI',MEM','CLM',PCLM') - no one could remember that . . . although they could bookmark it . . .

hope I'm making sense . . .


 

by: williampeckPosted on 2009-03-31 at 13:37:42ID: 24033395

this is what I got as the solution from a colleague here:

where s1.stus_nm = 'active' and s1.subj_area_cd in (
   <c:choose>
       <c:when test='${param.filter == "clientprod"}'>
           'PRD','CLI')
       </c:when>

       <c:when test='${param.filter == "memidm"}'>
           'MEM','IDM') and s1.srce_sys_cd <> '141'
       </c:when>

       <c:when test='${param.filter == "medd"}'>
           'MEM','PCLM') and s1.srce_sys_cd in ('140','141')
       </c:when>

       <c:when test='${param.filter == "claim"}'>
       'CLM','PCLM') and s1.srce_sys_cd <> '140'
   </c:when>

       <c:when test='${param.filter == "prov"}'>
       'PRV')
   </c:when>

       <c:otherwise>
           'PRV','PRD','CLI','MEM','IDM','CLM','PCLM')
       </c:otherwise>
   </c:choose>
order by 1

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...