Solved

loop through recordset and display all fields

Posted on 2003-12-04
7
883 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
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
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

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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 …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 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

24 Experts available now in Live!

Get 1:1 Help Now