Solved

non sequenced output of query results

Posted on 2003-12-08
8
146 Views
Last Modified: 2013-12-24
I have a query which can return 0-n records in the format

empid cid cidvalue

empid is the primary look up for the table with cid as a secondary so PK for the table is (empid,cid)

i need to output this information in a report but the report layout does not allow for looping over the query to output the cidvalue

the output is based on cid as a key, i need to be able to run the query once and using the value of cid lookup cidvalue so that it can be outptut in the proper location on the report
0
Comment
Question by:James Rodgers
8 Comments
 
LVL 17

Expert Comment

by:Tacobell777
ID: 9900727
empid is the primary look up for the table with cid as a secondary so PK for the table is (empid,cid)

i need to output this information in a report but the report layout does not allow for looping over the query to output the cidvalue

-----

Why does it not allow looping over the cidvalue? Whats the error if any?

-----

the output is based on cid as a key, i need to be able to run the query once and using the value of cid lookup cidvalue so that it can be outptut in the proper location on the report

-----

I am not 100% sure what it is your after, maybe I just don't understand the question, can you rephrase?

Just some wild guesses:

SELECT empid, cid, cidvalue, empid + cid AS myKey
FROM yourtable

<cfloop query="yourQuery">
<cfset myKey = yourQuery.empid & yourQuery.cid>
#variables.myKey#  #yourQuery.empid#
</cfloop>

0
 
LVL 25

Author Comment

by:James Rodgers
ID: 9900801
no i cant loop over the query as the output is not in a sequential format

if you consider that i get 4 rows of returned values from my standard query
EMPID   CID      CIDVALUE
111111 SADE   long text description od the contents of this field
111111 DFIO    even more of a long text description od the contents of this field
111111 KUTI    a not so long text description od the contents of this field
111111 WSSD  a very short text field

the fields might have to be displayed on the report as
-----------------------------------------------------
DFIO                                                           |
-----------------------------------------------------|
some other content                                      |
-----------------------------------------------------|
SADE                                                          |
-----------------------------------------------------|
other content                                               |
still more other content                                 |
and still more dynamic content                       |
-----------------------------------------------------|
WSSD                                                          |
-----------------------------------------------------|
KUTI                                                            |
-----------------------------------------------------|
                                                                   |
and still more dynamic content                       |
-----------------------------------------------------|

so looping over the query is not possible, i waqnt to use the CID as a lookup for CIDVALUE and output it at the specified location on the report
0
 
LVL 17

Accepted Solution

by:
anandkp earned 500 total points
ID: 9901866
take all the values in a list [ValueList] & then play around with the list as u want to
OR
u cld also use arrays for this !

<cfquery datasource="MyDatasource" name="MyQuery">
  SELECT FirstName, LastName FROM MyTable
</cfquery>

<cfoutput>
#MyQuery["FirstName"][3]#
</cfoutput>
This example displays the value of the "FirstName" column, third row.

With this - u can access the values in a non sequential format & can get ur reporting done as per the need !

K'Rgds
Anand
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 11

Expert Comment

by:hart
ID: 9902058
will this do..

hit the query... and do this
<html>
<head>
<script language="javascript">  
   <cfloop query="queryname">
      var lst_#empid# = '#EmpID#';
      var lst_#cid# = '#cid#';
      var lst_#cid#value = '#cidvalue#';
   </cfloop>
function showVal()
{
   var nCid = document.frm.selcid.options[document.frm.selcid.selectedIndex].value;
   document.all.showcidvalue.innerHtml = eval("lst_" + nCid + "");
}
</script>
</head>
<body>
   <form name="frm">
        <select name="selcid">
           <cfoutput query="queryname" onchange="showVal()">
                <option value="#cid#">#cidvalue#</option>
           </cfoutput>
       </select>
       <div id="showcidvalue"></div>
   </form>
</body>
</html>

Regards
Hart
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 9903682
sorry hart, not what i need

i need to output cidvalue form the server side, the report has to be complete and ready to print as soon ans the html is rendered by the browser

Anand, your answer looks like what i am looking for ... just need to test

thanks
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 9903811
Anand,
used what you suggested and came up with this
<cfquery name="getFreeText" ..... >
      SELECT CID, CIDVALUE
      FROM HR_ToolBox_CDPG_FreeText
      WHERE EMPID =<cfqueryparam value="#empLookupId#">
</cfquery>

<cfset lookupList=#ValueList(getFreeText.CID)#>

<cfif listFind(lookupList,'SPS')>
#getFreeText['CIDVALUE'][listFind(lookupList,'SPS')]#
</cfif>

and it seems to do what i need...

thanks
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9903842
coooooool  .... way to go !

Looks like u've merged - ValueList & Array ... Neat one !

Cheers
Anand
0
 
LVL 25

Author Comment

by:James Rodgers
ID: 9903886
thanks for the good word

...and the help
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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