Can a view include a variable

So what I'm trying to do is create a modified version of a view that can accept a date range when run. I have come across references to "parameterized views" and views using "context variables". Can someone help me understand the difference between the two and which approach is better for my situation?
Here is a sample of one working view (there are dozens):
CREATE OR REPLACE FORCE VIEW  "VF_PAYLOAD_BYMONTH"
  ("FACTORY_ID", "MONTH", "LOADS",
      "TTL_BIDTONS", "AVGBIDPAYLOAD",
      "TTL_ACTTONS", "AVGACTPAYLOAD") AS
  (select FACTORY_ID, to_number(to_char(DT,'MMYYYY')), SUM(LDS),
      SUM(TTL_BID_TONS), AVG(AVG_BID_TONS), SUM(TTL_ACT_TONS), AVG(AVG_ACT_TONS) from
  (select j.FACTORY_ID, c.DATE_INDEX as DT, COUNT(j.LOAD_JOB_ID) as LDS,
        SUM(DECODE(r.BID_TONS,0,NULL,r.BID_TONS)) as TTL_BID_TONS,
        AVG(DECODE(r.BID_TONS,0,NULL,r.BID_TONS)) as AVG_BID_TONS,
        SUM(DECODE(w.SPOT_WEIGHT,0,j.MAN_SPOT_WT,w.SPOT_WEIGHT)) as TTL_ACT_TONS,
        AVG(DECODE(w.SPOT_WEIGHT,0,j.MAN_SPOT_WT,w.SPOT_WEIGHT)) as AVG_ACT_TONS
     from TC c, TC_LOAD_JOBS j, LOAD_RATES r, SPOT_WEIGHTS w
    where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID and r.YARD = 0
      and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
    group by j.FACTORY_ID, c.DATE_INDEX)
  group by FACTORY_ID, to_number(to_char(DT,'MMYYYY')))
/This is what I am after:
CREATE OR REPLACE FORCE VIEW  "VF_PAYLOAD_BYMONTH"
  ("FACTORY_ID", "MONTH", "LOADS",
      "TTL_BIDTONS", "AVGBIDPAYLOAD",
      "TTL_ACTTONS", "AVGACTPAYLOAD") AS
  (select FACTORY_ID, to_number(to_char(DT,'MMYYYY')), SUM(LDS),
      SUM(TTL_BID_TONS), AVG(AVG_BID_TONS), SUM(TTL_ACT_TONS), AVG(AVG_ACT_TONS) from
  (select j.FACTORY_ID, c.DATE_INDEX as DT, COUNT(j.LOAD_JOB_ID) as LDS,
        SUM(DECODE(r.BID_TONS,0,NULL,r.BID_TONS)) as TTL_BID_TONS,
        AVG(DECODE(r.BID_TONS,0,NULL,r.BID_TONS)) as AVG_BID_TONS,
        SUM(DECODE(w.SPOT_WEIGHT,0,j.MAN_SPOT_WT,w.SPOT_WEIGHT)) as TTL_ACT_TONS,
        AVG(DECODE(w.SPOT_WEIGHT,0,j.MAN_SPOT_WT,w.SPOT_WEIGHT)) as AVG_ACT_TONS
     from TC c, TC_LOAD_JOBS j, LOAD_RATES r, SPOT_WEIGHTS w
    where c.TC_ID = j.TC_ID and j.LOAD_RATE_ID = r.LOAD_RATE_ID and r.YARD = 0
      and c.DATE_INDEX = w.DATE_INDEX and j.LOAD_RATE_ID = w.LOAD_RATE_ID
      and c.DATE_INDEX between :X and :Y   <-----  ADDED THIS
    group by j.FACTORY_ID, c.DATE_INDEX)
  group by FACTORY_ID, to_number(to_char(DT,'MMYYYY')))
/What I'd like to do is place a date range on the underlying query. The user wants two versions of the report: one that grabs everything by month and one that grabs everything by month but only within a certain date range.
PS. If this is possible, how do I "call" the view?

re Centinul : This is actually getting called using a procedure in APEX to generate a report. The entire report consists of one or more of these procedures: each one calculates a year's worth of metrics related to a given category and the data comes from a variety of source tables. I used views to ease the creation of the procedures, but maybe that's the wrong way to go. The thing is that the data has to be condensed (the view) then translated from rows into columns (handled in SQL in procedure) because I am on 10g (I don't have the PIVOT capability in 11g which would REALLY help simplify these reports a LOT). Putting it into views makes it easier to keep track of what is going on.
re Ajay Sharma, bluefrog, and AP: Yes, I saw those. Spent half an hour on AskTom, but the thing I didn't see was just a basic explanation of purpose and how to use it. The articles I saw kind of skipped that part, which was why I was asking here for an explanation.
re Frank Kulash: Thanks for the detailed explanation. As the view is going to be referenced from APEX, which shares a common execution user, I am questioning whether the parameterized approach would work at all, but I would appreciate input. It is looking more and more like I am going to have to incorporate the view directly into the procedure, as I will likely have more than one user attempting to access this report at the same time.
Any other suggestions would be appreciated. Here is the query being used in the procedure. Please understand that this is one of the simple ones: several of the other views are composites formed from two, three, or even four base views. Manageability quickly becomes a major concern here.
cursor c_PYLD_TARGET is SELECT NVL(SUM(CASE WHEN MONTH = to_number('08'||(v_dt-1))
          THEN AVGBIDPAYLOAD END),0) as "AUG",
        NVL(SUM(CASE WHEN MONTH = to_number('09'||(v_dt-1))
          THEN AVGBIDPAYLOAD END),0) as "SEP",
        NVL(SUM(CASE WHEN MONTH = to_number('10'||(v_dt-1))
          THEN AVGBIDPAYLOAD END),0) as "OCT",
        NVL(SUM(CASE WHEN MONTH = to_number('11'||(v_dt-1))
          THEN AVGBIDPAYLOAD END),0) as "NOV",
        NVL(SUM(CASE WHEN MONTH = to_number('12'||(v_dt-1))
          THEN AVGBIDPAYLOAD END),0) as "DEC",
        NVL(SUM(CASE WHEN MONTH = to_number('01'||v_dt)
          THEN AVGBIDPAYLOAD END),0) as "JAN",
        NVL(SUM(CASE WHEN MONTH = to_number('02'||v_dt)
          THEN AVGBIDPAYLOAD END),0) as "FEB",
        NVL(SUM(CASE WHEN MONTH = to_number('03'||v_dt)
          THEN AVGBIDPAYLOAD END),0) as "MAR",
        NVL(SUM(CASE WHEN MONTH = to_number('04'||v_dt)
          THEN AVGBIDPAYLOAD END),0) as "APR",
        NVL(SUM(CASE WHEN MONTH = to_number('05'||v_dt)
          THEN AVGBIDPAYLOAD END),0) as "MAY",
        NVL(SUM(CASE WHEN MONTH = to_number('06'||v_dt)
          THEN AVGBIDPAYLOAD END),0) as "JUN",
        NVL(SUM(CASE WHEN MONTH = to_number('07'||v_dt)
          THEN AVGBIDPAYLOAD END),0) as "JUL"
     from VF_PAYLOAD_BYMONTH
    where FACTORY_ID = v_proj;
...(might help to get the right one)
Edited by: blarman74 on Aug 24, 2010 11:10 AM

Similar Messages

  • Can not view contents of variable in debug mode (version 1.1.1.5.0)

    Hi
    I am running on WebLogic 11R1 and using OEPE 1.1.1.5.0.
    When Fast swap is enabled and I run WebLogic in debug mode using OEPE I can not view the contents of variables with the Eclipse debugger. I get the message "Expressions must contain either an expression or a block containing a well formed statement"
    However, if I disable Fast swap, i can view the variable within the Eclipse debugger
    Has anyone else had this problem?
    Regards
    Steve H

    Small correction... the soon-to-be-released version of WebLogic Server that Danny was referring to is 11gR1 PatchSet 2 or 10.3.3.

  • How can I view the member variable while debugging

    When I using JCOP-debug mode in eclipse, I want to view the variable in the Variable window. I can see the "this" instance in the window. But when I click the "+" beside "this" to view the member variables of the instance. Debug process is terminated, following lines displayed in console window:
    ASSERTION FAILED: Object header element PAK must be odd!
    Expression: (o->pak&1)==1
    File: simulation.c
    Line: 393
    What can I do then?

    http://forum.java.sun.com/thread.jspa?threadID=722788
    http://download.boulder.ibm.com/ibmdl/pub/software/dw/jcop/tools.zip

  • How can i view the variables of the session memory

    Hi experts
       How can i view the variables of the session memory.Such as I want display the variables of memory which id is 'BULRN' in ABAP debug.
    In program i can use import from memory id visit the momery of session,but i don't know the name of variables which store in momery of my session.

    Its not possible to view in the debug mode..
    SAP memory is a memory area to which all main sessions within a SAPgui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another. Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters can be set either for a particular user or for a particular program using the SET PARAMETER statement. Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA parameters is to fill input fields on screens
    SAP global memory retains field value through out session.
    set parameter id 'MAT' field v_matnr.
    get parameter id 'MAT' field v_matnr.
    They are stored in table TPARA.
    ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data
    to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse.
    ABAP memory is temporary and values are retained in same LUW.
    export itab to memory id 'TEST'.
    import itab from memory Id 'TEST'.
    Here itab should be declared of same type and length.

  • HT1766 how can i view my backed up items, including apps, and select specific items to restore back to my iPhone? i lost a lot of items when upgrading to iOS 6.0.1. thanks for any help.

    I have just updated an iPhone 4 to iOS 6.0.1 and lost a lot of the Apps that were on the phone. How do I get them back? Can I view my backed up items and select items to restore?

    You can restore the backup to get the apps back from the last backup
    Or you can re install them manually

  • How Can i retain the Shared Variable Values after PC rebooting

    Hi all,
    I am facing a paculiar problem with Shared Variables. I have an application in which shared variables are used for data communication.
    One of the application requirement is to retain the variable values eventhough PC is rebooted or started after crashing. 
    As per the my understanding, the variable values will retain eventhough the PC is rebooted. But here i can observe a paculiar problem like some library variables are retaing the values while some others not. I enabled logging for all the variables.
    I tried many ways. like logging enabled, logging disabled, changing variable names, changing process names etc... But i am not getting a consistent behaviour.
    I hope some you can help me in solving this issue.. "How Can i retain the Shared Variable Values after PC rebooting"
    Thanks and Regards,
    Mir

    Hi Blackperl,
    Thanks for the post and I hope your well. 
    What do you mean by not getting consistent behaviour.. this will all depend on excatly when the crash happens i.e. before the write or after. 
    Surely a better method would be to log the data to a file during the reboot...
    I beleived the value read back
    will be the default value for the shared variable's data type.
    The LabVIEW DSC 8.0 module adds more functionality to the shared variable, including initial values and alarms.
    If you enable an initial value on a shared variable, when the variable
    engine comes back on-line it will default to this value. Setting a bad
    status alarm for the shared variable is also a good way of handling
    this type of event. Additionally, if you are using a LabVIEW Real-Time
    target such as Compact RIO or Compact FieldPoint, it is appropriate to
    consider hosting the shared variable engine on the real-time target.
    These devices have watch-dog capabilities and are typically the
    hardware controlling the critical pieces of an application. Most
    Windows or PC-based targets do not have these fail-safes.
    I guess, if you could explain to me again that would be great. From my point of view, if I have a cRIO and a Windows PC. If the windows PC crashes, the cRIO will still update its shared variables. Then once the PC has started up its own shared variable engine, and the bindings are loaded, it will once again continue to update its copies of the variables.
    Please let me know what you think,
    Kind Regards,
    James.
    Kind Regards
    James Hillman
    Applications Engineer 2008 to 2009 National Instruments UK & Ireland
    Loughborough University UK - 2006 to 2011
    Remember Kudos those who help!

  • Can we view  SH's partner functions in Sales Order?

    Hi All,
    SP has a different SH and FA is assigned to SH in master record. When we create order we can see all the partner functions of SP but we can't see partner functions of SH. User wants to see which FA is assigned to SH. We can only view partner functions of SH in delivery document. Is it possible to view partner functions of SH in sales order as well? Please suggest the ways to configure this setting.
    Thanks!!

    Hi,
    Yes, you can view . Check the Partner determination procedure, include the partner function SH to your partner determination procedure assigned for your sales order.
    Regards,
    Murali

  • Can't view tables in rs window?

    I am trying to work on a page/site that someone else began
    outside of DW.
    The code currently includes a file with it's own connection
    string:
    CONN = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=[path];
    and the page works fine up on the site. This original page is
    very simple
    and loops to list some data from the database as plain text.
    When I try to make the connection in DW, however, while I CAN
    make a
    successful connection in the connection string window, once I
    am at the
    recordset window I can't view any of the database tables or
    queries.
    I looked up the problem online and found suggestions to use
    ODBC connections
    instead of OLEDB connections -- tried that, but same results.
    I get an
    error when I try to view the tables:
    Error calling GetTables:
    an unidentified error has occurred.
    Anyone have a solution??

    I too am currently having this problem. HELP.
    when I try to create a recordset to an ACCESS database, i get
    the same error...
    error calling getTables; an unidentifed error has occurred.
    I dont handle the server...I am just a lonely servant. the
    admin is telling me nothing has occured on his end....so Im
    thinking it has to be a macromedia issue.
    now Im finding others with the same problem.
    but is there a fix.

  • Can't view duplicates in iPod or iPod selection

    iTunes 7.3.2 seems a little odd, everything looks and seems to work differently - I don't seem to be able to have any control over the ipod (4 gig mini) contents unless I select "manually manage" - in the older versions, it seemed to be a mixture, you could add manually by dragging, or itunes would add from your regular itunes list as a 'surprise' which I quite liked...now I also find I can't view duplicates in anywhere but the main itunes music library - I wonder if this is a permissions issue?
    The update just seems to have complicated something that worked fine as it was....

    First of all, Yahoo! and Hotmail are not Apple products, so this is not the place to seek help with their services; you need to go to the Yahoo! Mail and Hotmail Help pages for them. Aside from that, are you certain the sender attached a picture instead of just including the link to it? Did you ask them that specific question?
    You need to check all those things before assuming there's a problem. The fact that you can view pictures in Safari on other sites would indicate there's no problem with Safari and that the sender of the email sent a link to a picture.
    Mulder

  • Can not view videos on you tube in firefox4 using flash player11

    I'm using firefox 4 and i can not view videos on you tube.I've updated and reinstalled adobe flash player twice with no results.I've also tried the other checks,security blocking,cache,pop ups etc Works fine on IE. Hope someone has a solution.I've always liked firefox but not the newer versions and many of the changes;

    I can't believe you're still running Firefox 4. Why not a newer version?
    There are a number of active threads concerning the latest Flash player plugin (11.3) and the latest Firefox (12-13). Not all users are experiencing the same issues, but things to check include the following:
    - Conflict with Realplayer Browser Record plugin (to disable this, open Add-ons from the orange Firefox button or the classic Tools menu and look under the Extensions and Plugins categories)
    - Conflict with Flash 11.3 Protected Mode (see [http://forums.adobe.com/thread/1018071?tstart=0 Adobe Forums: How do I disable Flash Player's protected mode for Firefox?])
    Scanning down the front of the forums probably will yield additional suggestions: https://support.mozilla.org/en-US/questions
    Does any of that appear promising?

  • Open URL including a variable

    I want to open a specific URL in Safari which has to be like this: +http://website.com/variableothertext
    where variable is a variable I created before. I tried the action "Obtain specified text", linked to "Show webpage", but I can't figure how to include my variable into the text field of "Obtain specified text", since when I try to drag that variable into it, it simply creates an "Obtain variable value" action.
    What should I do instead?

    Hello Tom!
    Keep it simple and try this:
    Option Explicit
    dim data
    dim maxval
    dim minval
    data = "[1]/[2]"
    maxval=CMax(data)
    minval=CMin(data)
    Matthias
    Matthias Alleweldt
    Project Engineer / Projektingenieur
    Twigeater?  

  • An event in one of my libraries no longer has the event icon next to it's name just the name only. I can't view the clips in the event or import new clips. I've tried deleting the event and nothing.

    an event in one of my libraries no longer has the event icon next to it's name in the browser just the name only. I can't view the clips in the event or import new clips. I've tried deleting the event and nothing. After control clicking the event it shows all the media that has been previously imported. But it does not allow anything to be done to the event including deleting. This showed up at the beginning of a normal import session. This is fortunately the back-up evant.

    Did you perhaps mess with the contents of the library in the Finder?
    You may try the solution suggested in this thread:
    https://discussions.apple.com/message/24915790#24915790

  • I recently updated iphoto 11 and now I can't view my photos in the iphoto library.  Screen is blank,  but photos will show if played as slide show.  What's going on? ? ?

    On Friday, October 28th I updated my iphoto 11 because I received notice from Apple that I should do so for better stability in the program.    Today I opened I photo and found that although all my events show they are present and the number of photos in the library appears correct,  when I click on an event to view the contents, I get a black screen.   I am told there are no photos in the event.   When I return to the iphoto page it again shows all my events with pictures of the photos in the event thumbnails and the number of pictures in each event.    I can not actually view these photos individually.      Now here's the strange part,  when I select an event thumbnail and right click,  I can choose to view the event as a slide show, complete with music and special effects and it will play normally.   But no way can I view the event photos individually.     I have one event that claims to be empty, no photos in it,  yet when I click on that event  all 346 pictures pop up for individual viewing,  but will not play as a slide show.    I am totally confused and want my iphoto put back to normal.  
    Has anyone else had this problem?
    How do I uninstall the update,  or failing that how do I get my photos back? ?

    Hi Liz,
    Sorry to hear you are having a similar problem.  Last night I went to the tool bar at the top of iphoto, clicked on "File",  then clicked "Browse Backups" in the drop down menu.    I have an external hard drive that is set up to Time Machine.   The Browse Backups  opened the iphoto pages in the Time Machine.  I selected a date one day ahead of the day I performed the now infamous update, and it showed my iphoto library as it had existed that day.   I then clicked  "Restore Library" at the bottom right corner of the Time Machine screen.   Roughly 2 hours later my iphoto was back to normal.   When I opened iphoto there was a message saying I need to upgrade my program to be compatible with the new version of iphoto(version 9.2.1).  I clicked "Upgrade" and within seconds it had done whatever upgrading it needed to do. 
    The only glitch in the restoration was that it restored the library as it appeared last week, so I no longer had photos I had imported this past weekend.   I simply went back to the Browse Backups in the drop down menu,  when Time Machine opened I selected the page showing my pictures from this weekend and again said to Restore Library.   Roughly 45 minutes later the library was restored including the most recent photos.  
    I am now a happy camper. 
    I don't know if any of this will be of help to you because your email says you are having trouble with photos imported after the upgrade was performed.   Have you had any pop up notices when you first open iphoto,  that tell you you need an upgrade to be compatible with the new iphoto?     If so have you clicked "upgrade"? 
    Good luck Liz,  if you have Time Machine running as a back up to your library, maybe you wil be able to get help there, by following my instructions above.   Otherwise,   good luck with your investigations.   I'd be interested in hearing how you make out.
    Karen

  • TS4036 how can I view backed up files and delete things I don't need

    how do I view backed up files and delete thing I don't need

    You can't view individual files contained in the backup.  You can control which apps are backed up, and whether or not the camera roll is included in the backup, by going to Settings>iCloud>Storage & Backup>Manage Storage, tapping the name of your device under Backups, then looking under Backup Options.

  • HELP!Please have patient on my English. HELP!  Since i upgraded my iphone 4s to iOS 6.0, i can no longer watch or view my Movies or Video's in my Music Playlist. I can still view them in my Videos which is not in orderly manner or arragement like i wanted

    Please have patient on my English.
    HELP!
    Since i upgraded my iphone 4s to iOS 6.0, i can no longer watch or view my Movies or Video's in my Music Playlist. I can still view them in my Videos which is not in orderly manner or arragement like i wanted unlike in the Playlist. There is some sort of restrictions i guess. I already checked the Allow All Movies but still the videos does'nt appear. What should I do?
    Please HELP ME.
    Thank you very much.

    Similar problem here. My Ical refuses to edit or delete events. Viewing is possible, though sometimes the whole screen turns grey. Adding new events from mail is still possible. The task-pane completely disappeared. My local apple technic-centre messed about with disk utility for a bit and than told me to reinstall leopard. I could of course do that, but it seems to me that reinstalling Leopard just to fix iCal events is a bit invasive.
    I tried also tried removing everything, installing a new copy of iCal from the leopard-cd, software updates, all to no avail.
    At the moment I'm open to all suggestions that do not include a complete leopard reinstall.

Maybe you are looking for

  • Srvctl change OS user during start database

    Scenario: Aix 7.1 Oracle Grid Infrastructure Standalone Server 11.2.0.3 Patch 16083653: GRID INFRASTRUCTURE PATCH SET UPDATE 11.2.0.3.6 (INCLUDES DB PSU 11.2.0.3.6) Oracle RDBMS Single Instance Installation 11.2.0.3 Patch 16056266: DATABASE PATCH SET

  • Need help in configuring work email

    recently purchased 8310 curve. i have tried configuring using outlook web access option and outlook exchange option but some how not able to connect ot the server. have been able to configure yahoo email address. Message Edited by asv on 08-20-2009 0

  • Patch from 10.2.0.3 to 10.2.0.4 on Linux x64

    Hi everybody, I installed Grid Control under CentOS 5.1 without any problem. I'm installing the patch 3731593, following the instructions I found. I installed it on OMS and the Agent without any error, but when I install it on DB an error occured dur

  • Just got apple tv, was able to move a photo album from iphoto but cant remeber how i did it?

    Am trying to move albums from iphoto to apple tv, did it once but cant figure it out..making slideshow.

  • Sp to sync two tables using linked servers

    Hello everybody I'm working in a SP and I got two tables in different servers, one is the main and the other is a copy but whit less columns, all I want is to run the SP every 5 min over the main table in order to validate if new records has been cre