Home » Developer & Programmer » Precompilers, OCI & OCCI » Pro*C and PL/SQL question
Pro*C and PL/SQL question [message #397016] Wed, 08 April 2009 11:22 Go to next message
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 #397032 is a reply to message #397016] Wed, 08 April 2009 12:20 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
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.

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
Re: Pro*C and PL/SQL question [message #397042 is a reply to message #397032] Wed, 08 April 2009 12:59 Go to previous messageGo to next message
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 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account 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
Previous Topic: Compilation error when compiling Pro*C code (merged)
Next Topic: Issue with fetch in Pro*C
Goto Forum:
  


Current Time: Fri Mar 29 00:16:06 CDT 2024