Solved

loop through recordset and display all fields

Posted on 2003-12-04
7
896 Views
Last Modified: 2013-12-24
hello,

I'm calling an Oracle storedprocedure:
No problem there, BUT;
Now I want to loop through the recordset and display all the fields/records
s'thing like this:
loop from 0 to maxFields
  <cfoutput>myRs.field.value
end loop
does anyone know how to do that?
thanx
0
Comment
Question by:sgt_ripley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 9

Expert Comment

by:CFDevHead
ID: 9875025
This should work
<cfloop query='myRS'>
           <cfoutput>#Field#</cfoutput>
</cfloop>
0
 
LVL 10

Accepted Solution

by:
Mause earned 250 total points
ID: 9875778
CFDevHead why use <cfloop>
<cfoutput query="myRS">
   #Field#
</cfoutput>

sgt_ripley is this what you want or don't you know what the fields are?
Than You can do something like this:

<cfoutput query="myRS">
    #myRS.currentrow#
   <cfloop list="#myRS.columnList#" index="fieldname">
       &nbsp#evaluate("myRS.#fieldname#")#
   </cfloop>
    <br>
</cfoutput>

Let me know
Mause
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9875841
in ur stored proc - u will have to define a ref cursor [i assume ur aware of that !]

ur code for cf wld look liek this

<CFSTOREDPROC>
      <CFPROCPARAM .... >
      <CFPROCRESULT name="qry_name2" resultset="1"><!--- first query in ur procedure returned thru the cursor --->
      <CFPROCRESULT name="qry_name2" resultset="2"><!--- 2nd query in ur procedure returned thru the cursor --->
</CFSTOREDPROC>

<cfoutput GROUP="qry_name1">
      .....
</CFOUTPUT>

<cfoutput GROUP="qry_name2">
      .....
</CFOUTPUT>

that shld do it for u

i gues thats what ur looking for ?

let me know

K'Rgds
Anand
0
Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

 
LVL 14

Expert Comment

by:Renante Entera
ID: 9878926
You may simply have it this way:

<cfstoredproc procedure="NameofProcedure" datasource="dsn">
  <cfprocresult name="GetRecords">
</cfstoredproc>

<cfoutput query="GetRecords">
  <!--- Display all records here ... --->
</cfoutput>

This will call the procedure then put the resultset in a query named "GetRecords".  Then basing from that query you may display the specific records from it.

Goodluck!
eNTRANCE2002 :-)
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9880010
entrance : how does that look different from what i had commented ?
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9880604
i am hoping that ur using packages ... the syntax for it as follows

package defination:

create or replace package pkg_mypkg
as
   type custom_ref_cursor is ref cursor;

   procedure prc_procname (    
      arg_cursor1  out   custom_ref_cursor
   );

-------------------------------------------
package body:

create or replace package body pkg_mypkg
as

   procedure prc_procname (  
      arg_cursor1  out   custom_ref_cursor
   )
   as
   begin
      open arg_cursor1
       for                
          select   fields
              from table;            

   end prc_procname;

end;

& the procedure calling it wld look like

<cfstoredproc procedure="pkg_mypkg.prc_procname" datasource="mydsn">
     <cfprocresult name="myqry" resultset="1"><!--- the ref cursor will be fetched into this query --->
</cfstoredproc>

<cfoutput query="myqry"><!--- my previous comment had a type & i had written group instead of query ! --->
    .....
</cfoutput>

hth !

K'Rgds
Anand
0
 

Author Comment

by:sgt_ripley
ID: 9894818
sgt_ripley is this what you want or don't you know what the fields are?
Than You can do something like this:

<cfoutput query="myRS">
    #myRS.currentrow#
   <cfloop list="#myRS.columnList#" index="fieldname">
       &nbsp#evaluate("myRS.#fieldname#")#
   </cfloop>
    <br>
</cfoutput>

Let me know
Mause

----

EXcellent!!
This was excactly what I was looking for!
thanx Mause!
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
What You Need to Know when Searching for a Webhost Provider
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

691 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