Equivalent for AUTHID CURRENT_USER in view

Hi, I'm facing a problem with a view which belongs to user a and I would like to select tables from user b.
Exemple :
user a - table MYTAB
user b - table MYTAB
done by user a : "create or replace view MYVIEW as select * from MYTAB"
grants and synonyms done for both users
if I execute from user b : "select * from MYVIEW", I get the data from a.MYTAB, not b.MYTAB
What can I do to force MYVIEW to select from current user's table ? (juste like the AUTHID CURRENT_USER for procs)
Do I have to create the view in all schemas ?
Thx in advance

I wanted exactly the same thing. It's not ideal, but here is what I did. I did it like this so that I can hide away any complexity from other users, and just give them a view that they need not worry about the internal nuts and bolts of.
It's a bit fiddly, but it goes like this.
1. In schema A, create an AUTHID CURRENT_USER package. Let's call it pkg_A.
2. Add a PIPELINED table function to pkg_A, let's call it pipe_rows. For this thread/example, into this function you put the query in question.
3. Or, you might put the query in a global, public pkg cursor. That way, you can declare a TABLE of that %ROWTYPE. A pipelined function can then return this table-type.
4. In schema B, create a view, let's call it pkg_A_pipe_rows_vw_in_B. Yes, this means creating a view in Schema-B, which we were hoping to avoid, but this is really simple, and now all the 'nuts and bolts' are common, generic, and hidden away in Schema-A. This view is as simple as:-
CREATE OR REPLACE VIEW pkg_A_pipe_rows_vw_in_B AS
SELECT * FROM TABLE(pkg_A.pipe_rows);Note, this view MUST be in Schema-B, as previously pointed out, a view <b>always</b> resolves to objects in the schema into which the view is compiled. This is very confusing, given that the package being called is AUTHID CURRENT_USER.
This code demo's points 1-3.
CREATE OR REPLACE PACKAGE pkg_A
AUTHID CURRENT_USER AS
    CURSOR G_PIPE_CSR IS SELECT * FROM DUAL; -- not good eg, need tab in BOTH schemas with diff data
    TYPE G_PIPE_TABLE IS TABLE OF G_PIPE_CSR %ROWTYPE;
    FUNCTION pipe_rows
    ( param1 IN VARCHAR2 := 'DEFAULT' ) -- can pass params but not from the view in (4) so must default
    RETURN G_PIPE_TABLE
    PIPELINED;
END;
CREATE OR REPLACE PACKAGE BODY pkg_A AS
    FUNCTION pipe_rows
    ( param1 IN VARCHAR2 := 'DEFAULT' ) -- can pass params but not from the view in (4) so must default
    RETURN G_PIPE_TABLE
    PIPELINED IS
        l_pipe_row G_PIPE_CSR %ROWTYPE;
    BEGIN
        OPEN G_PIPE_CSR;
        LOOP
            FETCH G_PIPE_CSR INTO l_pipe_row;
            EXIT WHEN G_PIPE_CSR %NOTFOUND;
            PIPE ROW(l_pipe_row);
        END LOOP;
        RETURN;
    END;
END;
/As you can't pass params from the view in schema-B, what you can do is provide further 'set' procedures in the package which assign values to global vars, then use the global vars (or public 'get' functions that return the same), when you issue the query. This, again, isn't brilliant. You could set local vars based on the user-id, time of day, etc, etc, and use these in the query.
Btw, I disagree with William's point:->
For this reason invoker's rights procedures are usually best for utilities that don't do DML.>
Providing these utilities are well advertised as resolving against the CURRENT_USER's schema, this is how you can provide generic access mechanisms for like-data in disparate schemas. For example, we are client driven, client A's data is separate from client B's data, but we provide the same service to both parties. (Although, William did say "usually"!)
Regards,
Cloink.

Similar Messages

  • Does pages have an equivalent for Word's option of viewing a document in "online layout"?

    Does pages have an equivalent for Word's option of viewing a document in "online layout"?

    With online layout you can have the page of your document fill up as much of the screen as you want while being able to zoom the viewing of your text or words to any percentage you want. In pages, I can zoom or stretch the document to fit the full width of the screen, but the view the actual text or words themselves correspondingly enlarges as well.

  • Using AUTHID = CURRENT_USER and Apex

    I'm new to Apex and am just assessing if we can make use of it, mainly for reporting functionality in our existing web based application.
    We have a schema that holds all of our procedures, packages, functions etc and they all have AUTHID = CURRENT_USER so each user can have their own set of tables in their own schema.
    I want to be able to create reports in Apex that will then report on the users table in their own schema but I can't quite work out how Apex actually works. Can I tell something in Apex to use AUTHID = CURRENT_USER?
    We used Webdb many years ago and that created the runtime package for all the forms and reports but I can't see anything that Apex creates so I assume it stores all the code in a table somewhere?
    Thanks
    Robert

    Hi Scott,
    does that mean, there is no way to make these packages work? Not even with additional direct grants to apex_public_user? I am aware of the implications but we have a significant amount of code using packages with authid current user.
    Our situation:
    We have four oracle schemas involved in a multi tenant application.
    GLB : Global objects
    BEE: tenant 1
    SIX: tenant 2
    IAM: tenant 3
    Then we have the user APEX_SCM. There we store the tables and objects for the APEX application. This is the parsing schema for the application.
    During page rendering we try change the CURRENT_SCHEMA to one of the tenants:
    declare
      l_sql varchar2(2000);
    begin
      if :P42_BRAND is null then
        :P42_BRAND := 'SIX';
      end if;
      l_sql := 'alter session set current_schema=' ||:P42_BRAND;
      apex_application.debug(l_sql);
      execute immediate l_sql;
    end;Then we call a stored function returning the report result:
    select *
    from table(six.inv_val_report_pack.fn_rpt_ar_nlf(to_number(:P42_BL_INV_CHECK_ID))) t,
      apex_scm.st_sor_v s, six.ls, ar
    where s.st_sor_id(+) = t.st_sor_id
    and ls.ls_id(+) = t.ls_id
    and ar.ar_id(+) = t.ar_idThe function is in a package with invoker rights:
    create or replace package inv_val_report_pack
    authid current_user
    is
    ...Now my questions:
    1) Is there a way to make this work (using invoker rights packages)?
    2) We cannot get the name resolution to work. Does execute immediate 'alter session set current schema=SIX' work at all? It seems to be ignored.
    I ran a test in the sql workshop as the parsing schema APEX_SCM.
    declare
    l number;
    begin
      execute immediate 'alter session set current_schema=SIX';
      select null into l from ls
      where rownum=1 ;
    end;
    /It only worked after I created a local synoynm for ls in the schema APEX_SCM. Weird, it seems like 'alter session set current schema=SIX' is just plain ignored.
    Any help would be greatly appreciated, by anyone ;).
    Thanks,
    ~Dietmar.

  • Authid current_user using

    Hello,
    I have question regarding authid current_user.
    What is the disadvantages of using AUTHID CURRENT_USER for developer?
    What is the advantages of using AUTHID CURRENT_USER for dba?
    Thanks a lot,

    Hi Scott,
    does that mean, there is no way to make these packages work? Not even with additional direct grants to apex_public_user? I am aware of the implications but we have a significant amount of code using packages with authid current user.
    Our situation:
    We have four oracle schemas involved in a multi tenant application.
    GLB : Global objects
    BEE: tenant 1
    SIX: tenant 2
    IAM: tenant 3
    Then we have the user APEX_SCM. There we store the tables and objects for the APEX application. This is the parsing schema for the application.
    During page rendering we try change the CURRENT_SCHEMA to one of the tenants:
    declare
      l_sql varchar2(2000);
    begin
      if :P42_BRAND is null then
        :P42_BRAND := 'SIX';
      end if;
      l_sql := 'alter session set current_schema=' ||:P42_BRAND;
      apex_application.debug(l_sql);
      execute immediate l_sql;
    end;Then we call a stored function returning the report result:
    select *
    from table(six.inv_val_report_pack.fn_rpt_ar_nlf(to_number(:P42_BL_INV_CHECK_ID))) t,
      apex_scm.st_sor_v s, six.ls, ar
    where s.st_sor_id(+) = t.st_sor_id
    and ls.ls_id(+) = t.ls_id
    and ar.ar_id(+) = t.ar_idThe function is in a package with invoker rights:
    create or replace package inv_val_report_pack
    authid current_user
    is
    ...Now my questions:
    1) Is there a way to make this work (using invoker rights packages)?
    2) We cannot get the name resolution to work. Does execute immediate 'alter session set current schema=SIX' work at all? It seems to be ignored.
    I ran a test in the sql workshop as the parsing schema APEX_SCM.
    declare
    l number;
    begin
      execute immediate 'alter session set current_schema=SIX';
      select null into l from ls
      where rownum=1 ;
    end;
    /It only worked after I created a local synoynm for ls in the schema APEX_SCM. Weird, it seems like 'alter session set current schema=SIX' is just plain ignored.
    Any help would be greatly appreciated, by anyone ;).
    Thanks,
    ~Dietmar.

  • AUTHID CURRENT_USER

    Hi,
    What is the difference between two..
    CREATE OR REPLACE FUNCTION func_temp
    RETURN NUMBER
    AUTHID CURRENT_USER
    AS
    BEGIN
    RETURN 1;
    END;
    and
    CREATE OR REPLACE FUNCTION func_temp
    RETURN NUMBER
    AS
    BEGIN
    RETURN 1;
    END;
    Please tell me what its the use of AUTHID CURRENT_USER here.
    Thanks,
    Vinod

    By default, stored procedures and SQL methods execute with the privileges of their owner, not their current user. Such definer's rights subprograms are bound to the schema in which they reside, allowing you to refer to objects in the same schema without qualifying their names. For example, if schemas HR and OE both have a table called departments, a procedure owned by HR can refer to departments rather than HR.departments. If user OE calls HR's procedure, the procedure still accesses the departments table owned by HR.
    If you compile the same procedure in both schemas, you can define the schema name as a variable in SQL*Plus and refer to the table like &schema..departments. The code is portable, but if you change it, you must recompile it in each schema.
    A more maintainable way is to use the AUTHID clause, which makes stored procedures and SQL methods execute with the privileges and schema context of the calling user. You can create one instance of the procedure, and many users can call it to access their own data.

  • Is there a logic:match equivalent for JSTL?

    In a search page I execute a query which returns an array of objects (All objects are of the same object type and are cast to Object[]) and each object has many attributes. I tried using <logic:iterate>, but I was never successful in having it display any results. I believe this had something to do with the entire array being passed via session scope instead of just one record and me not specifying it properly with <logic:iterate>. I was able to successfully use <c:forEach> and it worked right away. I stuck with using that because of its "just works" ability in addition to using a lot of other JSTL code. However, one of the attributes that is being printed out needs to be parsed and is of the form "Yxxx". <logic:match> covers this very nicely, but when I specify it in the below code it is not able to find my variable in any scope.
    <c:forEach var="myResults" items="${sessionScope.result}" varStatus="status">
        <logic:match parameter='${myResults}' property='pin' value='Y'>
            <c:out value="Preeti"/>
        </logic:match>
    </c:forEach>I have done several google searches, but I haven't found a JSTL equivalent for <logic:match>. If there is one could someone please tell me what it is? In addition, although <logic:match> is great I still need to print out a substring of that attribute. Could someone tell me how to do that? If this is not possible could someone please tell me if its possible to use <logic:iterate> with an array of objects like I was attempting to do initially so that I could use <logic:match> at least?
    Thanks to all of you for your time.

    Yes you can use the logic:iterate tag. I think you have to specify the type of the exposed variable though. I prefer the forEach loop.
    I think you are using the wrong attribute in the logic:match tag. You should be using the "name" attribute rather than "parameter"
    Parameter attribute refers you to a request parameter, and I pretty sure you don't want that.
    So given the collection of objects in the session attribute "result"
    This should loop through them all, and see if they start with the letter 'Y'
    <c:forEach var="myResults" items="${sessionScope.result}" varStatus="status">
        <logic:match name='myResults' property='pin' value='Y'>
            <c:out value="Preeti"/>
        </logic:match>
    </c:forEach>As for the latter bit, are you using a JSP2 container and JSTL1.1? It would appear so seeing as you are trying to use EL expressions in the logic:match tag.
    If so, you could make use of the JSTL function library:
    <c:forEach var="myResults" items="${sessionScope.result}" varStatus="status">
       <c:if test='${fn:startsWith(myResults.pin, "Y")}'>
          <c:out value="${fn:substring(myResults.pin, 1, -1)}"/>
        </c:if>
    </c:forEach>And I've just spotted a very cool function in there: substringAfter
    <c:forEach var="myResults" items="${sessionScope.result}" varStatus="status">
          <c:out value='${fn:substringAfter(myResults.pin, 'Y')}'/>
    </c:forEach>Cheers,
    evnafets

  • How to set printersettings for the crystal report viewer in SAP BI dynamically

    Hello
    I have set the URL method for my crystal report and with parameter passing as shown below, it was displaying the crystal report viewer by connecting to the SAP BI 4.0 server with this method.
    http://cr:port/businessobjects/enterprise115/desktoplaunch/opendoc/openDocument.jsp?sDocName=CRLabelParam&sType=rpt&lsSnPrinted=0&lsSsTestProjectNr=1
    This URL will be called from Web application by different users, i would like to set the printer settings differently for different users for this crystal report viewer how shall i need to set the printer options?
    shall i need to set the printer settings programatically for each user. Please advise me how do i need to proceed.
    Thanks & Regards,
    Rajeswari.

    There are no BI / CR APIs that would do this for you. The way I see it, you'll have to have your own print button and populate it with the correct printer information for each user as they request the report. Of course, alternatively, use the viewer printer button and get the users to choose the correct printer.
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • Looking for a stylish pdf viewer to integrate into muse site. Any suggestions?

    Dear all,
    I am looking for a stylish pdf viewer that i could integrate into a muse theme. I am after something that will give a similar effect to the page below.
    http://adoreum.com/magazine/
    Any suggestions would be most welcome. I have heard that it is possible to do this using InDesign, is this a red herring???
    Many thanks in advance,
    Martin

    No. Not for PDF viewing. Most people will view PDFs either through an Adobe Reader or Adobe Acrobat web browser plug-in or via web browsers that have built in PDF viewers such as Google Chrome.
    What you're seeing on sites like the web site link you posted is a conversion of the PDF to another format in a "flip book" layout, a format that doesn't require the site visitor to install any plug-ins. The flip book would either be in Flash format for desktop computer browsers or HTML5 for both web browser and mobile device compatibility.
    One example is Flipgorilla: http://blog.flipgorilla.com/
    It's a free PDF to HTML5 flip book creator. They even have a Wordpress plug-in. But I'm not sure how friendly its code would be to a Muse-based web site.

  • Batch Determination in SD - Need for Material Master Classification View

    Hi!
    Is it mandatory to have the classification view of the material maintained to enable expiry date based batch determination at delivery creation?
    I have configured BD for the delivery. When testing with a material for which the classification view is maintained, the batch is determined. When testing with a material for which the classification view is <b>not</b> maintained, the batch is not determined.
    Appreciate that this may seem like a strange question given what the testing shows but I am working with a colleague who is adamant that the classification view on the material master is not required.
    Any casting votes would be much appreciated and rewarded accordingly. Thanks, Duncan

    Classification of batches is mandatory if you want to use the batch determination feature.
    source: http://help.sap.com/saphelp_erp2005/helpdata/en/4d/2b8bd043ad11d189410000e829fbbd/frameset.htm

  • How do i change the backgound color for the "file edit view history bookmark tools help" bar in Firefox 29.0

    how do i change the backgound color for the "file edit view history bookmark tools help" bar in Firefox 29.0

    You can add a solid color theme to change the color of the top of the browser window, which includes the Menu Bar.
    https://addons.mozilla.org/en-US/firefox/themes/solid

  • What is the equivalent for 'On Change of' Event in ABAP OBJECTS?

    What is the equivalent for 'On Change of' Event in ABAP OBJECTS?  and how to use it in LOOP control?

    hi,
    There is no such Equivalent in OO ABAP.
    You have to Raise your own Event within tha class checking the value of the field whose value is changing.
    Regards
    Sumit Agarwal

  • I accidently click for a full screen view on Firefox and now I can't undo it. My bar with tools, bookmarks, etc. is not visible. As the browser opens, the bar appears but then jumps up where it can't be reached. How do I turn off the full screen?

    I accidently clicked for a full screen view on Firefox and now I can't undo it. My bar with tools, bookmarks, etc. is not visible. As the browser opens, the bar appears but then jumps up where it can't be reached. How do I turn off the full screen without access to view options?

    Co-el, This wasn't possible as there wasn't a navigation bar available. The F11 did the trick though. Thanks for adding to the discussion.

  • Creating a template in Pages is straight-forward as answered here previously. Is there and equivalent for iBooks Author which can start with a blank page and build up the template as required? or can one only adapt a ready made template?

    Creating a template in Pages is straight-forward as answered here previously. Is there an equivalent for iBooks Author which can start with a blank page and build up the template as required? or can one only adapt a ready made template? This has proved unsatisfactory to me so far. Lines are left in etc.

    There are two basic menus for fonts - one from the main menu bar and one from the toolbar. You can also bring up the font manage dialog.
    I don't recommend trying to hard to force an otherwise foreign font, as it inevitably needs to be usable/supported on iOS as well, and that can get tricky w/3rd party fonts, as an example, even with the expanded font support in the latest iBA.
    If you need to discuss fonts more, I suggest starting a new thread....preferably with a slightly more brief title, thanks.

  • JBO-25048: Operation getAllRowsInRange is invalid for a working set view ob

    I'm new to JDeveloper, so please forgive my ignorance...but I'm having a problem creating a list binding in LOV mode. After placing the list of values attribute on the jsp and making changes in the List Binding Editor, I receive the following error when I try testing the page.
    JBO-25048: Operation getAllRowsInRange is invalid for a working set view object.
    Any suggestions or hints to help me on my way would be greatly appreciated. Thanks.

    You should consider switching your application to Immediate Mode. You typically should never need to manually call the sync() method.
    Here is some advice on Batch Mode versus Immediate Mode.
    http://www.oracle.com/technology/products/jdev/collateral/papers/10g/adftoystore/readme.html#batchmode
    Usually this error occurs if you attempt to work with an iterator binding before the prepareModel() method has been invoked in the DataAction lifecycle.
    When batch mode is being used, the prepareModel() method internally batches up all the calls to execute the view objects referred to by iterator bindings in the current binding container and then syncs the operations in a single round-trip with the (either logically- or physically- separated) middle-tier application module.

  • HDD Health: How to check it? HD Tune Pro equivalent for Mac?

    hi all, i was just wondering if there's a Mac equivalent for HD Tune Pro. it's a Windows app i use to check for errors on hard drives. i want to check if an externall 1TB HDD has any bad sectors on it before i use time machine to backup my work. i want something that'll check for any small error -- i don't want something that'll just do a basic scan.
    thank you         

    ThunderCon wrote:
    but there's software that can do it on Windows so there must be something on the Mac.
    DiskUtility, DiskWarrior, TechTools, Genius, etc. etc. just do a google search. Most are paid apps except DiskUtility which is already built in and can be accessed from your reinstall partition. I personally don't bother with any except DiskUtility, but do keep a copy of DiskWarrior on hand just in case.
    Developers will convince you that you need all sorts of programs to check and repair most often manufactured disc ailments, but if you are one of those happy to pay, then that is your choice.
    Good Luck
    Pete

Maybe you are looking for

  • Capture an image using the web camera from a web application

    Hi All, Could anyone please share the steps what have to be followed for capture an image using the web camera from a web application. I have a similar requirement like this, 1) Detect the Webcam on the users machine from the web application.(To be m

  • Word Web App can't open a document (corruption) but Word Desktop can

    Hi, My team and I are currently working on integrating a custom WOPI-Host and everything is going pretty good.  While testing out different documents that will be used in the system to see the supported features and the reaction of Word Web App we fo

  • How do I create an iView with multiple links to R/3 transactions

    Hello Portal developers, I'm looking for a solution for displaying multiple links on a single iView or Page.  The requirement is calling for several SAP Transactions and a link to an external web application from a single view.  Could or should this

  • Installing oracle 8i on RHEL 4

    Hi All, I did see the thread which was about RHEL 3 , should i follow up the same thread? But from the document it isnt evident what needs to be done , on top of it I got confused seeing this URL - http://www3.sympatico.ca/arothmel/oracle/817.html I

  • Reversing Accruals F.81 as a Periodic Job

    Hi Guys, We want to run F.81 , reversing the recurral entries , on a periodic basis. We want to set it as a background job and make it run periodically so that even if the users forget to run the reversals on the first of each month, this process wil