Executing APEX_INSTANCE_ADMIN inside APEX Application

Hi,
I'm having trobule when I try to execute APEX_INSTANCE_ADMIN.SET_PARAMETER from an apex application.( For further information, I'm trying to implement this Re: Changing SMTP server from Apex Application )
I have the following scenario:
1) An Oracle Schema associated to an APEX Workspace (with one application inside)
2) Oracle Schema has been granted with APEX_ADMINISTRATOR_ROLE
3) If I execute (via SQL Developer) from my Oracle Schema:
begin
   execute immediate 'ALTER SESSION SET CURRENT_SCHEMA = APEX_040100';
   APEX_INSTANCE_ADMIN.SET_PARAMETER('SMTP_HOST_ADDRESS','localhost');
end;It works fine.
4) So I put that code inside a PL/SQL Package
5) Then, I try to execute package from Apex Application, and I get:
Error:ORA-20987: APEX - User requires ADMIN privilege to perform this operation. - Contact your application administrator.What am I missing? Who is executing my package code when calling it from APEX? Do I have to grant APEX_ADMINISTRATOR_ROL to other users?
Thanks

jcoves wrote:
Hi,
I'm having trobule when I try to execute APEX_INSTANCE_ADMIN.SET_PARAMETER from an apex application.( For further information, I'm trying to implement this Re: Changing SMTP server from Apex Application )
I have the following scenario:
1) An Oracle Schema associated to an APEX Workspace (with one application inside)
2) Oracle Schema has been granted with APEX_ADMINISTRATOR_ROLE
3) If I execute (via SQL Developer) from my Oracle Schema:
begin
execute immediate 'ALTER SESSION SET CURRENT_SCHEMA = APEX_040100';
APEX_INSTANCE_ADMIN.SET_PARAMETER('SMTP_HOST_ADDRESS','localhost');
end;It works fine.
4) So I put that code inside a PL/SQL Package
5) Then, I try to execute package from Apex Application, and I get:
Error:ORA-20987: APEX - User requires ADMIN privilege to perform this operation. - Contact your application administrator.What am I missing? Who is executing my package code when calling it from APEX? Do I have to grant APEX_ADMINISTRATOR_ROL to other users?
YES
Look at this {message:id=10266929}

Similar Messages

  • Executing queries in another schema in an APEX application

    Hello all,
    I'm using Application Express 2.1.0.00.39 with Oracle Database Express.
    Following this post (Re: Including a SQL GUI in APEX applications I made a page that executes users' queries. The user inputs his SQL statement in a textarea and submits the page, then a new region returning the query results is displayed. Actually I did hardly the same as Vikas did here: http://htmldb.oracle.com/pls/otn/f?p=24317:228:4426360772935581::NO:::
    However my needs are very specific: as there will be a lot of users and all users will have their own schema, I need to execute the queries a user inputs in his own schema and not the default parsing schema.
    I looked around and found a few solutions.
    First, GRANT. But I can't grant the default schema priviledges on all users' schema. It will permit everyone to work on all schemas and I don't want that. I want to force the parsing schema to be the same as the user authentified.
    Next, I found that post: Re: how to connect to another user from a named pl/sql block. I tried the EXECUTE IMMEDIATE but it won't work with the CONNECT statement.
    Finally I found that post: Change Parsing Schema dynamically? I tried to put the ALTER SESSION in a process. The success message appears, meaning the statement was executed successfully. But the query in input is still executed in the APEX default parsing schema. Then I tried to put the ALTER SESSION statement in the Report (which is a PL/SQL function body returning a SQL query), like that:
    BEGIN
    EXECUTE IMMEDIATE 'ALTER SESSION SET CURRENT_SCHEMA=:APP_USER';
    RETURN v('P2_QRY_TEXT');
    END;
    It didn't work either.
    What should be the best practice for my problem? Is there anyway to do what I want?
    Thanks,

    Re-thinking my solution:
    Instead of having the package for each user, make 1 schema hold the package (whichever represents your system and not a user). Then declare the package to run as AUTHID CURRENT USER, which should make the calling schema's privileges be active. That way you avoid the hassle of having the manage 1 package for each user.
    User Shema ===(SQL QUERY)==> Your System's Schema ==(QUERY) ===> Your Package w/ Authid Current User ==(Dynamic SQL Execution) ==> END
    For your package, you might want to consider implementing/simulating variable argument lists, so that you can provide binds if necessary. You would just match up the binds within the query (using dbms_sql would be the only way, execute immediate does not give supporting query information) to the corresponding arguments.
    I'm not sure what your goal is, but at least you have a direction to run in/at.

  • Executing multiple apex applications from EBS

    Hi,
    We have developed an apex application which can be triggered through an application link from Oracle EBS. Now, we have a requirement to run multiple apex applications from a single EBS session simultaneously.
    Can someone provide information on how this can be acheived?
    Raajkumar G

    Hi,
    We have developed an apex application which can be triggered through an application link from Oracle EBS. Now, we have a requirement to run multiple apex applications from a single EBS session simultaneously.
    Can someone provide information on how this can be acheived?
    Raajkumar G

  • Unit testing PL/SQL used in APEX application

    question from my customer :
    I am developing an application in Oracle Application Express and am working on unit tests for the PL/SQL stored procedures and packages that are stored in the underlying database and that are used by the APEX application. These unit tests should run within the SQL Developer Unit Test framework.
    The problem is that some of the PL/SQL code stored in the database uses functions like NV('APPLICATION_ITEM') to access items in the apex application. These do not return any values when I try to execute the PL/SQL within the unit test framework, ie through the backend. While it is good that the NV function does not error, NULL do not really work well in my scenario either (for example when the result of this functions is inserted into a NOT NULL column of a table). I can think of a few workarounds, such as creating my own NV function inside the test schema to return desirable values, but nothing seems a really satisfactory solution. I just wonder if there is any best practice recommendation from Oracle for this scenario - how can I run code that uses APEX-specific functions through the back end. I could not find anything in the APEX documentation for this but I'd be interesting to know if there is any recommendation how to best deal with this case.
    I am using SQL Developer version 4.0.0.13.80

    User[[:digit:]*
    Your PL/SQL Package APIs are poorly designed.
    You need to take Tom Kyte's quote to heart:
    "Application come and application go, but data remains forever"
    In short, you need to separate your database processing code (the stuff you need to unit test) from front-end/middle tier code.
    (repetitiveness is for effect.. not rudeness.)
    As such, The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in APEX.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in .NET.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in JSP.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in Jive.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in Ruby.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in Perl::CGI.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in P9.
    The PL/SQL code that you need to 'UNIT TEST' must work without needing to run in <place latest and greatest thing here>.
    Again, I don't mean to sound rude.  I'm just trying to reinforce the idea that you need to separate database code from middle-tier/front-end stuff.
    Basically, you will need to separate all of your packages into multiple parts.
    a _CORE package (that will be unit tested) that does all the hard work
    an _APEX package for APEX infrastructure (this works with NV()/V(), etc.)
    a _NET package for .NET infrastructure when you need it
    a _JSP package for the JSP infrastructure when you need it
    a _JIVE package for the JIVE infrastructure when you need it
    a _<place latest and greatest thing here> for the <place latest and greatest thing here> when you need it.
    MK

  • APEX Application accessing data from two different databases

    Hi All,
    Currently as we all know that APEX Application resides in database and is connected to the schema of that database.
    I want APEX Application to be running and accessing data from two different databases. Elaborating my question,
    Currently, my APEX Production Application is connected with XXXX Schema of DB1 Database(Where APEX Resides). Now I want to add some pages into this APEX Application for REPORT Purpose, But I want to connect this REPORT APEX Pages to get data from Different Schema YYYY for Database DB2.
    Is it possible to configure this scenario?
    The reason for doing this is to avoid the REPORT related (adhoc queries) resource utilization effect on Production DB1 Database.
    Thanks
    Nil

    1. If you do the joining of two or more tables in DB1 then all data is pulled over to DB1 and then the join is executed: so more data over the databaselink and more work for DB1. Better keep the joining stuff where the data resides and just pull exactly that data over that you need.
    2. Don't know about your different block sizes. Seems a nice question for one of the other forums (DBA or SQL).
    3. I mean create synonyms on DB1 for reports VIEWS in DB2.
    Hope all is clear!

  • APEX application integration into Java application

    Hello,
    I'm working on a new APEX application and I would like to integrate that application into an existing Java application.
    The integration should be invisible for the end-users. Our application will have the same look and feel as the Java application.
    The existing menu of the Java app will be extended with a new link. This link will then call our application.
    Visually I was thinking about using an Iframe to display the content of the APEX application inside the Java generated xHTML.
    This is however not the biggest issue.
    We are working in a secure context and we thus need to make sure that our APEX application doesn't create a backdoor on the
    security mechanism provided by the Java app.
    Some options have come to mind, but the one that look best is this:
    We keep the java application as the single point of entry for our end-users and make sure that the apex application is "hidden".
    We could do this by means of some re-routing code in the java application so that the incomming requests there are send to the correct server (java or apex).
    Then we will need to capture the response of the APEX application and place it inside the Java generated xHTML. The combined content is then send to the client.
    Or we could place a reverse proxy server that does this for us.
    The goal is thus that we can rely on the existing java application to cover the security and the navigation structure.
    Any ideas on this ?
    How-to's or other options ?
    thanks & regards
    Karel

    In a project I am currently working on we do it using iframes and passsing parameters over a http link.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Truncating a table from inside an application

    Hi all,
    Got a new problem to tackle. I am creating an application to calculate a very complex production bonus based on alot of different variables...
    I am working through retrieving all the data and created an apex temp table called site_bonus. I dump all the retireved values I get from Oracle for attendance, SIT data on discipline etc into the temp table as a count of number of occureneces to start the calculation of the bonus factors - here's the gotcha.....
    Prior to dumping the new run data into the temp table I want to truncate the table to remove anyprevious run data so that I dont get duplicate records cuased by a previous run. I created an on demand application process that basically does the following:
    truncate table "SITE_BONUS" /
    ( I basically copied it right from SQL workshop inside apex,by retrieving the SQL fromthe table truncate process where it works....
    When I run it anywhere inside my page as an on demand process It fails with the following error:
    ORA-06550: line 1, column 16: PLS-00103: Encountered the symbol "TABLE" when expecting one of the following: := . ( @ % ; The symbol ":= was inserted before "TABLE" to continue.
    Error
    OK
    I have tried it as a plsql process, an on demand process....and I get teh same error from any page inside my app and I cant figure out why I can do this from SQL worksop but cant call it from a page within my app.....
    Any ideas?
    Edited by: DSULLIVAN on Oct 28, 2009 3:13 PM - I corrected the typo

    You are trying : trucate
    trucate table "SITE_BONUS" /It should be : tuncate
    truncate table SITE_BONUSHope this helps,
    Sam
    +Please reward good answers by marking them correct or helpful!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Oracle dbms.set_role does not work in APEX application

    Hi, in our j2ee applications, we use secure application role. Basically, the data source use the app user schema to connect to the database. the app user only has create session privileges. the database logon trigger will copy a set of attribute to the local secure context. (ip address, session user, client id, application name). The applications explicitly invoke the stored procedure sec_mgr.set_role before any DMLs are executed.
    the sec_mgr.set_role will check the local context attribute , authorize the ip, application name, and set an appreciated role to this session based on session user.
    we want to apply the same framework to the APEX application. First, we change the paring schema to the app schema which only has create session privilege. then we put the plsql code in which sec_mgr.set_role is called in the application builder --> shared components ---> edit security attribute ---> Virtual Private Database (VPD).
    however, we got the error ORA-06565: cannot execute SET ROLE from within stored procedure
    the sec_mgr.set_role is defined as invoker's right(AUTHID CURRENT_USER)
    do i missing something in APEX to get it work?
    Thanks

    Please explain it does not work in APEX? Is the application updating tables that have a trigger? APEX does NOT override trigger actions. Is it possible the values your trigger is looking for are NOT available in your APEX application? Can you post the trigger code here for review?
    Thank you,
    Tony Miller
    Webster, TX
    What if you really were stalking a paranoid schizophrenic... Would they know?
    If this question is answered, please mark the thread as closed and assign points where earned..

  • Single log in for multiple apex application in same workspace

    hi forum.
    We created 5 applications based on same schema and all in one workspace now. Actually, initially they were created on different machines. now, we have to authenticate users from AD and depending on user type, have to allow or deny some modules. i have created one pager application which have 5 buttons and can control rendering of buttons according to user logged in but...the problem is, inside the applications, i have restrictions on some reports for some users...now one way was to do that is to create a log in for every application separately and thus every application would exactly know who is logged in. but that would be impractical as we need single-sign-on kind of functionality.
    please let me know how to have a single log in page work for all application inside the apex workspace so that every application would know name of the user currently logged in.
    for the 5 applications, i actually use No_Authentication authentication scheme. and i use following function initially for my one pager application to render the buttons to user or deny
    create or replace function getUserName return varchar2
    is
       userName varchar2(20);
       c owa_cookie.cookie;
    begin
        c := owa_cookie.get('LOGIN_USERNAME_COOKIE');
        userName := c.vals(1);
        return trim(userName);
    end;but i cannot user this function obviously in my 5 actual applications.
    help is requested please.
    bundle of thanks in advance.

    You can create one application that does the login authentication according to your authentication scheme. When authenticated, this login app sets a cookie. That's all the login app does (and maybe show a list of available apps to choose from).
    The other apps have an even simpler authentication scheme. The only thing they have to do is check the cookie and redirect to the login page (Session Not Valid URL) if there is no valid cookie.

  • Integrate an Apex Application with the E-Business Suite 11i

    Hi !
    I'm currently working to get connected to APEX (Application Express 3.2.1.00.11) using an E-Business Suite 11i form function then using the ICX cookie.
    I'm using a document created by Rod West(consultant at Cabot Consulting) to help me doing this connection.
    The document is : http://www.oracle.com/technology/products/database/application_express/pdf/apex_ebs_wp_cabot_consulting.pdf
    I always have errors when I try to get connected using the method suggested in the document.
    The error I have received is :
    ORA-00942: table or view does not exist ORA-00942: table or view does not exist ORA-06512: at "APPS.ICX_SEC", line 2388 ORA-06510: PL/SQL: unhandled user-defined exception
    This error seems to come from wfa_sec.getsession(:P101_USERNAME) used in the Before Header process of the login page(Page101).
    See code here (Figure 10 in the document) :
    BEGIN
    wfa_sec.getsession(:P101_USERNAME);
    :P101_PASSWORD :=
    XXAPX_SECURITY_PKG.generate_hash
    (FND_GLOBAL.user_name);
    IF :P101_PASSWORD IS NOT NULL THEN
    APEX_CUSTOM_AUTH.login(
    P_UNAME => :P101_USERNAME,
    P_PASSWORD => :P101_PASSWORD,
    P_SESSION_ID => v('APP_SESSION'),
    P_APP_PAGE => :APP_ID||':1'
    END IF;
    EXCEPTION WHEN OTHERS THEN NULL;
    END;
    I have done a "GRANT EXECUTE ON apps.WFA_SEC" to my APEX Schema, so the APEX Schema should have access to everything used by the package... I have tried to "GRANT EXECUTE ON" ICX_SESSIONS but I still have the same error...
    Do I need to do other "GRANT" ? Have you experienced the same problem ?
    Thanks for your help !

    Hi !
    Yes, I have already created synonyms but I still got the same errors...the error seems to be related to a table used in the package icx_sec...I have tried to grant and create synonym for tables icx_transactions and icx_sessions but I still got the error. Any ideas ?
    I have also tried to use the method (OWA_COOKIE.send) suggested in the 2007 version of the Rod West's document (the method you mentionned in the thread) and I'm able to get connected to my APEX application using the E-Business Menu but I have an intermittent problem with this method.. In fact, some days I'm able to get connected to APEX at the first try but some days I received "Invalid Login Credentials" at the first try and at the second try I get connected...And we haven't found any reasons yet for the intermittent "Invalid Login Credentials" ?
    Have you experienced the same intermittent problem on your side ?
    Thanks !

  • Error when calling a procedure from my apex application

    Hello.
    I want to create a small APEX application that can configure asynchronous change data capture (distributed hotlog) on certain tables.
    Basically, what the application should do is to simply create change tables. Everything else is set up as prerequisite.
    My problem is that when I run the following script from schema apex_cdd (using sqldeveloper) , it works; but if I run it from my apex application by calling it when pressing a button as a pl/sql process, it doen't work.
    BEGIN
    apex_cdc.enable_table_capture
         (     i_owner => 'staging_cdcpub',
              i_change_table_name     => 'g_changeTable',
              i_change_set_name     => 'Source_changeSet',
              i_change_source          => 'orcl01_cs',
              i_source_schema          => 'My_src',
              i_source_table          => 'G',
              i_column_type_list     => 'STARTDATE DATE,STATUS CHAR(1),NAME VARCHAR2(10),ENDDATE DATE,DESCRIPTION VARCHAR2(255),ID NUMBER(8,0),VALUE NUMBER(10,2)'
    END;
    If I look in the trace file, i see that the error is:
    CDCdebug:in ChangeTable.java enableDisabledTriggers: ORA-06550: line 1, column 8:
    PLS-00201: identifier 'SYS.DBMS_CDC_SYS_IPUBLISH' must be declared
    ORA-06550: line 1, column 8:
    PL/SQL: Statement ignored
    oracle.jdbc.driver.OracleSQLException: ORA-06550: line 1, column 8:
    PLS-00201: identifier 'SYS.DBMS_CDC_SYS_IPUBLISH' must be declared
    ORA-06550: line 1, column 8:
    PL/SQL: Statement ignored
    Other remarks:
    - My procedure calls: sys.DBMS_CDC_PUBLISH.CREATE_CHANGE_TABLE.
    - I gave the same rights that I gave for apex_cdc schema to flows_030200 and APEX_PUBLIC_USER schemas (just to see if it works), but it doens't.
    Is APEX calling the procedure from another schema ?
    Does anyone has an idea why this procedure crashes if called from APEX application, but works ok if called from the same schema APEX application runs on, but using SQLDeveloper ?
    Any thoughts are appreciated.
    Radian

    The procedure apex_cdc.enable_table_capture i created myself with no authid mentioned explicitly, so it uses definer rights, by default.
    BUt this procedure is simply a wrapper for sys.dbms_cdc_publish.create_change_table.
    When I look on the security model for this sys.dbms_cdc_publish, i see it runs under invoker rights. (http://www.psoug.org/reference/dbms_cdc_publish.html).
    The code is like this:
    CREATE OR REPLACE PROCEDURE enable_table_capture
              i_owner               IN VARCHAR2,
              i_change_table_name     IN VARCHAR2,
              i_change_set_name     IN VARCHAR2,
              i_change_source          IN VARCHAR2,
              i_source_schema          IN VARCHAR2,
              i_source_table          IN VARCHAR2,
              i_column_type_list     IN VARCHAR2
         IS
         BEGIN
              EXECUTE IMMEDIATE 'alter session set REMOTE_DEPENDENCIES_MODE=SIGNATURE';
              EXECUTE IMMEDIATE 'begin add_log@orcl01(i_tableName => ''G''); end;';
    sys.DBMS_CDC_PUBLISH.CREATE_CHANGE_TABLE(
    owner => i_owner,
    change_table_name => i_change_table_name,
    change_set_name => i_change_set_name,
    source_schema => i_source_schema,
    source_table => i_source_table,
    column_type_list => i_column_type_list,
    capture_values => 'both',
    rs_id => 'y',
    row_id => 'n',
    user_id => 'n',
    timestamp => 'y',
    object_id => 'n',
    source_colmap => 'n',
    target_colmap => 'y',
    options_string => NULL);
    END enable_table_capture;

  • How to deploy APEX Application within EBS module

    Hi Guruz,
    How to deploy APEX Application within EBS module, for example I have developed APEX application by using EBS Tables like OA Framework Development in jDeveloper. or anyone can clear my understanding regarding jDeveloper and APEX differences and both are same in relation with EBS Development.
    Regards,

    Hello,
    First of all you can delete delete the development environment, by executing apxdevrm.sql script.
    You can also wrap your packages.
    Regards

  • Auditing usage of ApEx applications and data

    Hi there,
    I am new to the Oracle forums and asking this question not as a DBA but from a systems security angle...
    I am using ApEx to deliver business applications to my user community and I need to know collect audit trail information on system usage. I'd like to obtain information such as:
    - which user made a database change, or accessed particular database records
    - if a user has tried to access information that they have no rights to see
    - if a DBA has created new users or changed access privileges
    and so on...
    My interest is in finding out firstly if it can be done and, secondly, how it can be achieved and recorded for analysis.
    Grateful for any advice!
    Many thanks,
    HoinviP

    We've turned on fine grained audting (FGA) and the coolest part is that oracle automatically picks up the apex application level user name and puts it in the FGA log. I expected our audit logs to have a whole lot of "apex_public_user" or the workspace schema name in the user field, but when you've got a non-public app, the end user's ID gets captured. Just as it should be.
    Our app has two layers of auditing. The vendor delivered application level audit logs so that critical application level events are captured. This is just part of the code overhead of the application. In addition we turned on Oracle FGA so that we know every DDL/DML operation that occurs against our most sensitive tables.
    The short answer is that if FGA doesn't get you what you want, you'll have to build your own auditing into your app. There is no magic checkbox or setting that will add auditing to your app, though FGA goes a long way if set up properly.
    Inside our apex app, our developer put a process on every page that displays sensitive information. The process calls a stored procedure with the user's name, the sensitive field name, its value and the primary key of the record displayed. The process has the same authorization scheme as the sensitive fields. So, if the sensitive data field is displayed, the process is run, if the user cannot see the field, no audit process is run. It actually works pretty well.
    We've also written additional Apex Apps that analyze the application level audit logs so that we can track who is looking at what and when. Very useful.

  • How to Print Receipts to Miniprinter from Apex Application

    I have an APEX Application to control orders in a restaurant. I need to automatically print orders to an Epson miniprinter in the kitchen as they are generated in multiple workstations within the place.
    There is no way of doing this in APEX. Is there a way to do it using PL/SQL? The server is not inside the place. The connection may be made through SQL*Plus or SQL Developer.
    I can see hundreds of places where the receipts are printed automatically (convenience stores, department stores, etc). I am sure most of them are using Oracle. How do they do that?
    I have been stuck with this for weeks. I can't find information about it in the forums, nor in the user manuals.
    Please help.
    Francisco.

    Hi Sven,
    Thanks for the reply.
    I have an order_detail table where every dish and beverage is recorded. Where the category is dish, there should be a process running concurrently that sends that line (or the lines accumulated in a time interval of 30 or 60 seconds) to the printer and then mark them as printed to avoid selecting them in the following run. No button and no human intervention.
    I have an APEX screen that does the job nicely, displaying the pending items and with a checkbox to mark them as delivered. But my customers want the printed thing.
    For the check I have a BI Publisher report that is opened with a button, then the PDF opens and then the cashier must send that PDF to the printer. Two or three clicks needed and it works. But that is not practical for the cook in the kitchen.
    The other issue is that the server is not within the place. Currently I am working with a server in the UK, and my business is in Mexico. So there is no way to have a printer physically connected to the server. Everything should be done at the client side.
    So do you think there could be a solution in this scenario? Is there some way to spool from SQL Developer or SQL*Plus to a txt file concurrently? That might be the answer.
    Option 2: Assuming the customer might want to buy its own server. Could you tell me more about that apex_job that may help?
    Regards,
    Francisco

  • New Oracle ACE web-page an APEX application!

    Hi,
    have you already noticed, the new Oracle ACE web-page where you can search and view the profile of the ACE's is an Oracle APEX application!
    http://www.oracle.com/technology/community/oracle_ace/index.html
    APEX is spreading... :-)
    Patrick
    My APEX Blog: http://inside-apex.blogspot.com
    The ApexLib Framework: http://apexlib.sourceforge.net
    The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

    I guess they get a special exemption from the rule against running a production app on apex.oracle.com.
    Nice to see John's book mentioned on the front page.

Maybe you are looking for