Use of rownum in a view

Trying to create a view which consistent of :
1. Data from a set of tables, implemented as a
separat VIEW VIEW1 with an unique key.
CREATE OR REPLACE VIEW1 AS
SELECT ukey,... FROM divtables;
2. An subtable refering to the unique key, may contain a number of occurences for each key. Now implemented as VIEW2 containing rownum.
CREATE OR REPLACE VIEW2 AS
SELECT ukey,ROWNUM rno, ... FROM subtab;
ROWNUM - How to get around this
When using SQL from VIEW2 for a specific key, then rownum is 1,2..., when using in VIEW2 then rownum seems to be numbered for the base table as such.
RESULTVIEW - How to implement
=============================
The RESULTVIEW should be used in an generic application, where one datarecord should be present for each unique key (used for "mailmerge").
Assumes that subtable only contains max 4 rows. Was planning to implements it as:
CREATE OR REPLACE RESULTVIEW AS
SELECT ukey,...,
sum(decode(nvl(v2.rno,0),1,v2.val,0)) Val1,
max(decode(nvl(v2.rno,0),1,v2.desc,0)) Desc1,
sum(decode(nvl(v2.rno,0),4,v2.val,0)) Val4
max(decode(nvl(v2.rno,0),4,v2.desc,0)) Desc4,
FROM VIEW2 v2,VIEW1 v1
WHERE v2.ukey(+)=v1.ukey
GROUP BY ukey,...
The problem with rownum in VIEW2 makes the planned implementation impossible, any suggestions on how to get around this would be appreciated.
The result must be a view which contains only one record for each unique key, and may contains up to
four groups of values for subtable (5 values in each group).

I suspect that you want VIEW2 to be defined as
CREATE OR REPLACE VIEW view2
AS
SELECT ukey,
       ROW_NUMBER() OVER (PARTITION BY ukey ORDER BY <<something>>) rno
  FROM subtabJustin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • Using a variable in a view?

    I know that it may not be possible to use a variable within a view, but I'm wondering if there isn't a work-around? If there is a single value---pulled from another table---you wish to reuse in a view that does not use dynamic SQL, how do you do so? I've been toying around with WITH statements, but that's getting me nowhere. I'm using 11r2.
    BTW, please do not ask me the standard litany of angry-dba questions (why are you doing this? your database is f*****, RTFM, etc.), this is just for my own curiosity. :)
    Thank you
    Example for demo purposes only (I know it's not syntactically correct):
    variable var_value varchar2(30)
    begin
    select this_is_just_one_value
    int :var_value
    from tableX where column1 = 'BOB';
    end;
    select
    numerous_columns
    from tableY
    where
    column5 = :var_value;

    893968 wrote:
    BTW, please do not ask me the standard litany of angry-dba questions (why are you doing this? your database is f*****, RTFM, etc.), this is just for my own curiosity. :)Why are you doing this? your database is f*****! RTFM! Etc!! ;-)
    SQL is not a procedural language - so you cannot create a view for example that has a parameter signature. E.g. this is possible in a procedural language:
    declare
            cursor c( deptID number ) is
                    select * from emp where deptno = deptID;
    begin
            open c( 1234 ); --// open SQL cursor using a parameter/variable
            --// etc..
            close c;
    end;This is not possible using a SQL object like a view. As a view is not a procedure. So the same approach as the above using SQL (silly example, but do demonstrates the basics):
    // define
    create or replace view emp_view as select * from emp;
    // use
    select * from emp_view where deptno = 1234;The CBO is clever - and it will likely push such a predicate into the emp_view SQL statement.
    To parameterise such a view, is ugly. And should only be considered when dealing with issues such as security and data restrictions. A context is created - this can contain a number of name-values. The view can then use a name-value from the context. Oracle's data dictionary views use this approach.

  • How can I use the Rownum/Customized SQL query in a Mapping?

    Hi,
    * I need to use a Rownum for populating one of the target field? How to create a mapping with Rownum?
    * How can I use an Dual table in OWB mapping?
    * Can I write Customized SQL query in OWB? How can I achieve this in a Mapping?
    Thanks in Advance
    Kishan

    Hi Niels,
    As I'm sure you know, the conundrum is that Reports doesn't know how many total pages there will be in the report until it is all done formatting, which is too late for your needs. So, one classical solution to this problem is to run the report twice, storing the total number of pages in the database using a format trigger, and throwing away the output from the first run when you don't know the total number of pages.
    Alternatively, you could define a report layout so that the number of pages in the output is completely predictable based upon, say, the number of rows in the main query. E.g., set a limit of one, two, ... rows per page, and then you'll know how many pages there will be simply because you can count the rows in a separate query.
    Hope this helps...
    regards,
    Stewart

  • HT5824 I have 4 calendars on my ICloud at work - I used to be able to view one calendar at a time or multiple - now when I check off to see just one calendar it automatically comes back on...?

    I have 4 calendars on my Icloud - I used to be able to view one at a time or multiple just by clicking on the check mark - now when I want to view just one calendar I click off the check mark but it automatically comes back on.  Any ideas?

    Can anyone help?

  • ICal View-Used to be able to view week with months on the side

    In the older version, I used to be able to view my iCal in the week view, with a colum on the side that showed the calandars.  I just updated to Lion and can't figure out how to get this same view.

    Greetings,
    The calendar side bar is a drop down menu in Lion.  To see the calendars you must click on the "Calendars" button in the top left corner of the iCal window.  The list is designed to disappear when not in use.
    The feature you are looking for does seem to be a part of the next version of OS X, Mountain Lion: http://www.macworld.com/article/1165436/mountain_lion_hands_on_with_contacts_and _calendar.html
    Cheers.

  • When I use my IPhone 4S to view the Shaw Go Movie Central App when I am at home I only use WiFi which is automatic, I start watching a show and sometimes I will get a message like "you can not use your cellular for video playback" or something close to th

    When I use my IPhone 4S to view the Shaw Go Movie Central App when I am at home I only use WiFi which is automatic, I start watching a show and sometimes I will get a message like "you can not use your cellular for video playback" or something close to that. Then I received an email from Telus saying I had used my 3G instead of Wi-Fi  using 75% of my data. How can this happen when I'm on Wi-Fi at home? If it switched to 3G for some reason I should have been disconnected and not just transferred to 3G network using up my data. What is the fix for this??

    It doesn't have to be that complicated, Verizon iPhones come unlocked, just tell VZ you're going on Holiday/Traveling and suspend the service, no need to pay for service if you're not going to be using it. Pick up local SIM cards in the countries of your choosing, pop them in, re-activate iMessage and you're set!
    I recommend getting a SIM card from the Three network in England, they have great EU roaming rates and free like-home roaming in Italy.
    Set your phone's region to match the country you're in, it'll save from some headaches when calling local/international numbers.
    To answer your questions,
    1. If you choose not to have a local SIM card, it is good to keep your phone in Airplane mode to save battery.
    2. Make sure the two iPhones have different names to reduce sync/restore issues.
    3. If husband has an iPhone also, you can chat with iMessage/Facetime, just give him heads up about the new number you'll have. Otherwise, use Whatsapp if he's got an Android. You can activate Whatsapp with your American number or the international number if you choose to get a SIM in Europe.
    Also, Get the MagicJack app and/or Google Hangouts, both of those apps provide you with free calling to the USA and Canada using any internet connection. Google Voice is another good way to SMS across the seas.
    Let me know if you need any more tips for iPhoning across the pond.

  • Hello. I want to use my iphone as a viewing screen for a usb endoscope, (its a small camera on a long cable for inspecting down piping and such) with an app is it possible to attach the usb to my iphone using a adapter to watch the live video feed on th

    Hello. I want to use my iphone as a viewing screen for a usb endoscope, (its a small camera on a long cable for inspecting down piping and such) with your app is it possible to attach the usb to my iphone using a adapter to watch the live video feed on the iphone?
    Thankyou.

    Hello. I want to use my iphone as a viewing screen for a usb endoscope, (its a small camera on a long cable for inspecting down piping and such) with your app is it possible to attach the usb to my iphone using a adapter to watch the live video feed on the iphone?
    Thankyou.

  • INDEX on VIEW or TABLE when using CONTAINS function on the VIEW

    Hi,
    I'm querying a view with a contains function and I'm getting an error:
    query: select * from view where contains(name,'jack OR jill')>0
    ORA-20000: Oracle text error
    DRG-10599 column is not indexed.
    From what I gathered you can't create an index on the view, or is that possible afterall (using 10g).
    Would it be sufficent to create an index on the column in the table that the view-query is pulling the data from? or can you use the contains funtion on views at all?
    Or are there other ways of doing this better?
    Thanks,

    That particular CONTAINS clause will require a domain index on the column, NAME in your case.
    You could also do: select * from view where name in ('Jack', 'Jill')
    Depending on your need and number of records and other variables, it may be "fastest" to do the text index on the NAME column. If it is a rather small subset of data and performance is not critical then the IN clause should suffice.

  • Can I use aperture 3 in live view shooting on my macbook pro

    Can I use aperture 3 in live view on my mac boook pro ?

    Why would you use two?
    It is much cheaper and better to simply use a usb drive..
    The TC cannot be linked to store files or automatically back them up.. whereas a usb drive at least will be backed up by Time Machine.
    If you want to do this properly get a real NAS.. that has mirrored drives and real rsync type backup. You can use an airport extreme for wireless.

  • When using FireFox I often cannot view pictures in Hotmail, but have no problem when using other browsers

    When using FireFox I often cannot view pictures in Hotmail emails, but I have no problem when using other browsers

    Do you also have this issue if you temporarily switch to Private Browsing mode?
    *https://support.mozilla.org/kb/Private+Browsing
    *Tools > Options > Privacy, choose the setting <b>Firefox will: Use custom settings for history</b>
    *Select: [X] "Always use private browsing mode"
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    See also:
    *https://support.mozilla.org/kb/fix-login-issues-on-websites-requrie-passwords

  • I have a 17" computer, and I'dlike to use the entire screen to view, but in order to do so, I have to press Control + several times at each site.

    I have a 17" computer, and I'dlike to use the entire screen to view, but in order to do so, I have to press Control + several times at each site. I don't want to use "full screen."
    Does anyone know how to set a default to maximize the screen? For some reason, the screen appears even smaller than my old 15" computer.

    Yes, it's a hassle to zoom every single site manually. You can "zoom" all sites using this add-on: [https://addons.mozilla.org/en-US/firefox/addon/2592/ NoSquint]. After setting your Global zoom level, you can still fine-tune the zoom on individual sites.
    After installing NoSquint, click the % on the Add-on Bar to call up site preferences, then click the Global Settings button, then the Zooming tab.
    If you don't have the Add-on Bar displayed, you can right-click the new tab button ("+") or a blank area of the tab bar to the right of it and choose Add-on Bar from the shortcut menu.
    You can experiment with sizes larger than 125%, but I wouldn't go much higher than 150% unless you have a large high-resolution monitor.
    If there are particular sites that still present a problem, feel free to post their URLs.

  • Is there anyway I could hook my Apple TV to my (non apple) lap to and essentially use my lap top as my tv. In other words use my computer screen to view content of y Apple TV

    Is there anyway I could hook my Apple TV to my (non apple) lap to and essentially use my lap top as my tv. In other words use my computer screen to view content of y Apple TV

    Nevermind I just installed it to try it and it's awesome, so happy right now, Thanks. All the things I had read about it on third party sites led me to believe it could not do extended desk tops, thanks for your help!

  • Hi i am using oracle 10g how to view the content of the stored procedure or trigger ?

    Hi i am using oracle 10g .How to edit  the content of the stored procedure or trigger ?

    jklopkjl wrote:
    Hi i am using oracle 10g .How to view the content of the stored procedure or trigger ?
    query ALL_SOURCE
    SQL> desc all_source
    Name                                      Null?    Type
    OWNER                                              VARCHAR2(30)
    NAME                                               VARCHAR2(30)
    TYPE                                               VARCHAR2(12)
    LINE                                               NUMBER
    TEXT                                               VARCHAR2(4000)

  • How can I use MS Access in Lab View

    how can I use MS Access in Lab View
    Its urgent

    There are a couple of routes you can take to communicate with MS Access in LabVIEW. The preferred method is our Database Connectivity Toolset. This allows you to use VIs to communicate with your database. Here is a link to the product for more information.
    http://sine.ni.com/apps/we/nioc.vp?cid=6429〈=US
    Your other choice would be to use ActiveX. I believe there are a couple of examples on our web site using it. Overall you will probably spend a lot more time taking this route.
    Matt Kisler
    Applications Engineer
    National Instruments

  • Help to use presentation variables in title view

    Hi,
    I am trying to use presentation variables in title view and the presntation variable that I have created is for current month date range (04/01/2012-04/30/2012)
    When I am using this variable in the title view in the report it is showing me as (04/01/2012,04/30/2012)
    IS there any way to get the date range as 04/01/2012-04/30/2012 instead of comma

    863997 wrote:
    Hi,
    I can not create two presenation variables and use becasue I have dashboard prompts setted up and I am using that prompt in my dashboard and report to..So if I create two presentation variables seaperately and use then whenever we change the dates in the prompts the dates in the reprot title will not changeYou absolutely can use two presentation variables and they will change in the Title View if you use them there. Click on this link for the details on how to create the two prompts and use them in your report.
    http://oraclebizint.wordpress.com/2008/02/26/oracle-bi-ee-101332-between-prompts-for-date-columns-using-presentation-variables/

Maybe you are looking for

  • Nokia lumia 1520 Ram

    How can i check the ram running on my nokia lumia 1520? I check the spec on nokia.com.my, there is 2 GB ram, but i check with apps, my nokia lumia 1520 only has 1 GB ram Attachments: wp_ss_20140111_0001.png ‏176 KB

  • MS configure program: encryption format for UGDIR_BINDPW and CFGDIR_BINDPW

    Hi Sun Folks, I am creating a silent installation script for JES 3 messaging and I have come to a bit of roadblock. I would like to create a state file to use with the Messenger Server configure program "/opt/SUNWmsgsr/sbin/configure" and pass to it

  • Please help me to decide the best deign for my web app

    I'm quite new to j2EE developement. Currently im working on a web based user management application ( a small scale one ). For that im hoping to use JSP s for presentaion tier and EJBs for business logic. This business logic seems to be having more o

  • Abap Objects-Factory classes

    Hi All, We are thinking of developing some factory classes in ABAP.Cud u suggest some ? May be analogous to those factory classes in other programming languages also.

  • Tax code does not exist against the proceedure

    Hi, I have copies TAXINN proceedure and created new ZTAXIN, assigned to country IN. Created tax code through FTXP and maitained rate inFV11 against condition type JIPS. In OB40 GL assigned against the tax code. And also logistic general also assigned