Execute a Grant in PL/SQL Procedure DBMS_SQL

Trying to find a way to do a Grant in a PL/SQL procedure. We have done it in forms before using FORMS_DDL() to execute the command. I tried DBMS_SQL but the samples show cursors for queries and inserts. Can't seem to get it to work.
Need to grant roles to users and also create users accounts.

So it should work I just have to get it setup correctly. I am coding as the
APPUSER. The APPUSER is a DBA, created the procedure and the roles. I am
coding, compiling and running as APPUSER and getting errors. I did go ahead
and try running it as someone else and granting that user explicit Grant Any Role
with Admin option and it still does not do the grant. I do not want to grant the
actual role to the user since the role give him specific Menu privileges and such
that he does not need.
We already have users granting the roles through FORMS_DDL because they
have Grant Any Role permissions for this purpose.
I guess if I know that you CAN Grant Roles in a PL/SQL Procedure with
Execute Immediate then I just need to figure out whats missing.
Thanks.

Similar Messages

  • Create table statement in a pl/sql procedure

    Hi all.
    I have a problem in Oracle 10g.
    First of all I must say that I'm new in oracle 10.
    I have a stored procedure in which I have the instruction "create table name_table as
    select col1,col2,col3,..ecc
    from table1, table2
    where table1.col1 = table2.col2"
    When I compile this procedure it gives me an error.
    Is it changed the sintax????
    Is there anyone that can help me???
    Thanks all for the collaboration,
    Fabrizio

    A little mistake -- see it --
    SQL> ed
    Wrote file afiedt.buf
      1  Create or replace procedure My_procedure as
      2  begin
      3  EXECUTE IMMEDIATE 'create table my_table(fld number(5));'
      4* end;
    SQL> /
    Warning: Procedure created with compilation errors.
    SQL>
    SQL>
    SQL> ed
    Wrote file afiedt.buf
      1  Create or replace procedure My_procedure as
      2    str varchar2(200);
      3  begin
      4   str := 'create table my_table(fld number(5))';
      5  EXECUTE IMMEDIATE(str);
      6* end;
    SQL> /
    Procedure created.
    SQL>
    SQL>
    SQL> Create or replace procedure My_procedure as
      2  begin
      3  EXECUTE IMMEDIATE 'create table my_table(fld number(5));'
      4  end;
      5  /
    Warning: Procedure created with compilation errors.
    SQL> ed
    Wrote file afiedt.buf
      1  Create or replace procedure My_procedure as
      2  begin
      3  EXECUTE IMMEDIATE 'create table my_table(fld number(5))';
      4* end;
    SQL> /
    Procedure created.Regards.
    Satyaki De.
    N.B.: Please check the bolded line. You didn't write the ; outside the quotation. Otherwise, it will compile successfully.

  • Ratio_to_report into pl/sql procedure

    how can i use 'ratio_to_report' inside a stored procedure?

    from the SQL prompt (sqlplus) Use either "execute" or its abbreviation "exec" .
    SQL> create procedure x(y number)
      2  as
      3  begin
      4  dbms_output.put_line(y);
      5  end;
      6  /
    Procedure created.
    SQL> set serveroutput on size 1000000
    SQL> execute x(100);
    100
    PL/SQL procedure successfully completed.
    SQL> exec x(100);
    100
    PL/SQL procedure successfully completed.
    SQL>

  • Error granting EXECUTE on DBMS_JAVA:-4042:ORA-04042: procedure, function,

    Hi .
    I 'm experiencingn the following problem when granting acess to the sys user can any one help please in this issue.I 'm using an oracle 10 g on a solaris system.
    Granting EXECUTE on DBMS_JAVA to SYSTEM WITH GRANT OPTION
    Error granting EXECUTE on DBMS_JAVA:-4042:ORA-04042: procedure, function,
    Thanks.

    You need to execute this with user "sys"
    see my test please:
    oracle@myserver:~> sqlplus "/ as sysdba"
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Aug 17 13:24:28 2010
    Copyright (c) 1982, 2009, Oracle. All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    sys@MYSID> grant EXECUTE on DBMS_JAVA to SYSTEM WITH GRANT OPTION;
    Grant succeeded.
    sys@MYSID>as I check ORA-04042: procedure, function, package, or package body does not exist
    I can see that you issue is that you don't have Oracle JVM option installed in your database.
    start database configuration assistant (dbca) choose configure database options operations select your DB SID and install Oracle JVM for your database (find it under Standard database components button)
    HTH, Regards

  • Execute CDC mappings from a PL/SQL procedure

    Hi,
    I´m using OWB 11.2.0.2 for Linux. I´ve created some CDC mappings to update cubes with changes coming from other tables and cubes (from the tables that implement those cubes with the relational option). The issues are:
    - The CDC mappings run successfully from the OWB (Project Navigator - Start), but I cannot execute them from a procedure in PL/SQL with the following code:
    PROCEDURE "PROC_RUNCDCMAPPINGS" IS
    --inicializar variables aquí
    RetVal NUMBER;
    P_ENV WB_RT_MAPAUDIT.WB_RT_NAME_VALUES;
    -- ventana principal
    BEGIN
    RetVal:= BARIK.CDC_LOAD_CUBO_RECARGA.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_TOR.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_TOAE.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_VIAJES.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_TICKETINCIDENCIA.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBO_LIQMONEDERO.MAIN(P_ENV);
    RetVal:= BARIK.CDC_LOAD_CUBOS_LIQTEMPORALES.MAIN(P_ENV);
    COMMIT;
    END;
    It doesn´t report any error (the value for RetVal after execution is 0), but the cubes are not loaded with changes, and the changes stored in the J$_%tables are not consumed.
    Some of the options that may impact in the mappings are:
    - All the CDC are of Simple type
    - There are more than one subscriber to consume the changes, as for some tables, its changes must feed more than one CDC.
    - All the mappings include only one execution unit per mapping.
    - The integration/load template is the default: DEFAULT_ORACLE_TARGET_CT
    Other question is: As I explained, I need more than one subscriber because same updates must be consumed by different CDC mappings, to load different cubes, but I´ve not been able to assign the subscribers to only the tables associated with them, so all the subscribers are subscribed to all the changes in all the CDC tables, but as many of those subscribers never consume the changes of same tables, in the J$_% tables remains the not consumed records, and I haven´t found the way to purge those tables (other than the delete from J$_), nor to assign the tables with the subscribers (so the subscribers are only subscribed to their interested changes, that will be consumed, so the tables will be emptied after the consumption).
    Any help with these problems will be greatly appreciated.
    Tell me if more info is needed to clarify the situation.
    Best regards,
    Ana

    Hi David,
    Thank you for your reply.
    These mappings are the mappings needed to update the cubes with the changes detected by the CDC system, they are located under the Mapping Templates folder and I´m using code templates for the control of the loading and the integration (the DEFAULT_ORACLE_TARGET_CT) mapping.
    What I need is to execute these mappings within a PL/SQL procedure that will be invoked from different tools.
    I´ve done it for regular mappings (not CDC mappings), and it works. The code is the same as for the CDC ones:
    PROCEDURE "PROC_RUNLOADMAPPINGS" IS
    --inicializar variables aquí
    RetVal NUMBER;
    P_ENV WB_RT_MAPAUDIT.WB_RT_NAME_VALUES;
    -- ventana principal
    BEGIN
    RetVal:= BARIK.LOAD_CUBO_RECARGA.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_TOR.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_TOAE.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_VIAJES.MAIN(P_ENV);
    RetVal:= BARIK.LOAD_CUBO_TICKETINCIDENCIA.MAIN(P_ENV);
    COMMIT;
    END;
    -- End of PROC_RUNLOADMAPPINGS;
    ,and when I run it, the mappings are executed, but with the CDC ones it doesn´t (even when no error is reported).
    I know that they are deployed in the selected agent (in my case the Default_Agent), but when I start them from the OWB, the mapping packages are created in the DB schema, so, I thought that maybe I could invoke them....so what you tell me is that the only way to invoke them is from SQL*Plus? not from a regular PL/SQL procedure?
    Thank you very much,
    Ana

  • How to execute a script(.sql) file from a PL\SQL procedure

    I would like to know how to execute a .sql file from a stored procedure and the result of it should update a table. My .sql file contains select statements.

    Hi!
    just go through the following piece of code -
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    str varchar2(200);
      3  begin
      4    str := '@C:\RND\Oracle\Misc\b.sql';
      5    execute immediate(str);
      6* end;
    SQL> /
    declare
    ERROR at line 1:
    ORA-00900: invalid SQL statement
    ORA-06512: at line 5ORA-00900: invalid SQL statement
    Cause: The statement is not recognized as a valid SQL statement. This error can occur if the Procedural Option is not installed and a SQL statement is issued that requires this option (for example, a CREATE PROCEDURE statement). You can determine if the Procedural Option is installed by starting SQL*Plus. If the PL/SQL banner is not displayed, then the option is not installed.
    Action: Correct the syntax or install the Procedural Option.
    Regards.
    Satyaki De.

  • Execute report from pl/sql procedure

    hi all
    please, can i know whether there's any way to execute a report from pl/sql stored procedure??
    thank you.

    Hallo,
    usually you would use 21.1 The Event-Driven Publishing API
    You can search the forum for examples Google: site:forums.oracle.com call report from pl/sql
    Regards
    Marcus

  • Xml file not generated through Pl/sql procedure as a concurrent executable

    Hi,
    I getting error while genarating xml file through Pl/sql procedure as a concurrent executable file.
    Error Message:
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Invalid at the top level of the document. Error processing resource

    Hi,
    Make sure the file has the XML header:
    <?xml version="1.0" encoding="UTF-8"?>
    or similar.
    Regards,
    Gareth
    Blog: http://garethroberts.blogspot.com/

  • PL/SQL WEB Toolkit: Using BUTTON to execute PL/SQL procedure

    I am trying to execute a PL/SQL procedure with a "SUBMIT" button from a WEB page. I have several URLs that execute perfectly, but I do not want endusers to have to type the URL themselves. I want to display a web page with multiple URLs in a drop_down list. User chooses a member of the list, clicks the "SUBMIT" buttom and that specific URL executes and produces the proper result. I am NOT a web developer, but this is what I've written sofar:
    CREATE OR REPLACE PROCEDURE html_list
    IS
    BEGIN
    HTP.PRINT ('<html>');
    HTP.PRINT ('<head>');
    HTP.PRINT ('<meta http-equiv="Content-Type" content="text/html">');
    HTP.PRINT ('<title>Title of the HTML File</title>');
    HTP.PRINT ('</head>');
    HTP.PRINT ('<body TEXT="#000000" BGCOLOR="#FFFFFF">');
    HTP.PRINT ('<h1>List of Valid URLs</h1>');
    HTP.PRINT ('<p>Choose your desired URL from the list below.');
    HTP.PRINT ('<FORM method="post" action="WHATEVER_COUNTS_WEB">');
    HTP.PRINT ('<FORM method="post" action="REQUEST_OBJECTS?PARAM1=MY_SCHEMA_ID">');
    HTP.PRINT ( '<SELECT name="URL">
    <option value="http://asai01.ffxlab.net:8080/me_epg_dad/WHATEVER_COUNTS_WEB">Count of Rows in Whatever Tables
    <option value="http://asai01.ffxlab.net:8080/me_epg_dad/REQUEST_OBJECTS?PARAM1=ME">Request Objects for MY_SCHEMA_ID
    <input type="submit" value="Submit"/>
    </SELECT>');
    HTP.PRINT ('</FORM>');
    HTP.PRINT ('</body>');
    HTP.PRINT ('</html>');
    END;
    Any help would be greatly appreciated. I've been writing PL/SQL code since 1989, but have never had to execute code via a WEB page until this week.
    Thanks so much

    Hi,
    Welcome to Oracle Forums!
    Please acquaint yourself with the FAQ and forum etiquette if you haven't already done so.
    Always post code snippets enclosed in a pair of &#123;code&#125; tags as explained in FAQ
    This Forum is dedicated to Oracle Forms. Unfortunately there is no Forum for WebToolKit that I know of. The closest is Oracle Application Express (APEX).
    If you objective is to have the User Navigate to the URL clicked then the easiest way is to use anchor tag with href attribute
    CREATE OR REPLACE PROCEDURE html_list
    IS
    BEGIN
    HTP.PRINT ('<html>');
    HTP.PRINT ('<head>');
    HTP.PRINT ('<meta http-equiv="Content-Type" content="text/html">');
    HTP.PRINT ('<title>Title of the HTML File</title>');
    HTP.PRINT ('</head>');
    HTP.PRINT ('<body TEXT="#000000" BGCOLOR="#FFFFFF">');
    HTP.PRINT ('<h1>List of Valid URLs</h1>');
    HTP.PRINT ('<p>Choose your desired URL from the list below.</p>');
    HTP.PRINT ('<a href="http://asai01.ffxlab.net:8080/me_epg_dad/WHATEVER_COUNTS_WEB" target="_blank">Count of Rows in Whatever Tables</a>');
    HTP.PRINT('<a "http://asai01.ffxlab.net:8080/me_epg_dad/REQUEST_OBJECTS?PARAM1=ME" target="_blank">Request Objects for MY_SCHEMA_ID</a>');
    HTP.PRINT ('<FORM method="post" action="WHATEVER_COUNTS_WEB">');
    HTP.PRINT ('<FORM method="post" action="REQUEST_OBJECTS?PARAM1=MY_SCHEMA_ID">');
    HTP.PRINT ( '<SELECT name="URL">
    <option value="http://asai01.ffxlab.net:8080/me_epg_dad/WHATEVER_COUNTS_WEB">Count of Rows in Whatever Tables
    <option value="http://asai01.ffxlab.net:8080/me_epg_dad/REQUEST_OBJECTS?PARAM1=ME">Request Objects for MY_SCHEMA_ID
    <input type="submit" value="Submit"/>
    </SELECT>');
    HTP.PRINT ('</FORM>'); */
    HTP.PRINT ('</body>');
    HTP.PRINT ('</html>');
    END;Change the target attribute to suite your needs. More here http://www.w3schools.com/tags/att_a_target.asp
    Or, maybe explore Apex !
    Cheers,

  • Include Button that executes PL/SQL procedure to SQL query based region

    I would like to add two columns to a SQL query region.
    These columns would not be sourced from the query, but rather would be used to execute a PL/SQL procedure.
    For example, I would like to have a manager approve or deny adding an additional employee to the department.
    There would be one button for APPROVE. And, one button for DENY.
    The PL/SQL procedure would execute to perform the required DML based upon the selected action (either APPROVE or DENY).
    A sample output would look like this:
    <APPROVE>, <DENY>, John Doe, Accountant
    <APPROVE>, <DENY>, Jane Doe, Accountant
    Is there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?
    Thanks!
    -Reid

    Is there any way to add a button to a SQL Query based report region where that button executes a stored proc? If so, what is the basic process for doing this?Conditional page item? You can associate processes with buttons on a page

  • Executing pl/sql procedure in SQL Workshop

    Hello.
    My understanding is that the only way to execute a pl/sql procedure in the SQL Workshop is via SQL Scripts, because running it under SQL Commands causes
    "ORA-00900: invalid SQL statement".
    Here is the statement I would like to run:
    execute efax_letter_to_pharmacist ('8888888888','ASDFSFSFSF','1','APN123456789','81');
    and here is the message I get when I run it under SQL Scripts:
    You have requested to run a script that does not contain any runnable statements.
    Script Name TEST
    Created on 02/14/2008 10:47:15 AM by ADMIN
    Updated on 02/14/2008 10:56:45 AM by ADMIN
    Number of Statements 0
    Script Size in Bytes 86
    thanks
    Boris

    Boris,
    Execute is a SQL*Plus command.
    It should work if you call your procedure in a begin-end block. e.g:
    begin
      efax_letter_to_pharmacist ('8888888888','ASDFSFSFSF','1','APN123456789','81');
    end;

  • How to execute a SQL procedure in UNIX

    How to execute a SQL procedure in UNIX

    Check this out..
    -Sri
    << a.sql >>
    create or replace procedure junk(nout out varchar2) is
            x varchar2(20);
    begin
            select 'Sam' into x
            from dual;
            nout := x;
    end;
    << Shell script >>
    sqlplus -s / << DOC
    scott/tiger
    variable x varchar2(20);
    set autoprint on
    @a.sql
    begin
    junk(:x);
    end;
    exit
    DOC
    << Execution of Shell SCript >>
    # sh b.sh
    Procedure created.
    PL/SQL procedure successfully completed.
    X
    Sam

  • Execute PL/SQL procedure periodically

    Hello everybody.
    Im working with Oracle 10G R1.
    I need to execute a PL/SQL procedure every 5 minutes.
    Can anyone send me a example, or a link where I can study how to do this?
    Thanks in advanced & regards to all.

    Hi,
    From Os perspective you use crontab - to execute a script
    Refer to :
    http://dbamac.wordpress.com/2008/08/01/running-sqlplus-and-plsql-commands-from-a-shell-script/
    sqlplus and Unix crontab - example
    Using Schedulers you can do it
    Kindly refer to : http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_sched.htm
    http://www.oracle-base.com/articles/10g/Scheduler10g.php
    - Pavan Kumar N

  • Executing OS command from sql procedure

    i want to execute an OS command from the procedure, can i do this way? looks like it is not executing the command move....
    declare
    begin
    dbms_output.put_line(' moving...');
    host;
    move c:\file1\test.txt C:\moved
    exit;
    /

    True. But that job is going to run in a separate session, some time after the current transaction commits (depending on the number of jobs queued up to run). So if you need to pass information back from the job, or you want the procedure to handle exceptions thrown by the job, or you want to tie job related failures back to a particular application level event, or you want the rest of your procedure to wait for the operating system command to finish, using the DBMS_SCHEDULER for this sort of thing is going to require a fair amount of additional coordination/ monitoring/ infrastructure code. It's certainly not a Herculean task to write that additional code, and it's reasonable in some situations, but the Java stored procedure approach strikes me as substantially easier to deal with in most cases.
    Justin

  • How to call a PL/SQL procedure from Portal

    Env.Info: Windows NT Server 4 (Service Pack 3) / Oracle 8i R3 EE / Oracle Portal 3.0 Production.
    I created a new schema "BISAPPS" and created a user with the same name. Ran provsyns.sql script to grant Portal API access. Created a new package under this new schema and compiled it against the database. After that I registered the schema as a portal provider. There were no errors.
    Now I logged into Portal using the account PORTAL30. Refreshed the portlet repository and the new portlets appeared. I added the new portlet to the page. It is displayed successfully.
    New portlet allows the user to enter a bug-number and lets the user to either view or edit. If the user clicks on the button "Edit", it opens a new window and displays the contents from BugDB application. But if the user clicks on "Show", it should display the output generated by a PL/SQL procedure (Owned by the above New Schema - BISAPPS) in a separate window. But instead it is displaying the following error in the separate window:
    bisapps_pkg.buginfo: PROCEDURE DOESN'T EXIST.
    DAD name: PORTAL30
    PROCEDURE : bisapps_pkg.buginfo
    URL : http://host_name:80/pls/portal30/bisapps_pkg.buginfo
    And list of environment variables ....
    Can anyone help me? How can I call a PL/SQL procedure when the button is clicked? Thanks in advance.

    You must grant EXECUTE privilege on your procedure to the PORTAL30_PUBLIC user. If the error still persists, create a PUBLIC synonym for your procedure.

Maybe you are looking for

  • Worst customer support ever

    I was using sony ps3 super slip 500 gb,after 11 months of using this my system could not read the discs. As my product was under warrenty, I sent that to service centre. They told me that they will call me in 7-10 days. They did not, when I called th

  • How to poke with response using DDE

    I am trying to communicate with a windows application using the antiquated DDE interface, I know this interface has been overtaken by ActiveX but the application i am talking to (ZEMAX – optical modelling software) doesn't implement it. I have manage

  • MP3s open in smaller window

    I know how to link to an MP3 and have it open in a separate window, but how do I make it open in smaller pop-up window instead of the full size that comes up with the Quicktime logo?? I tried using an onClick Behavior to open in another window but it

  • How to display content in HttpSerlvetResponse in a new web page?

    I am a newbie in servlet&html and hope to get some information here for my question. Suppose I have a web page having a list. after the user has chosen one of them, he will click on submit to send the request to the servlet. In my servlet, I use the

  • IDVD 5.01 Crash at Start-up

    I'm on a dual 1.4 GHz G4 with 2 GB of RAM running OS 10.4.11. I have been using iDVD 5.01 for years, but lately it refuses to work. It boots, but when I try to create a file it crashes every time.  I've deleted the preference files and re-updated 5.0