Creating parameterized views in oracle11g

I have a big query with nesting and left join and Ineed to create a view out of it so as not to run it from the application. The issue is I need the date range and some other fields as input parameters since it will vary from the front end for each request. I just looked up and saw some posts referring to using SYS_CONTEXT for parameterized views and need to know exactly how do I create the view for example with 2 parameters - fromdate, todate and how I invoke the view from the application.
Just for info I am using grails/groovy for developing the application. and here is the query I want to create view out of..
select
d.dateInRange as dateval,
eventdesc,
nvl(td.dist_ucnt, 0) as dist_ucnt
from (
select
to_date(fromdate,'dd-mon-yyyy') + rownum - 1 as dateInRange
from all_objects
where rownum <= to_date(fromdate,'dd-mon-yyyy') - to_date(todate,'dd-mon-yyyy') + 1
) d
left join (
select
to_char(user_transaction.transdate,'dd-mon-yyyy') as currentdate,
count(distinct(grauser_id)) as dist_ucnt,
eventdesc
from
gratransaction, user_transaction
where gratransaction.id = user_transaction.trans_id and
user_transaction.transdate between to_date(fromdate,'dd-mon-yyyy') and to_date(todate,'dd-mon-yyyy')
group by to_char(user_transaction.transdate, 'dd-mon-yyyy'), eventdesc
) td on td.currentdate = d.dateInRange order by d.dateInRange asc

user12985447 wrote:
I have a big query with nesting and left join and Ineed to create a view out of it so as not to run it from the application. The issue is I need the date range and some other fields as input parameters since it will vary from the front end for each request. I just looked up and saw some posts referring to using SYS_CONTEXT for parameterized views and need to know exactly how do I create the view for example with 2 parameters - fromdate, todate and how I invoke the view from the application.
Just for info I am using grails/groovy for developing the application. and here is the query I want to create view out of..
select
d.dateInRange as dateval,
eventdesc,
nvl(td.dist_ucnt, 0) as dist_ucnt
from (
select
to_date(fromdate,'dd-mon-yyyy') + rownum - 1 as dateInRange
from all_objects
where rownum <= to_date(fromdate,'dd-mon-yyyy') - to_date(todate,'dd-mon-yyyy') + 1
) d
left join (
select
to_char(user_transaction.transdate,'dd-mon-yyyy') as currentdate,
count(distinct(grauser_id)) as dist_ucnt,
eventdesc
from
gratransaction, user_transaction
where gratransaction.id = user_transaction.trans_id and
user_transaction.transdate between to_date(fromdate,'dd-mon-yyyy') and to_date(todate,'dd-mon-yyyy')
group by to_char(user_transaction.transdate, 'dd-mon-yyyy'), eventdesc
) td on td.currentdate = d.dateInRange order by d.dateInRange ascAre you dead set on creating a view? If so ... why?
I'd recommend creating a stored procedure / function (in a package) that returns a ref cursor before i'd recommend what you're going for (unless there is some extremely compelling reason why only a view will work).

Similar Messages

  • How to create a view with parameters; read the documentation but nothing!

    Hello!
    I'm new to the Oracle world but together with my coworkers we need to very quickly study Oracle to figure out whether we'll add Oracle to our list of supported databases or not.
    Question: How do I create a view with parameters?
    I've read the documentation but I could not find this! I found the sql syntax to create a view but no parameters whatsoever...
    I have found on the web some very complicated way of doing this, but doesn't Oracle support Views with parameters?
    The goal here is to return a recordset, don't forget, so,please don't speak about stored procedures unless you are going to tell me how to get a recordset out of a stored procedure! ;)
    Thanks for all your help and attention!
    Jorge C.

    You can set up a parameterized view via context as follows:
    1. Set up a procedure to set your context values:
    create or replace procedure p_set_context (p_context IN VARCHAR2,p_param_name IN VARCHAR2,p_value IN VARCHAR2)
    as
    BEGIN
    sys.dbms_session.set_context(p_context,p_param_name,p_value);
    END;
    2. Create your context using the procedure you just created
    create or replace context my_ctx using p_set_context
    3. This is the test table I'll use
    create table my_table(col1 number)
    and populate it:
    begin
    for v_index in 1..10
    loop
    insert into my_table values(v_index);
    end loop;
    end;
    and the view that will be parameterised
    create or replace view v_my_table as select col1 from my_table where col1 between sys_context('my_ctx','start_range') and sys_context('my_ctx','end_range')
    4. Now set the parameters using the procedure above.
    begin
    p_set_context('my_ctx','start_range','1');
    p_set_context('my_ctx','end_range','5');
    end;
    5. Selecting from my_table will give you 1 to 10 (no surprise there :-) )
    selectng from v_my_table will give you 1 to 5
    You can use the context to set formats etc using the same principle. A common gotcha to watch for is trying to set the context directly using DBMS_SESSION.SET_CONTEXT instead of creating a procedure. This belongs to SYS and SYS won't have the privileges to set your context so you get an insufficient privileges result leading to much headscratching and unnecessary grants (at least that's my understanding of it).
    Sorry Jorge, as you're new to Oracle I should also have pointed out for completeness sake, that you can change the parameters at any time through recalling the p_set_context, for example, following on from above, after your "select * from v_my_table" and seeing 1 to 5, you could then do
    begin
    p_set_context('my_ctx','start_range','3');
    end;
    and when you requery 'Select * from v_my_table' you will now see rows 3 to 5.
    Bit of a simplistic example, but you can see how easy it is. :-)
    Message was edited by:
    ian512

  • How to create a view with parameter?

    who can tell me hwo to create a view with
    parameters just like a cursor?

    Hi,
    This is not possible in Oracle. What u can do is create the view without the where clasue and supply the where clause at runtime.
    Hope this helps...
    Regards,
    Ganesh R

  • Error while creating Attribute View

    When I try to get Attribute view through two joined table with same type join indices I get following error ;
    Could not execute 'CREATE COLUMN VIEW "_SYS_BIC"."MyDB/TEAM_EVENT" TYPE JOIN WITH PARAMETERS ( joinIndex = ...' in 112 ms 159 µs . SAP DBTech JDBC: [2048]: column store error: logical index creation error:  [2434] join index inconsistent;object=MyDB/TEAM_EVENTen
    I tried everyhing in mind but cannot solve the problem. Any idea ?

    Try
    CREATE OR REPLACE VIEW rdr_le_info_view
    AS
    SELECT l.strategic_le
    ,cun.ucn cunucn
    ,cun.date
    ,cccs.ucn ucn
    ,cccs.agr_num
    FROM strat_le l
    ,ucn_name cun
    ,customer_setup cccs
    ,cccs.run_num run_num
    WHERE l.gfa_until_dt = '31-dec-9999'
    AND l.glas_until_dt = '31-dec-9999'
    AND l.int_until_dt = '31-dec-9999'
    AND cccs.ucn_lead_office = cun.ucn
    AND cun.OID = l.client_oid;Then call it like:
    select *
    from rdr_le_info_view
    where run_num = v_run_num;

  • Error while creating Materialized View step 3 of 6 using wizard

    have oracle 9i Rel 1 on Windows 2000 server. Master Site has been setup. Database links are created at Materialized view site. But while creating Materialized View Group using wizard there is following error on step 3 of 6.
    Statement:----------------
    /*OracleOEM*/ SELECT 1 FROM SYS.dba_constraints@masterdbname WHERE OWNER='username' and table_name='tabname' AND constraint_type='P'
    Stack Trace:----------------
    ORA-00942: table or view does not exist.
    ORA-02063: preceding line from masterdbname.
    All parameters for replication are correct.
    Please help me early.
    Thanks

    Hello,
    In the masterdbname, logging as sys user, you must grant select permission on sys.dba_constraints view to mvadmin_dbname user (where dbname is the replicated database name).
    Regards,

  • Error while creating Materialized View step 3 of 6

    I have oracle 9i Rel 1 on Windows 2000 server. Master Site has been setup. Database links are created at Materialized view site. But while creating Materialized View Group there is following error on step 3 of 6.
    Statement:----------------
    /*OracleOEM*/ SELECT 1 FROM SYS.dba_constraints@masterdbname WHERE OWNER='username' and table_name='tabname' AND constraint_type='P'
    Stack Trace:----------------
    ORA-00942: table or view does not exist.
    ORA-02063: preceding line from masterdbname.
    All parameters for replication are correct.
    Please help me early.
    Thanks

    Hello,
    In the masterdbname, logging as sys user, you must grant select permission on sys.dba_constraints view to mvadmin_dbname user (where dbname is the replicated database name).
    Regards,

  • Creating a view for a datasource

    Hi experts,
    I'm kinda new in BW and ABAP, but I have a requirement to get a datasource that contains data between SAP Tables. The scenario should be like this :
    1. Get all Personal Number from PA9038 (Customized Infotype) within a period ( ENDDA & BEGDA as the parameters )
    2. Get only the last Cost Center each person has from PA0001-KOSTL
    3. Get only the last Assessment Value from PA9040 (Customized Infotype)
    Is there any way to create a view based on that scenario? I've tried using the create view via SE11 and I was confused about joining the tables to get only the last data from PA0001 and PA9040.
    Or is there any method to build a Fact Table that contains the data I need?
    PS:
    Actually if I used ABAP Commands, I can generate this data in Internal tables and joining them into one internal tables.
    Probably the ABAP Codes are like this :
    SELECT pernr endda begda
       FROM pa9038
       INTO   CORRESPONDING FIELDS OF TABLE itab1.
    IF NOT itab1[] is initial.
       SELECT pernr endda begda kostl
           FROM pa0001
              FOR ALL ENTRIES IN itab1
           INTO   CORRESPONDING FIELDS OF TABLE itab2.
    *For getting the last record I can manipulate the data in itab2 like this
    SORT itab2 BY pernr ASCENDING endda DESCENDING begda DESCENDING.
    DELETE ADJACENT DUPLICATES FROM itab2 COMPARING pernr.
    ENDIF.
    LOOP AT itab1.
        READ TABLE itab2.
    ...... and so on.
    ENDLOOP.
    Thanks for the help...

    Hi Febrain,
    Identify the base tables from where you can fetch the data from. Then Using those tables you create a VIEW. Using the view you create a generic Datasouce.
    Please use this url for more info..
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/3f/548c9ec754ee4d90188a4f108e0121/content.htm
    Regards

  • Create a view with parameter

    it's posible create a view with parameters?
    i want to create a view and pass it parameters, in the same way when i create a procedure or function.
    i never have seen it, but i would like to know if that's posible
    thanks

    You cannot create a view with parameters. The only way is to use a stored proc to dynamically create the sql statement. The substitution variable approach does not work. SQL*Plus will prompt for the value of the variable at compile time (i.e. when you create the view) and use the value you provide in the view's query.
    SQL> create or replace view jws_test_v as
      2  select * from jws_test where flag = '&flg'
      3  /
    Enter value for flg: AA
    old   2: select * from jws_test where flag = '&flg'
    new   2: select * from jws_test where flag = 'AA'
    View created.
    SQL> select * from jws_test_v
      2  /
    no rows selected
    SQL> select text from user_views where view_name = 'JWS_TEST_V'
      2  /
    TEXT
    select "LEV1","LEV2","LEV3","LEV4","LEV5","LEV6","FC","FLAG","ONAFT","ONAPT","CU
    PEFT","CUPEPT" from jws_test where flag = 'AA'This makes sense, since substitution vartiables are a sqlplus construct, not a sql or Oracle construct. A view constructed in this way would not be callable from anywhere other than sqlplus.

  • Can AnyOne Explain Parameterized View with Example

    Explain the parameterized view with example

    Cathrin wrote:
    Hi ,
    I have created a view...
    CREATE OR REPLACE VIEW V_UNITS_UNITMOVEMENT_AMTEST(fromdate varchar,todate varchar)
    ... 127 more lines (no kidding)
    Group By A.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 parenthesis
    what should i do?First, indent your code to show the extent of structures that extend over several lines, such as subqueries, 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 the same 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 of formatted text, to preserve spacing.
    Note that "ORA-00907: missing right parenthesis" doesn't always mean you have unbalanced parentheses.  Often, it just means that something (such as an Oracle keyword) appears at a point where it doesn't make sense, but where a ) would make sense.
    Second, develop code in very small increments.  Take baby steps. Start with a very small, simple query, test it, then add one or two more lines.  When you get a mysterious error like "ORA-00907: missing right parenthesis", chances are there was a mistake in the one or two lines you just added.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to Create a View of a Query and assign it into my web template?

    Hi All,
    I need to create 3 views for my query and show that on my web template. I have never done this before. Can you please let me know step-by step procedure to create views for a query and how to show it on my WAD report?
    Thanks,
    Satyam

    Hi Satyam,
    Include the Dropdown Box web item in your web template. In the Web Item Parameters tab, select the Data Binding type as Query View Selection. Assign the Dataprovider from Selection of Query Views button below the Data Binding Type. You also have the option to Display Specific list of Query Views or all views based on that Query. For this you have to choose Selection of Query Views button. Here you can turn on Specific List of Query Views checkbox and select the Views depending on your requirement.
    Regards,
    Hari.
    Edited by: Hari Krishnan K on Aug 18, 2010 2:33 PM

  • Error Creating Materialized View With a Job

    Oracle 9ir2
    I've created a job like this in a java class:
    ...Java Code ...
    cs = conn.prepareCall ("DECLARE v_job NUMBER; BEGIN DBMS_JOB.SUBMIT(v_job,'begin CTH_REGENERA_VM; end;', TRUNC(SYSDATE+1) + (3/24)); END;");
    ...Java Code ...
    The Procedure called in the Job:
    CREATE OR REPLACE PROCEDURE CTH_REGENERA_VM
         AUTHID CURRENT_USER IS
         existe NUMBER(1);
         cur BINARY_INTEGER := DBMS_SQL.OPEN_CURSOR;
         fdbk BINARY_INTEGER;
    BEGIN
         SELECT count(*) INTO existe FROM user_mviews WHERE mview_name = 'CTH_PRESENTA_A_VM';
         IF existe > 0 THEN
              DBMS_SQL.PARSE(cur, 'DROP MATERIALIZED VIEW CTH_PRESENTA_A_VM', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
              INSERT INTO CTH_HISTORIAL VALUES('ELIMINADA VM CTH_PRESENTA_A_VM', SYSDATE);
              COMMIT;
         END IF;
         DBMS_SQL.PARSE(cur, 'CREATE MATERIALIZED VIEW CTH_PRESENTA_A_VM
         TABLESPACE DAT1_CTH
         STORAGE(INITIAL 16M NEXT 8M MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0)
                   XMLTYPE XML STORE AS CLOB (           TABLESPACE DAT1_CTH
                   STORAGE(INITIAL 16M NEXT 8M MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0))
         AS select FICHA, XML,
         extractvalue(xml, ''/FICHE/Encab_de_nombre_geogr�fico_a'') as MUNICIPIO,
         extractvalue(xml, ''/FICHE/Encab_de_nombre_geogr�fico_c'') as CALIFICACION,
         extractvalue(xml, ''/FICHE/Encab_de_nombre_geogr�fico_b'') as PROVINCIA,
         extractvalue(xml, ''/FICHE/Encab_tem�tico_de_materia_a[1]'') as MATERIA,
         extractvalue(xml, ''/FICHE/Fecha_cronol�gica_b[1]'') as FECHA,
         extractvalue(xml, ''/FICHE/Datos_matem�ticos_a[1]'') as ESCALA
         from cth_xmltable', DBMS_SQL.NATIVE);
         INSERT INTO CTH_HISTORIAL VALUES('ASIGNO EL PARSE DE MATERIALIZED', SYSDATE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('EJECUTO EL PARSE DE MATERIALIZED', SYSDATE);
         INSERT INTO CTH_HISTORIAL VALUES('CREADA VM CTH_PRESENTA_A_VM', SYSDATE);
         DBMS_SQL.PARSE(cur, 'CREATE INDEX CTH_INDEX1
         ON CTH_PRESENTA_A_VM(XML)
         INDEXTYPE IS CTXSYS.CONTEXT
         PARAMETERS (''storage cth section group ctxsys.auto_section_group'')', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('CREADO INDICE ORACLE TEXT CTH_INDEX1', SYSDATE);
         DBMS_SQL.PARSE(cur, 'CREATE INDEX CTH_IDX_MUNICIPIO3
              ON CTH_PRESENTA_A_VM(UPPER(MUNICIPIO))
              TABLESPACE IDX1_CTH
              STORAGE (INITIAL 1M NEXT 512K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0)', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('CREADO INDICE CTH_IDX_MUNICIPIO2', SYSDATE);
         DBMS_SQL.PARSE(cur, 'CREATE INDEX CTH_IDX_FICHA2
         ON CTH_PRESENTA_A_VM
         (FICHA)
         TABLESPACE IDX1_CTH
         STORAGE(INITIAL 1M NEXT 512K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0)', DBMS_SQL.NATIVE);
         fdbk := DBMS_SQL.EXECUTE(cur);
         INSERT INTO CTH_HISTORIAL VALUES('CREADO INDICE CTH_IDX_FICHA2', SYSDATE);
         DBMS_SQL.CLOSE_CURSOR(cur);
    COMMIT;
    END;
    I got always an error in the created materialized view. If I call the procedure with SQL Plus, it run ok. The user
    has CTXAPP, DBA roles, so I supouse it is not a privileges problem. I also tried to create a simple materialized view or a table, and always got an error ora-12011
    Thanks in advance.

    If I call the procedure with SQL Plus, it run ok. Are you using the same user to run it in SQL*Plus as runs it from Java.
    The normal reason for procedures to fail like this is privileges. Particularly, we cannot run procedures using privileges we have been granted through roles.
    The user has CTXAPP, DBA roles, so I supouse it is not a privileges problem. Try granting the system privilege CREATE MATERIALIZED VIEW to the user and see what happens.
    I drop the materialized and create again, cause it's the fastest way I've found. With a DBMS_MVIEW.REFRESH is too slow.I find that surprising as drop & create has to do all the work that a refresh has to do plus some more - maybe it's something to do with XML. Did you try adding a snapshot log and going for FAST? I don't know whwther the XML procesing would render the view complex - have you explained it?
    Cheers, APC

  • Parameterized Views for User Reports

    I would like to be able to define a view such as:
    create view dept_emps(p_dept in varchar2) as
    select * from emps where dept = p_dept);
    and use this view to define a SQL Dev drilldown report with SQL such as:
    select * from dept_emps(:DEPT)
    where :DEPT is a bind variable passed from a selected depts report row.
    Oracle apparently does not support parameterized view definitions as suggested above, but I have found an article by Tom Kyte on the issue of parameterizing views, where Tom suggests using DBMS_SESSION.SET_CONTEXT (called within a user package) to set context values that can be retrieved in a view using the SYS_CONTEXT function. I can get this approach to work at the SQL prompt to work around the lack of formal view parameters. I have a package which defines a procedure which sets context values that I can then retrieve within a view using the SYS_CONTEXT function.
    To use this approach when defining a SQL Developer user report, the SQL for the report would need to be logically something like (which works fine at an SQL prompt):
    exec ssuper_context.set_ctx('DEPT', :DEPT) - - Call user procedure to assign context variable 'DEPT' with bind value from parent report
    select * from dept_emps
    where view dept_emps uses function SYS_CONTEXT to return the value for context variable 'DEPT'.
    SQL Developer complains about this as the SQL for a user-defined report. Can anyone suggest how I might pass a bind value from a selected parent record to a view which implements a drilldown report?
    TIA Jon

    I met CSI at a kongress a few weeks ago and pressed them a bit on how this works. Eventually they fezzed up about the table read but mentioned that in the next release being developed it would be different...
    Problems with this is that the FM has a couple of limitations, so you cannot read all tables correctly... so you end up reading some of the wrong ones or taking the easy ones.
    Another option is to let the database itself do the hard work, to get back to the performance aspect.
    Anyway, for neither of these two do you need any tcode, so indeed we are drifting off topic...

  • GP Design Time - what is the purpose of 'Create Object View' option?

    We are running EP 7.01.  When I am in the GP Design Time, and I click on the 'Create Object View' link, I receive the following error:
    The initial exception that caused the request to fail, was:
       java.lang.NullPointerException
        at com.sap.caf.eu.gp.ui.bo.VCreateBasicData.wdDoInit(VCreateBasicData.java:103)
        at com.sap.caf.eu.gp.ui.bo.wdp.InternalVCreateBasicData.wdDoInit(InternalVCreateBasicData.java:159)
        at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.doInit(DelegatingView.java:61)
        at com.sap.tc.webdynpro.progmodel.controller.Controller.initController(Controller.java:215)
        at com.sap.tc.webdynpro.progmodel.view.View.initController(View.java:445)
        ... 55 more
    What is the purpose of the 'Create Object View' option?  I cannot find it in the documentation.

    Hi Karen,
    The Object Types are used to define the Parameters for the Callable Objects. We Can create the Object Views for the CAF Core Entity services or UME Pricipal Objects such as Users,Roles Groups etc. While creating the Object View we can select either of these and then we can create a view i..e. Select the required attributes from those Business Objects i.e. Entity Services or the Principals. Once we create the Object View, we can use them to define the Parameters for the callable Objects. While defining the parameters for Callable Objects, if you click the dropdown for 'Type', you'll see an entry 'Reference to BO'. If you select the entry, you'll see the list of Object Views you have created and you can select the Object View you want for defining that parameter. In short it means that you can create the Obect Views for the BOs i.e. CAF core Entity services and Pricipals. And then you can define the parameters for the Callable Objects with type 'Refence to BO' pointing to your object views.
    [further Info|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/44/051d496d9c5922e10000000a155369/frameset.htm]
    [Some more Info|http://help.sap.com/saphelp_nw70ehp1/helpdata/en/44/051d496d9c5922e10000000a155369/frameset.htm]
    Regards,
    Ajay

  • Parameterized views

    Hello,
    I currently have a pretty nasty query involving hierarchial subqueries which I reuse multiple times in my application. I would like to store this query in the database as a view so that my code would be more modular. Is there a way to create a parameterized view in the database? Thanks for your help.

    Heya all!
    I think this solutions wont perform because they involve PL/SQL.
    I had the same problem some time ago and the point is that
    .) the PL/SQL engine will be called a really often
    .) the optimizer wont recognize the constant value (i think you will need it for the start-with-clause), i tested this issue with an early 10g version btw
    My Solution, create a system context. I am working with this solution for some years and did not notice any disadvantages.
    You can find a example here [sys_context example|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_5002.htm#sthref5947] (scroll down to the examples.
    What you need to do is to define a package that controls the context (put thingies in), after creating context and packager your code would look like that:
    View:
    CREATE OR REPLACE VIEW V_MY_TEST_VIEW AS
    SELECT LPAD(E.SURENAME,LENGTH(SURENAME)+LEVEL-1,'-'),
    E.SURENAME,
    E.FIRST_NAME,
    E.EMPLOYEE_NO,
    E.STATUS,
    E.INSTRUCTOR,
    E.POS_NR
    FROM EMPLOYEES E
    WHERE 1=1
    START WITH E.EMPLOYEE_NO = SYS_CONTEXT('myContext','Employee')
    CONNECT BY PRIOR E.EMPLOYEE_NO = E.INSTRUCTOR_NO
    Package Call:
    EXEC MY_CTXT_CONTROL_PCK.SET_EMPLOYEE('ROGERROGER');
    finally....:
    SELECT * FROM V_MY_TEST_VIEW;
    I had to translate the view-names and columns and so i also could not test it, so apologize any typos or errors.
    If you have any questions just ask!

  • Create DB view  to hold all header sales document data

    hi dear
    i want Create DB view  to hold all header sales document data on the following tables:
    VBAK, VBKD, VBUK, KNA1 as follow:
    FROM VBAK:
    Sales Document
    Created on
    Time
    Created by
    Doc. Currency
    Division
    Sales Group
    Sales Office
    FROM VBKD:
    Price group
    Customer group
    Sales district
    Price List
    Incoterms
    Payt Terms
    FROM VBUK:
    Overall status
    Totals status
    Pricing
    Document cat.
    Document object
    FROM KNA1:
    Name
    Name 2
    City
    Postal Code
    Govern.Code
    Search term
    Street
    Telephone 1
    Fax Number
    One-time acct
    Address
    2. i want also Select and display all data from that view  from program code, sales order will be the only parameter.
    Any pointers in this regard are very much helpful.
    Regards
    Waseem Hesham

    Hello
    SE11 -> View -> Create -> Database view
    In column TABLES:
    VBAK
    VBKD
    VBUK
    KNA1
    Join conditions:
    VBUK-MANDT = VBAK-MANDT
    VBUK-VBELN = VBAK-VBELN
    VBAK-MANDT = VBKD-MANDT
    VBAK-VBELN = VBKD-VBELN
    KNA1-MANDT = VBAK-MANDT
    KNA1-KUNNR = VBAK-KUNNR
    View fields:
    MANDT VBAK MANDT
    VBELN VBAK VBELN
    ERDAT VBAK ERDAT
    ERZET VBAK ERZET
    ERNAM VBAK ERNAM
    ... ENUMERATE HERE ALL FIELDS YOU NEED
    Save and activate.
    Then in programm:
    tables: z_your_view.
    data: itable like z_your_view occurs 0.
    parameters: p_vbeln like vbak-vbeln.
    select * from z_your_view into table itable where vbeln eq p_vbeln.
    anything do with data .....

Maybe you are looking for

  • Updating Database From csv File in Web Dynpro Java

    Hi Gurus, I'd like to write an WDJ where the (super-)user can upload a csv file and delta-update the content of this file witch an external database. Could you please give some me hints & examples. Thanks in advance, Farid ps. answers will be rewarde

  • How can I add the date next to time in menu bar?

    Hi, I'd like to see today's date next to the "time" on the right-hand side of the menubar. I called Apple tech support twice about it and no one could help. The last guy suggested I post the question here, and someone might know of a third-party app.

  • Recommended color calibrator/monitor calibration tool?

    Hi all, It is a few years since I have purchased a color calibrator for my monitor and need to purchase a new one now at the new company I am at. It will be for my 30" Apple Cinema Display. As usual, I always come straight to these forums for your ad

  • Weblogic Server Startup issue

    Hi All, Initially I started the server, and then created around 2 Connection Factories & 2 Data Sources. Also 2 JMS Server & a JMS Store. Then I deployed my application successfully on the server. Then I undeployed the application and stopped the ser

  • Recurrent near-freeze every week

    For months now, I've been experiencing a troubling near-freeze once a week. It occurs every Friday between 2 and 2:30 PM ET and lasts about 30 minutes. During that freeze, I lose all control of the iMac. At the time, I am running Safari 4.0.5, Mail,