Upload
mrcseku
View
67
Download
0
Embed Size (px)
DESCRIPTION
Parameterized View - Oracle
Citation preview
All Places > Developer > English > Oracle Database > SQL and PL/SQL > Discussions
THIS DISCUSSION IS ARCHIVED
11 Replies Latest reply: Oct 20, 2013 6:59 AM by xerces8
4870 Views
Average User Rating
(0 ratings)
This question is Not Answered.
Explain the parameterized view with example
727892 Apr 21, 2010 4:22 AM
1. Re: Can AnyOne Explain Parameterized View with Example
Hi,Checkhttp://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1448404423206
Regards,Bhushan
Like (0)
728534 Apr 21, 2010 4:25 AM (in response to 727892)
2. Re: Can AnyOne Explain Parameterized View with Example
user12059276 wrote:Explain the parameterized view with example
How about you explain your problem?
We're not here to teach things that are easily looked up in documentation.
BluShadow Apr 21, 2010 4:40 AM (in response to 727892)
Can AnyOne Explain Parameterized View with Example | Oracle Co... https://community.oracle.com/thread/1063238?tstart=0
1 of 8 8/04/2014 3:51 PM
Like (0)
3. Re: Can AnyOne Explain Parameterized View with Example
Passing two Dates to View and Select data between two dates
Like (0)
727892 Apr 21, 2010 4:43 AM (in response to BluShadow)
4. Re: Can AnyOne Explain Parameterized View with Example
user12059276 wrote:
Can AnyOne Explain Parameterized View with Example
http://homepage.ntlworld.com./jonathan.deboynepollard/FGA/questions-with-yes-or-no-answers.html
Yes.
http://forums.oracle.com/forums/search.jspa?threadID=&q=%22parameterized+view%22&objID=f75&dateRange=all&numResults=15&rankBy=10001
Like (0)
6363 Apr 21, 2010 4:47 AM (in response to 727892)
5. Re: Can AnyOne Explain Parameterized View with Example
user12059276 wrote:Passing two Dates to View and Select data between two dates
How would you go about selecting data between two dates in a normal query?(Hint: A view is no different to a normal query)
Like (0)
BluShadow Apr 21, 2010 4:54 AM (in response to 727892)
6. Re: Can AnyOne Explain Parameterized View with Example
Hi ,
728140 Apr 21, 2010 5:46 AM (in response to BluShadow)
Can AnyOne Explain Parameterized View with Example | Oracle Co... https://community.oracle.com/thread/1063238?tstart=0
2 of 8 8/04/2014 3:51 PM
select MARKETSU_SU_CODE, MARKETSU_ADJUSTEDNAV , dt from ( select MARKETSU_SU_CODE, MARKETSU_ADJUSTEDNAV,MARKETSU_ADJUSTEDDATEdt, row_number() over (partition by MARKETSU_SU_CODE order by MARKETSU_ADJUSTEDDATE desc) rn from trn_invest_marketsu where MARKETSU_ADJUSTEDDATE between to_date(fromdate,'DD/MM/YYYY') andto_date(todate,'DD/MM/YYYY') and MARKETSU_ADJUSTEDNAV> 0 ) where rn=1) bon a.PURSU_CODE = b.MARKETSU_SU_CODE(+)Where SubStr(PurSU_ID,0,2)='UN' And SubStr(PurSU_ID,0,4) != 'UNSW'And PurSU_RequestStatus='Y' and PURSU_FROMBANKCODE = ' 'and PURSU_DATE between to_date(fromdate,'DD/MM/YYYY') and to_date(todate,'DD/MM/YYYY')Group By MARKETSU_ADJUSTEDNAV,PURSU_CODE,PURSU_DATE,dt,PURSU_NAV,PURSU_TOTALSU,DIVIDENDTYPE_IDUnionSelect SalSU_Code As Code,SalSU_Date As UDate,SalSU_SaleNAV As NAV,SalSU_NoOfUSold AsUnits,0 PurchaseAmt,0 SwitchInAmt,0 DividendAmt,Sum(SalSU_TotalRealization) As RedemptionAmt,0 SwitchOutAmt,DividendType_ID As DividendOption From Trn_Invest_SalShareUnitsWhere SubStr(SalSU_ID,0,5)='UNRED' And SalSU_RequestStatus='Y'and SalSU_Date between to_date(fromdate,'DD/MM/YYYY') and to_date(todate,'DD/MM/YYYY')And SalSU_MJVStatus in('C','D','O') Group BySalSU_Code,SalSU_Date,SalSU_SaleNAV,SalSU_NoOfUSold,DividendType_IDUnionSelect SalSU_Code As Code,SalSU_Date As UDate,SalSU_SaleNAV As NAV,SalSU_NoOfUSold AsUnits,0 PurchaseAmt,0 SwitchInAmt,0 DividendAmt,0 RedemptionAmt,Sum(SalSU_TotalRealization) As SwitchOutAmt,DividendType_ID As DividendOptionFrom Trn_Invest_SalShareUnits Where SubStr(SalSU_ID,0,4)='UNSW' And SalSU_RequestStatus='Y'and SalSU_Date between to_date(fromdate,'DD/MM/YYYY') and to_date(todate,'DD/MM/YYYY')And SalSU_MJVStatus in('C','D','O') Group BySalSU_Code,SalSU_Date,SalSU_SaleNAV,SalSU_NoOfUSold,DividendType_ID) A,Mst_Invest_Scheme B,Mst_Invest_SchemeDividendType CWhere A.Code=B.Scheme_CodeAnd A.DividendOption = C.DividendType_IDGroup ByA.Code,A.UDate,B.Scheme_Description,A.DividendOption,C.DividendType_Name,A.NAV,A.Units/
when i execute i get this error ...ORA-00907: missing right parenthesiswhat should i do?
Like (0)
Can AnyOne Explain Parameterized View with Example | Oracle Co... https://community.oracle.com/thread/1063238?tstart=0
5 of 8 8/04/2014 3:51 PM
7. Re: Can AnyOne Explain Parameterized View with Example
Cathrin wrote:Hi ,
I have created a view...CREATE OR REPLACE VIEW V_UNITS_UNITMOVEMENT_AMTEST(fromdatevarchar,todate varchar)... 127 more lines (no kidding)Group ByA.Code,A.UDate,B.Scheme_Description,A.DividendOption,C.DividendType_Name,A.NAV,A.U/
when i execute i get this error ...ORA-00907: missing right parenthesiswhat should i do?
First, indent your code to show the extent of structures that extend over several lines, such assubqueries, CASE expressions, or function calls that have nexted arguments.Make parentheses line up so that, if a ) has to be lines away from its matching (, then are indented thesame amount, with nothing except white space between them.When posting code (or any formatted text) on this site, type these 6 characters:
\
(small letters only, inside curly brackets) before and after sections
Note that "ORA-00907: missing right parenthesis" doesn't always mean y
Second, develop code in very small increments. Take baby steps. Start
Like (0)
Frank Kulash Apr 21, 2010 6:18 AM (in response to 728140)
8. Re: Can AnyOne Explain Parameterized View with Example
Hicreate or replace view test(fromdate varchar(20),todate varchar(20))asselect * from trn_invest_purshareunitswhere pursu_date between to_date(fromdate,'dd/MM/yyyy') and to_date(todate,'dd/MM/yyyy')..even with this view i get the error missing right parantheses
Like (0)
728140 Apr 21, 2010 6:24 AM (in response to Frank Kulash)
Can AnyOne Explain Parameterized View with Example | Oracle Co... https://community.oracle.com/thread/1063238?tstart=0
6 of 8 8/04/2014 3:51 PM
9. Re: Can AnyOne Explain Parameterized View with Example
Hi,
Cathrin wrote:Hicreate or replace view test(fromdate varchar(20),todate varchar(20))asselect * from trn_invest_purshareunitswhere pursu_date between to_date(fromdate,'dd/MM/yyyy') and to_date(todate,'dd/MM/yyyy')..even with this view i get the error missing right parantheses
Even that is too much to start with, and even that is unformatted.Here's an example of formatted code:
create or replace view test ( fromdate varchar (20) , todate varchar (20) )asselect * from trn_invest_purshareunitswhere pursu_date between to_date (fromdate, 'dd/MM/yyyy' and to_date (todate, 'dd/MM/yyyy');
Whenever you have an error, it helps to post the entire error message.In your case, it's probably:
create or replace view test ( fromdate varchar (20) *ERROR at line 1:ORA-00907: missing right parenthesis
Notice where the * is in the error message: it's right below "varchar". That's a hint. In this example, youhave balananced parentheses, but you have an Oracle keyword in a place where it isn't allowed, butwhere ) would be allowed.
In a CREATE VIEW statement, you can give aliases to all the columns immediately after the viewname, but you can't specify a data type (such as VARCHAR) at that point. Use CAST in the query ifyou need to specify a data type or length.
Like (0)
Frank Kulash Apr 21, 2010 6:45 AM (in response to 728140)
10. Re: Can AnyOne Explain Parameterized View with Example
(google listed this as one of first ten hits for searching on "how to make a parameterized view in
xerces8 Oct 20, 2013 6:59 AM (in response to 727892)
Can AnyOne Explain Parameterized View with Example | Oracle Co... https://community.oracle.com/thread/1063238?tstart=0
7 of 8 8/04/2014 3:51 PM
About Oracle | Oracle and Sun | | Subscribe | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Your Privacy Rights| Cookie Preferences
oracle", so I'll add some notes) Oracle (as of version 11g) does not support parameters for views, as is tried in the post above this one. There are several ways to "emulate" parametrized views in Oracle:- using SYS_CONTEXT- using Global Package Variables- maybe some more ways If anyone finds a nice article explaining each, please post... A start would be Ask Tom "Parameterized View & Truncation of Table"or Dive in Oracle: Create View with Parameter
Like (0)
11. Re: Can AnyOne Explain Parameterized View with Example
3.5 year old thread. Probably should be locked.
Like (0)
SomeoneElse Oct 19, 2013 1:22 PM (in response to xerces8)
Can AnyOne Explain Parameterized View with Example | Oracle Co... https://community.oracle.com/thread/1063238?tstart=0
8 of 8 8/04/2014 3:51 PM