How to wrap a view in oracle

Does any one know how to wrap a view in Oracle, I know it is not possible, yet. Are there any third party software to wrap the logic in the view.
Thanks,
Sanjay

Your best bet is to write a view that queries the source tables and contains any necessary business logic
CREATE VIEW VBASE AS SELECT A.COLUMN_A FROM TABLE_1 A, TABLE_2 B, TABLE_3 C WHERE A.ID = B.ID AND B.ID = C.ID;
create a view for exposure to the user that queries the base view.
CREATE VIEW VSECURE AS SELECT COLUMN_B FROM VBASE;
and grant privileges to VSECURE.
GRANT SELECT ON VSECURE TO SECURE_USER;
This will allow the user to see, query, and describe VSECURE without seeing the definition for VBASE.
The advantage of the this approach is that the query engine can still push predicates down into the base view to optimize the performance or the query where as this is limited with the pipeline function and can become a tuning headache.
eg.
SQL> -----------------------------------------
SQL> -- create some tables
SQL> -----------------------------------------
SQL> CREATE TABLE table_1(ID NUMBER, MESSAGE VARCHAR2(100))
Table created.
SQL> CREATE TABLE table_2(ID NUMBER, message2 VARCHAR2(100))
Table created.
SQL> CREATE TABLE table_3(ID NUMBER, message3 VARCHAR2(100))
Table created.
SQL> -----------------------------------------
SQL> -- populate tables with some data
SQL> -----------------------------------------
SQL> INSERT INTO table_1
SELECT ROWNUM,
CASE
WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'HELLO there joe'
ELSE 'goodbye joe'
END
FROM DUAL
CONNECT BY LEVEL < 1000000
999999 rows created.
SQL> INSERT INTO table_2
SELECT ROWNUM,
CASE
WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'how are you joe'
ELSE 'good to see you joe'
END
FROM DUAL
CONNECT BY LEVEL < 1000000
999999 rows created.
SQL> INSERT INTO table_3
SELECT ROWNUM,
CASE
WHEN MOD ( ROWNUM, 50 ) = 0 THEN 'just some data'
ELSE 'other stuff'
END
FROM DUAL
CONNECT BY LEVEL < 1000000
999999 rows created.
SQL> -----------------------------------------
SQL> --create base view
SQL> -----------------------------------------
SQL> CREATE OR REPLACE VIEW vbase AS
SELECT a.MESSAGE,
c.message3
FROM table_1 a,
table_2 b,
table_3 c
WHERE a.ID = b.ID
AND b.ID = c.ID
View created.
SQL> -----------------------------------------
SQL> --create secure view using base view
SQL> -----------------------------------------
SQL> CREATE OR REPLACE VIEW vsecure AS
SELECT MESSAGE,
message3
FROM vbase
View created.
SQL> -----------------------------------------
SQL> -- create row type for pipeline function
SQL> -----------------------------------------
SQL> CREATE OR REPLACE TYPE vbase_row
AS OBJECT
message varchar2(100),
message3 varchar2(100)
Type created.
SQL> -----------------------------------------
SQL> -- create table type for pipeline function
SQL> -----------------------------------------
SQL> CREATE OR REPLACE TYPE vbase_table
AS TABLE OF vbase_row;
Type created.
SQL> -----------------------------------------
SQL> -- create package
SQL> -----------------------------------------
SQL> CREATE OR REPLACE PACKAGE pkg_getdata AS
FUNCTION f_get_vbase
RETURN vbase_table PIPELINED;
END;
Package created.
SQL> -----------------------------------------
SQL> -- create package body with pipeline function using same query as vbase
SQL> -----------------------------------------
SQL> CREATE OR REPLACE PACKAGE BODY pkg_getdata AS
FUNCTION f_get_vbase
RETURN vbase_table PIPELINED IS
CURSOR cur IS
SELECT a.MESSAGE,
c.message3
FROM table_1 a,
table_2 b,
table_3 c
WHERE a.ID = b.ID
AND b.ID = c.ID;
BEGIN
FOR rec IN cur
LOOP
PIPE ROW ( vbase_row ( rec.MESSAGE, rec.message3 ) );
END LOOP;
END;
END pkg_getdata;
Package body created.
SQL> -----------------------------------------
SQL> -- create secure view using pipeline function
SQL> -----------------------------------------
SQL> CREATE or replace VIEW vsecure_with_pipe AS
SELECT *
FROM TABLE ( pkg_getdata.f_get_vbase ( ) )
View created.
SQL> -----------------------------------------
SQL> -- this would grant select on the 2 views, one with nested view, one with nested pipeline function
SQL> -----------------------------------------
SQL> GRANT SELECT ON vsecure TO test_user
Grant complete.
SQL> GRANT SELECT ON vsecure_with_pipe TO test_user
Grant complete.
SQL> explain plan for
SELECT *
FROM vsecure
WHERE MESSAGE LIKE 'HELLO%'
Explain complete.
SQL> SELECT *
FROM TABLE ( DBMS_XPLAN.display ( ) )
PLAN_TABLE_OUTPUT
Plan hash value: 3905984671
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 16939 | 2365K| | 3098 (3)| 00:00:54 |
|* 1 | HASH JOIN | | 16939 | 2365K| 2120K| 3098 (3)| 00:00:54 |
|* 2 | HASH JOIN | | 24103 | 1835K| | 993 (5)| 00:00:18 |
|* 3 | TABLE ACCESS FULL| TABLE_1 | 24102 | 1529K| | 426 (5)| 00:00:08 |
| 4 | TABLE ACCESS FULL| TABLE_2 | 1175K| 14M| | 559 (3)| 00:00:10 |
| 5 | TABLE ACCESS FULL | TABLE_3 | 826K| 51M| | 415 (3)| 00:00:08 |
Predicate Information (identified by operation id):
1 - access("B"."ID"="C"."ID")
2 - access("A"."ID"="B"."ID")
3 - filter("A"."MESSAGE" LIKE 'HELLO%')
Note
PLAN_TABLE_OUTPUT
- dynamic sampling used for this statement
23 rows selected.
SQL> -----------------------------------------
SQL> -- note that the explain plan shows the predicate pushed down into the base view.
SQL> -----------------------------------------
SQL> explain plan for
SELECT count(*)
FROM vsecure_with_pipe
WHERE MESSAGE LIKE 'HELLO%'
Explain complete.
SQL> SELECT *
FROM TABLE ( DBMS_XPLAN.display ( ) )
PLAN_TABLE_OUTPUT
Plan hash value: 19045890
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 15 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 2 | | |
|* 2 | COLLECTION ITERATOR PICKLER FETCH| F_GET_VBASE | | | | |
Predicate Information (identified by operation id):
2 - filter(VALUE(KOKBF$) LIKE 'HELLO%')
14 rows selected.
SQL> -----------------------------------------
SQL> -- note that the filter is applied on the results of the pipeline function
SQL> -----------------------------------------
SQL> set timing on
SQL> SELECT count(*)
FROM vsecure
WHERE MESSAGE LIKE 'HELLO%'
COUNT(*)
19999
1 row selected.
Elapsed: 00:00:01.42
SQL> SELECT count(*)
FROM vsecure_with_pipe
WHERE MESSAGE LIKE 'HELLO%'
COUNT(*)
19999
1 row selected.
Elapsed: 00:00:04.11
SQL> -----------------------------------------
SQL> -- note the difference in the execution times.
SQL> -----------------------------------------

Similar Messages

  • How to schedule a view in oracle

    Hi,
    I want to schedule a view(creating view) that runs everyday at 8'o clock in morning. how can i do this in oracle.
    Thanks in advance

    Hi
    Sorry for last reply....!! Try like this....!!
    create a procedure like this...
    create or replace procedure dummy as
    begin
    execute immediate'create or replace view dummy1 as select * from emp';
    end;Then create a job as .....
    declare
    vJobNumber binary_integer;
    begin
    dbms_job.submit(job => vJobNumber,next_date => sysdate,interval =>'trunc(SYSDATE+1)+8/24',
    what => 'begin dummy; end;');
    dbms_output.put_line('Job number assigned: ' || to_char(vJobNumber));
    commit;
    end;KPR
    Edited by: KPR on Jul 9, 2011 11:47 AM

  • How to create a view with Oracle apps Org initialization ?

    Hi,
    How to create a view which needs Oracle apps org initialization to provide the correct data .
    The purpose of the view is to be accessed in Primavera DB via a DB link for reporting purpose.
    So how should the org be initialized so that the view returns the correct data when accessed from the remote data base using the DB link?
    EX: step1 run fnd_client_info.set_org_context for the org
    step2 query the veiw returns correct data in Oracle.
    How can this be achieved if the view needs to be accessed via DB link?
    sample view sql :
    select po_header_id
    from po_distributions_all pod
    where (apps.po_intg_document_funds_grp.get_active_encumbrance_func
    ('PO',
    pod.po_distribution_id
    ) <> 0
    Thanks in advance!
    Darshini

    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

  • How to Register a View in Oracle Applications

    Hi,
    I have created a Custom View and want it to see it in one of the BPA Pages. For this purpose I shall need to register the view in Oracle Applications.
    Can you please provide me clues to do so. I tried the Application Developer responsibility, there I can only query the view and not register them.
    Also if I try using backend I could get hold of Package AD_DD which registers a table. Any clues for registering the View would be welcome.
    Thanks

    Thanks for your response.
    Actually I need to show Sales Order Line No, Federal Id and a few other Fields on our Invoice. Now these are not available in Oracle Recievables view. So I was trying to create my own View.
    I created a View in database. Now I am trying to create a Data source and associate this (custom created) View to it. However my View is not showing in the Views List of Values.
    I am not sure whether I am doing it right. Can you please help me with this. Any pointers to a document which explains my requirement would be great.
    Thanks
    Sumit

  • How to create sub views in Oracle SQL

    I am trying to write a select statement through TOAD that needs to build a view and then query from that view further in the same statement. I don't mean create a VIEW in the common sense of running a CREATE VIEW command, I mean creating one dynamically within an SQL statement. Here's what I mean - in DB2 sql I can write the following:
    WITH COUNT_NUM
    COUNT_ADS
    AS
    (SELECT
    COUNT(AD_ID)
    FROM AD
    WHERE CONTRACT_ID = '000234123'
    SELECT * FROM COUNT_NUM;
    Obviously this is a real simple example but you get the idea. Using this syntax you can create numerous sub-views to build data into your final select. My question is how to do this for Oracle. I have searched tons of help pages and sites but the only reference is to creating permanent views. I do not want to create temporary views either as I do not have adequate system permissions - I only want to create dynamic ones within my SQL.
    Thanks in advance for any help!

    In Oracle, the equivalent concept is known as an in-line view. The Oracle version of your statement is:
    SELECT *
    FROM (SELECT COUNT(AD_ID) count_ads
          FROM AD
          WHERE CONTRACT_ID = '000234123')Essentially, you can use an in-line view anywhere you would use a "real" view or a table, so the follwoing is also possible:
    SELECT a.contract_id, a.count_ads, b.count_pages
    FROM (SELECT contract_id,ad_id,COUNT(*) count_ads
          FROM ad
          GROUP BY contract_id,ad_id) ads,
         (SELECT ad_id,count(*) count_pages
          FROM ad_pages
          GROUP BY ad_id) ad_pages
    WHERE ads.ad_id = ad_pages.ad_idHTH
    John

  • How to create materlised view in oracle 10g what are the step to create it

    hi,
    this hafeez i have a database in oracle 10g now i want to create materlised view to the database what arre the step required for it.

    You should refer to documentation for more information:
    [Overview of Materialized Views|http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/schema.htm#CNCPT411]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • How to deal with views ?

    Hello,
    How to deal with views and Oracle Lite ?
    Do I have to package views ? Of course, no updatable...
    How do you manage to use views in your win32 app and Olite ?
    Thanks

    I upgrade to 5.0.2.10.0, now I see a new tab in packager wizard where I can add views or indexes to application, but when connecting to import views, the wizard doesn't show views only indexes of the schema of my database...
    Why ???

  • How to maintain Entries for VIEWS in ORacle Sql developer

    hi gurus,
    Could you please help in maintaining an entries for VIEW is Oracle SQL develope...I have created a VIEW by name SD_WH08....now i need to maintain some entries in this for my testing purpose...how do i do this?
    Your help is very much appreciated.
    Regards

    What do you mean by "maintaining an entries for VIEW" ?
    K.

  • How to Export Snapshots and Materlized View in Oracle 9i

    Hi,
    How to Export Snapshots and Materlized View in Oracle 9i .
    I require to Migrate from 9i to 10g with either Export or Script.
    Please help

    Using exp-imp for snapshots generally causes problems, at least for me. I would prefer taking their creation scripts and running them on the new database.
    By the way, what do you mean by "migrate from 9i to 10g"? Are you trying to create the same snapshots in another (10g) database or are you trying to upgrade your 9i database to 10g? If it is the latter then you can just upgrade the database automatically with the upgrade assistant or manually using upgrade scripts.

  • Help: How to open wrapped store procedure on oracle database

    Dear Gurus,
    how to open the wrapped store procedure on oracle database?
    anyone can help me...?
    reply me soon
    take care

    Any other way so that I can see the flow of data that written on wrapped store procedure?You need to see the source code which has keeped outside of database. Read a wrapped code is not common for humans...
    reply me asap If you want an asap answer, raise a SR for oracle support, not through a forum which is based on volunteers.
    Nicolas.

  • How to handle EXTENDED Views  SQL 2000 to Oracle Migration

    Hi All,
    I am in the process of migrating SQL server 2000 database to Orcle databse. I would like to know how to handle the views created in SQL server with Extended clause.
    See below for example for SQL 2000 view.
    create view "Order Details Extended" AS
    SELECT "Order Details".OrderID, "Order Details".ProductID, Products.ProductName,
         "Order Details".UnitPrice, "Order Details".Quantity, "Order Details".Discount,
         (CONVERT(money,("Order Details".UnitPrice*Quantity*(1-Discount)/100))*100) AS ExtendedPrice
    FROM Products INNER JOIN "Order Details" ON Products.ProductID = "Order Details".ProductID
    Thanks in advance for your reply.
    Ramesh

    Ramesh
    The Workbench has a problem with spaces in identifiers which will be fixed in a later release.
    Apart from that large drawback the view should work ok. [The parser handles convert and aliases]
    Turloch

  • How to Call Image Viewer from Form application

    Hi,
    how to call Image viewer using host command on oracle form 6i.
    i trying using host command on local/client application .. and it is working ...
    but when i try on server application (EBS - UNIX) it does not working ...
    thanks ..
    regards,
    safar

    Are you using Forms 6i in client/server mode or web deployed? I'm not sure what you mean by 'try on server application"
    Remember that when using a web deployed architecture, a host command will execute the command on the Forms application server, NOT on the client.
    To execute host commands on the client you would have to use WebUtil, but that's not available for Forms 6i. Perhaps there are PJC's out there that can do it for you, but I don't want to get in all those details without me knowing if it is relevant for you.

  • How to Use Transient View Objects to Store Session-level Global Variables

    hi
    Please consider section "40.8.5 How to Use Transient View Objects to Store Session-level Global Variables"
    at http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcstatemgmt.htm#ADFFD19610
    Based on this documentation I created the example application
    at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.01.zip
    It behaves as show in the screencast at http://screencast.com/t/qDvSQCgpvYdd
    Its Application Module has a Transient View Object instance "MyEmployeesContextVOVI", as master for the child View Object instance "EmpInCtxJobVI".
    On rollback the Transient View Object instance keeps its row and attribute values.
    Also when passivation and activation is forced (using jbo.ampool.doampooling=false ) the Transient View Object instance seems to keep its row and attribute values.
    questions:
    - (q1) Why does the expression #{bindings.MyEmployeesContextVOVIIterator.dataControl.transactionDirty} evaluate as true when a Transient View Object instance attribute value is changed (as shown in screencast at http://screencast.com/t/qDvSQCgpvYdd )?
    - (q2) What would be a robust approach to make a Transient View Object instance more self-contained, and manage itself to have only one single row (per instance) at all times (and as such removing the dependency on the Application Module prepareSession() as documented in "5. Create an empty row in the view object when a new user begins using the application module.")?
    many thanks
    Jan Vervecken

    Thanks for your reply Frank.
    q1) Does sample 90 help ? http://blogs.oracle.com/smuenchadf/examples/
    Yes, the sample from Steve Muench does help, "90. Avoiding Dirtying the ADF Model Transaction When Transient Attributes are Set [10.1.3] "
    at http://blogs.oracle.com/smuenchadf/examples/#90
    It does point out a difference in marking transactions dirty by different layers of the framework, "... When any attribute's value is changed through an ADFM binding, the ADFM-layer transaction is marked as dirty. ...".
    This can be illustrate with a small change in the example application
    at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.02.zip
    It now shows the result of both these expressions on the page ...
    #{bindings.MyEmployeesContextVOVIIterator.dataControl.transactionDirty}
    #{bindings.MyEmployeesContextVOVIIterator.dataControl.dataProvider.transaction.dirty}... where one can be true and the other false respectively.
    See also the screencast at http://screencast.com/t/k8vgNqdKgD
    Similar to the sample from Steve Muench, another modification to the example application introduces MyCustomADFBCDataControl
    at http://www.consideringred.com/files/oracle/2010/ProgrammaticalViewObjectAndRollbackApp-v0.03.zip
    public class MyCustomADFBCDataControl
      extends JUApplication
      @Override
      public void setTransactionModified()
        ApplicationModule vApplicationModule = (ApplicationModule)getDataProvider();
        Transaction vTransaction = vApplicationModule.getTransaction();
        if (vTransaction.isDirty())
          super.setTransactionModified();
    }Resulting in what seems to be more consistent/expected transaction (dirty) information,
    see also the screencast at http://screencast.com/t/756yCs1L1
    Any feedback on why the ADF Model layer is so eager to mark a transaction dirty is always welcome.
    Currently, question (q2) remains.
    regards
    Jan

  • How to wrap the text in column headers?

    Hi Friends,
    Can anyone please suggest how to wrap the text in column headers of a Java WebDynpro table?
    I believe that caption is the only UI element that a column header can have and it does not allow wrapping of the text.
    My original requirement is as follows,
    In a table I need to dynamically set the width of the columns according to the width configured by the user in some other view. All the columns of the table are dynamically rendered.
    Now what happens is when the user sets the width of the column to a rather low value, say 15 pixels, then the column is displayed like
    Supplier Catalog Name
    Sheila
    Catalog
    Name
    Dropdown
    As you can see it looks rather odd.
    Supplier Catalog Name is the header of the column and I use IWDCaption for header.
    Sheila Catalog Name Dropdown is the value of a particular row at the specified column. I am using a TextView as the TableCellEditor.
    I think what is happening here is that the framework wraps the text in the TextView according to the width specified (15px) and then the column width is extended because it can not accommodate the text (Supplier Catalog Name ) of the column header.
    We are using SAP NetWeaver Development Studio 7.0.12 as the IDE.
    I searched some forums and many people have suggested using scrollable columns but I don't understand how it will help in wrapping the text in a column header.
    Any help would be of great advantage.
    Thanks
    Amit

    Hi Deepti,
    Thanks a lot for the answer but the option that you have specified does not wrap the text. Instead it truncates the text being displayed and only the substring of the text which could be displayed in the given pixels is displayed.
    I need to show the whole text wrapped (Meaning if the width of the column is not sufficient then the text goes into the next line).
    Ayyapparaj,
    Thanks to you too for an helpful answer. It seems that the Netweaver has finally come up with a way to wrap the text in the column headers but as Manoj pointed out, I do not see the property headerTextWrapping  for a table column, Can you please specify which version of netweaver supports it?
    We are using SAP NetWeaver Development Studio 7.0.12 as the IDE.
    Thanks
    Amit Kapoor

  • How can i select view attribute in a method

    hi how can i select view attribute in method and pass that attribute to procedure
        public void DeleteAgr(Integer agrid) {
                     ViewObject svo = this.findViewObject("AGR");
                     //select current view id from agr and link id with agrid          
                    callPerformSdmsLogon("SMS_FORM_TO_ADf.delete_agr(?)", new Object[] { agrid });
    }Edited by: Tshifhiwa on 2012/06/30 1:01 PM
    Edited by: Tshifhiwa on 2012/06/30 1:22 PM
    Edited by: Tshifhiwa on 2012/06/30 1:24 PM

    hi i use your sample but now am geting this errror (oracle.jbo.JboException) JBO-29000: Unexpected exception caught: java.lang.NullPointerException, msg=null
    ----- Level 1: Detail 0 -----
    (java.lang.NullPointerException) null check the code below
                              public String getCurrentagrid(String currentagrId) {
                            if (currentagrId != null && currentagrId.length() > 0) {
                                ViewObjectImpl agrVO =
                                    this.getAGR1();
                                if (agrVO != null) {
                                    Key key = new Key(new Object[] { currentagrId });
                                    //Searching for the row with key
                                    //getRow(key) will search in the cache which contain atmost
                                    //2000 records Becoz the MaxFetchSize of EmpVO is 2000
                                    AGRRow agrRow =
                                        (AGRRow)agrVO.getRow(key);
                                    //if the record with key is not present in the cache
                                    if (agrRow == null) {
                                        //Searching for the row with key in the DataBase
                                        //findByKey() searches in DB
                                        Row[] agrRows = agrVO.findByKey(key, 1);
                                        if (agrRows != null && agrRows.length != 0) {
                                            //agrRows = (AGRRow)agrRows[0];
                                    if (agrRow  != null) {
                                        //currentagrId = (String)agrRow.getAttribute("id");
                                        //agrVO.executeQuery();
                                        //agrRow = agrVO.first();
                                        callPerformSdmsLogon("SMS_FORM_TO_ADf.delete_agr(?)", new  Object[] { currentagrId });
                            return currentagrId ;
                        }Edited by: Tshifhiwa on 2012/07/01 10:51 AM
    Edited by: Tshifhiwa on 2012/07/01 11:38 AM

Maybe you are looking for

  • Photoshop improvements. Disappointment at Adobe.

    Hi! All you know about recent Adobe decision to move to CC bussiness model. "Do less, charge more", good implementation of this principle. Before I was Adobe fan and I sincerely wanted to help them improve their products, I thought they want too. I c

  • Breakpoints in nested classes don't work

    I've noticed that when I set a breakpoint in a nested class, it doesn't work to stop the code, unless I set the breakpoint after I've created an instance of the class. In the code example below, if I set breakpoints A, B, C and D, only breakpoints A

  • How do I stop the "remember password?" pop-up whenever I log into a website?

    "Remember password for "ericbell" on mozilla.com?" - how do I keep this from happening at all for all sites?

  • Microsoft Wireless Laser Mouse 5000

    I unwrapped a new MS Wireless Laser Mouse 5000. It appears to have a plastic wrap on the top. Like the cling wrap on some electronic items. It doesn't seem to want to come off. The sides are the same texture as other MS mice. Anyone else seen this pl

  • Datatype problem in project euler

    Today I had nothing to do, so I participated in Project Euler http://projecteuler.net with Labview. I'm at question 10 now. The question itself isn't much of a challenge, but the problem I'm having is that the datatypes are to small for the value I w