CodeSnip: Using Dynamic Cursor in a Procedure Using Oracle 9i
page 2 of 4
by Deepankar Sarangi
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 5492/ 243
Article Contents:

Code

Listing 1

CREATE OR REPLACE
PROCEDURE referenced_cursor_p (in_table_nm IN VARCHAR2, in_job_name IN VARCHAR2)
as
       TYPE CUR_TYPE             IS REF CURSOR;
       managers                  CUR_TYPE;
       manager_name              VARCHAR2 (20);
       sql_stmt                  VARCHAR2 (200);
       job_name                  VARCHAR2 (20):=in_job_name;
BEGIN 
 
       /*Use of cursor in selecting the SALES Guys*/
       sql_stmt := 
'SELECT distinct ENAME FROM '||in_table_nm||' WHERE JOB ='''||job_name||'''';
       dbms_output.put_line('Use of cursor in selecting the Managers');
/*Opened the ref cursor where the table name is passed dynamically through a string*/
       Open managers for sql_stmt;
       loop
       FETCH managers INTO manager_name;
       EXIT WHEN managers%NOTFOUND;
       dbms_output.put_line(manager_name||' is a Manager');
       end loop;
END referenced_cursor_p;

View Entire Article

Article Feedback

Title:  
Name:  
Url: ( Optional )
Comment:  
Please add 8 and 5 and type the answer here:

User Comments

Title: Passing Table from .Net   
Name: Jegan
Date: 5/30/2008 1:42:32 AM
Comment:
Hi Deepankar Sarangi

This is goood,now i wanted to pass datatable from .Net to oracle stored procedure.
Pls reply

Jegan






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2008 ASPAlliance.com  |  Page Processed at 12/3/2008 7:51:24 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search