Link to home
Start Free TrialLog in
Avatar of sgt_ripley
sgt_ripley

asked on

loop through recordset and display all fields

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
Avatar of CFDevHead
CFDevHead

This should work
<cfloop query='myRS'>
           <cfoutput>#Field#</cfoutput>
</cfloop>
ASKER CERTIFIED SOLUTION
Avatar of Mause
Mause

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of Renante Entera
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 :-)
entrance : how does that look different from what i had commented ?
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
Avatar of sgt_ripley

ASKER

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!