[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to query based on a parameter?

Posted on 2009-02-10
3
Medium Priority
?
905 Views
Last Modified: 2013-11-19
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>

Open in new window

0
Comment
Question by:Alaska Cowboy
  • 2
3 Comments
 
LVL 15

Expert Comment

by:fsze88
ID: 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>

Open in new window

0
 
LVL 1

Author Comment

by:Alaska Cowboy
ID: 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 . . .


0
 
LVL 1

Accepted Solution

by:
Alaska Cowboy earned 0 total points
ID: 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
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question