| 
		
			| Pro*C and PL/SQL question [message #397016] | Wed, 08 April 2009 11:22  |  
			| 
				
				
					| lamikam Messages: 7
 Registered: April 2009
 | Junior Member |  |  |  
	| I have some PL/SQL code that needs to run from a pro*c app. I need to do something like this:
 
 EXEC SQL EXECUTE
 declare
 foo number;
 begin
 for record in ( < some query > )
 loop
 
 // Do a bnuch of other queries that generate scalar values.
 
 // I know I cannot do this:
 printf("%d", foo);
 end loop;
 EXE-END;
 
 I don't know how many iterations the PL/SQL loop will generate, but with each loop iteration, I want to take the calculated results and in C, print them to a file.  Can I create a PL/SQL table and somehow populate that and access it OUTSIDE of the PL/SQL block?  The other option, is to write the values to some temp table, and then query the table.  This seems wasteful.
 Is there some way to use a host array for this?
 
 Thanks.
 |  
	|  |  | 
	|  | 
	| 
		
			| Re: Pro*C and PL/SQL question [message #397042 is a reply to message #397032] | Wed, 08 April 2009 12:59   |  
			| 
				
				
					| lamikam Messages: 7
 Registered: April 2009
 | Junior Member |  |  |  
	| "Declare a bind variable and put the result in this bind variable, then you can print after the return of PL/SQL. You cannot print DURING PL/SQL block execution."
 
 That won't work.  I need to print the values from INSIDE the loop.
 Where can I store them temporarily, and then access after the loop completes?
 |  
	|  |  | 
	| 
		
			| Re: Pro*C and PL/SQL question [message #397049 is a reply to message #397042] | Wed, 08 April 2009 13:23  |  
			| 
				
				|  | Michel Cadot Messages: 68770
 Registered: March 2007
 Location: Saint-Maur, France, https...
 | Senior MemberAccount Moderator
 |  |  |  
	| | Quote: |  | That won't work. I need to print the values from INSIDE the loop. Where can I store them temporarily, and then access after the loop completes?
 
 | 
 
 | Quote: |  | You can use dbms_application_info to set v$session.client_info and check in which loop your process is but outside this program (or in another thread if you write a multithreaded program). 
 | 
 Regards
 Michel
 
 |  
	|  |  |