Print
Add To Favorites
Email To Friend
Rate This Article
|
CodeSnip: Using Dynamic Cursor in a Procedure Using Oracle 9i
|
Published:
21 May 2008
|
Abstract
In this code snippet, Deepankar examines the usage of dynamic cursors in a procedure where the table name is passed as an input parameter. After listing the SQL code sample, he analyzes it and then provides a screenshot of the final output. |
|
by Deepankar Sarangi
Feedback
|
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days):
21692/
39
|
|
|
Introduction |
When the table to be used inside a cursor is not known to
the user while creating the procedure, a ref cursor can be used to pass the
name of the table dynamically as the input parameter to the procedure. The procedure
also serves the purpose of being used again and again for many different tables
of similar type as per the business requirement.
Requirements
Oracle database 9i
|
|
|
User Comments
Title:
Auther
Name:
Deepankar Sarangi
Date:
2009-06-13 2:45:20 AM
Comment:
Hi Andrew, In case you do not know the column(s) name in advance and wish to pass the column name dynamically just like the table name and job name you have to pass another in parameter carrying the column name. Then your dynamic query would look as given below.
sql_stmt := 'SELECT distinct '||in_column_nm||' FROM '||in_table_nm||' WHERE JOB ='''||job_name||'''';
plz let me know in case any issue.....
|
Title:
listing Table Contents
Name:
Andrew Snowball
Date:
2009-06-11 7:01:29 PM
Comment:
But what if you don't know the columns in the table(s). This example only works if you know that whatever table you use will always contain a column named "ename"...
I need to extract data without knowing the columns.
~AS.
|
Title:
Passing Table from .Net
Name:
Jegan
Date:
2008-05-30 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
|
|
|
|