GeeCON Prague 2014*
The moose likes Oracle/OAS and the fly likes Execution of stored procedure using for loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Execution of stored procedure using for loop" Watch "Execution of stored procedure using for loop" New topic
Author

Execution of stored procedure using for loop

Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
I want to use the below procedure in java.



But, while i executed query in sql console, it returned 300 records.

while i execute the proc, I am getting the ouput as just "Names: ". The usernames are displaying.

Please let me know, is this a correct way to display output while using query in for loop.
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
Any help for this..please
Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
Honestly I did not understand what are you trying to do? Can you explain it a bit more? Are you trying to return values as ref cursor from pl/sql to java?

Regards,

Fatih.
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
Yes, i am trying to return values from pl/sql to java using ref cursor. I am getting those values and am displaying that in my java output also.

You can see that i am using "dbms_output.put_line" in this procedure. While i execute this procedure in oracle console, I am getting the ouput as just "Names: ". The usernames that were suppose to display in a loop are not displaying beside "Names:".

My question is am i using the "dbms_output.put_line" statement in a right place as in the below procedure or do i need to put all the retrieved values from a loop to some storage like cursor and then use dbms_output.put_line to display values
Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
From java perspective dbms_output.put_line has no practical use. You should handle by getting resultset which is your out parameter and then iterate over the resulset and display or whatever you want.

From oracle perspective I have not seen such a usage till now. Does it really display all values from cursor? If I were you I would use a for loop for displaying results of cursor in sqlplus/toad/sql developer/etc. but again it has no benefit for java code.

But I guess your code is already working fine, or does not?

Regards,

Fatih.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Execution of stored procedure using for loop