Create view in PLSQL [message #622776] |
Fri, 29 August 2014 06:35 |
|
kmuthu
Messages: 2 Registered: August 2014 Location: Chennai
|
Junior Member |
|
|
I have created view like below;
create or replace view <viewname> as select * from <tablename> where creation_date <= (sysdate-30);
Is there possible to pass the date value using cursor?
My requirement is, i dont want to give the date value directly in the create view script.
Want to get the value from function and pass that value to creation_date column at the time of create view.
Can you please help me to write the plsql procedure for the same.
|
|
|
|
Re: Create view in PLSQL [message #622795 is a reply to message #622777] |
Fri, 29 August 2014 11:34 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
Quote:
My requirement is, i dont want to give the date value directly in the create view script.
Want to get the value from function and pass that value to creation_date column at the time of create view.
At first place, you shouldn't create views for underlying SQLs having varying predicates. In your case, you want to provide the date dynamically.
In my opinion, you don't require a view(unless you tell us the reason for creating a view). Why? Because, all you need to do is, in SQL*Plus declare a variable and assign the required value and then, go ahead with the date variable for the SQL.
|
|
|
|
|
|
Re: Create view in PLSQL [message #622861 is a reply to message #622860] |
Mon, 01 September 2014 00:03 |
|
Littlefoot
Messages: 21808 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
If you can't change SELECT statement, I wonder:
a) why not?
b) which part of it can you not change?
If you can't change ANYTHING, not a single word, then create a global temporary table (GTT) whose description is the same as the view's you planned to use. Before selecting from the GTT, populate it with data that is unique for a user who is going to use it (which means that you'd use different date value while performing INSERT INTO GTT). Finally, SELECT FROM GTT.
|
|
|