Solved

non sequenced output of query results

Posted on 2003-12-08
8
143 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 11

Expert Comment

by:hart
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 25

Author Comment

by:James Rodgers
Comment Utility
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
Comment Utility
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
Comment Utility
coooooool  .... way to go !

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

Cheers
Anand
0
 
LVL 25

Author Comment

by:James Rodgers
Comment Utility
thanks for the good word

...and the help
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
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 tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now