Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

loop through recordset and display all fields

Posted on 2003-12-04
7
Medium Priority
?
902 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 1000 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
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 
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

Understanding Web Applications

Without even knowing it, most of us are using web applications on a daily basis. Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We often confuse these web applications tools for websites.  So, what is the difference?

Question has a verified solution.

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

What You Need to Know when Searching for a Webhost Provider
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

610 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