Solved

loop through recordset and display all fields

Posted on 2003-12-04
7
891 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

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…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 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