Calling DBMS_STATS within PL/SQL block

Hy guys
I trying to call the package DBMS_STATS within a pl/sql block but I'm getting the following error..
here is my blok
BEGIN
IF FGLOBAL('ABC_STATS') = 'SIM' THEN
FOR V_OBJETOS IN C_CURSOR_STATS LOOP
EXECUTE IMMEDIATE 'EXEC DBMS_STATS.GATHER_TABLE_STATS('''||USER||''','''||V_OBJETOS.TABLE_NAME||''')';
END LOOP;
END IF;
here is the execution error
SQL> exec analisa_stats;
BEGIN analisa_stats; END;
ERROR on line 1:
ORA-00900: invalid SQL instruction
ORA-06512: on "username.ANALISA_STATS", line 12
ORA-06512: on line 1
How can I call the package using execute immediate ? is there any other way ?
Tks to All

Hi,
1. in pl/sql you cannot specify "exec dbms_stats ..." but only "dbms_stats ...".
2. why execute immediate, just call dbms_stats and pass your parameters
regards, martina

Similar Messages

  • SQL within PL/SQL block

    This question sound funny. I just want to make sure this rule. In Oracle database before 10g, we can only use DML and transaction control code within PL/SQL block. We can not use DDL or other control languages within PL/SQL block. How about 10g? can I use DDL in PL/SQL block in 10g?
    I have created a procedure to drop all materialized view. Drop object is DDL. I used a piece of code like this:
    v_sql_stmt1 := 'DROP MATERIALIZED VIEW'||v_schema||'.'||x.mview_name;
    EXECUTE IMMEDIATE v_sql_stmt1;
    The procedure was compiled successfully. However, when I run this SP, it generate ORA-00905 missing keyword error on EXECUTE IMMEDIATE statement part. Is this caused by missing keyword in sql statement or DROP as DDL can not be used in PL/SQL block? If it is first one, what is the keyword for DROP MATERIALIZED VIEW statement?

    The versions of Oracle that run on this planet have been able to do DDL in PL/SQL for quite some time now. The DBAs who blasted off into space with you and worked in a vacuum the past however many years you feel you've been limited by this need to be replaced or re-introduced to Oracle.
    For what it's worth, the error looks like you're missing a space.

  • Calling function from PL/SQL block

    Hi,
    A very simple question.
    A have a function called "test1" in my database. It is there i double chekked.
    I would like to call this function from a block:
    DECLARE
    BEGIN
    TEST1(1202);
    END;
    This gives me an error.
    Why is this?

    user610868 wrote:
    Hi,
    A very simple question.
    A have a function called "test1" in my database. It is there i double chekked.
    I would like to call this function from a block:
    DECLARE
    BEGIN
    TEST1(1202);
    END;
    This gives me an error.
    Why is this?Hello
    A very very basic thing to do when you get an error is to include details of it. That helps narrow it down from one of the 1000s of potential Oracle errors it could be.
    Anyway, a function returns a value, and in PL/SQL you need to capture that otherwise you'll get "an error". Modify your code like so
    DECLARE
       l_Test1Val     VARCHAR2(4000); --CHANGE THIS TO BE THE SAME AS THE RETURN TYPE FOR YOUR FUNCTION
    BEGIN
       l_Test1Val :=  TEST1(1202);
    END;HTH
    David
    Edited by: Bravid on Oct 25, 2011 3:57 PM
    removed a ;

  • Call DLL from PL-SQL block

    Hello all,
    I want to call a function located in an external DLL from a PL-SQL block. I execute the followin steps :
    1. Create a database library pointing to the external DLL :
    create or replace library libstk as 'C:\SUMMIT\libstkdte_s_trade1.dll'
    2. Create the definition and the body package :
    CREATE OR REPLACE PACKAGE dllcall IS
         FUNCTION s_trade (
              s_in VARCHAR2 )
    RETURN VARCHAR2;
    PRAGMA RESTRICT_REFERENCES(s_trade, WNDS);
    end dllcall;
    show errors
    CREATE OR REPLACE PACKAGE BODY dllcall IS
    FUNCTION s_trade (s_in IN VARCHAR2) RETURN VARCHAR2
    IS EXTERNAL
    NAME "s_trade"
    LIBRARY libstk
    PARAMETERS (s_in           STRING,
    RETURN STRING);
    END dllcall;
    show errors
    set serveroutput on
    3. Start the PL-SQL block calling the external function. And I got the foolowing error :
    1 begin
    2 dbms_output.put_line ( dllcall.s_trade ( '<Request> ' ||
    3 '<CurveId>MYCURVE</CurveId> ' ||
    4 '<Mode>02</Mode> ' ||
    5 '<ExpCcy>GBP</ExpCcy> ' ||
    6 '<AsOfDate>20001023</AsOfDate> ' ||
    7 '<Entity>***SUMMIT-XML***</Entity> ' ||
    8 '</Request>') );
    9* end;
    10
    11 /
    begin
    ERROR à la ligne 1 :
    ORA-06520: PL/SQL: Error loading external library
    ORA-06522: Unable to load DLL
    ORA-06512: at "V31.DLLCALL", line 0
    ORA-06512: at line 2
    The "Read - Execute permissions" of the DLL file was given to "Authentified users" .
    What's wrong ?
    TIA
    PS : NT2K environment, DB 8.1.7
    R. Charles Emile

    Yes, a RPC was set up.
    Listner.ora
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Server1)(PORT = 1521))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = NMP)(SERVER = Server1)(PIPE = ORAPIPE))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = E:\Oracle\Ora81)
    (PROGRAM = extproc)
    tnsnames.ora
    extproc_connection_data =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (CONNECT_DATA = (SID = PLSExtProc))
    Thanks
    RCE

  • PERFORMANCE BAD WHEN CURSORS ARE USED WITHIN PL/SQL BLOCKS

    There are poor database performance at Oracle 10g
    For some cursor selects, the performance is under Oracle 10g
    significant slower than under Oracle 9i.On a test system (Oracle 9) the
    problem does not reproduce, on the 10g system however always.
    The simple execution of the base select statement was on both
    databases in roughly of the same speed. If however a cursor was defined and
    those executed within a PL/SQL block (without involving the user interface),
    then the time behavior was in accordance with the observed behavior
    behavior on the user interface.
    By adding of the hint first_rows on both machines a
    similar (fast) time behavior can be achieved.
    Conclusion: Something in the (Optimizer) settings of the Oracle-10
    databases must be fundamentally different than that of Oracle 9. Or Oracle
    10 has a real problem. The analysis and solution of this general
    problem seems to me more reasonable than the solution of individual performance
    problems.
    can you help me, many thanks

    Hello, thanks for the explanatory notes.
    Here are the concerned Script. The only difference is the Hint (with Hint = good püerformance; without Hint = bad performance)
    DECLARE
    b BOOLEAN;
    BEGIN
    b := plogin.batch_login('**', '****', 717, FALSE);
    prost.reload_context;
    END;
    DECLARE
    l_ma_kuerzel VARCHAR2(100) DEFAULT NULL;
    l_sta_id mitarbeiter_historie.sta_id%TYPE;
    l_org_id organisationseinheit.org_id%TYPE;
    l_pv_like mitarbeiter.ma_name%TYPE;
    l_typ_id typ.typ_id%TYPE;
    l_mihi_beginn VARCHAR2(40);
    l_ma_ausgeschieden VARCHAR2(40);
    l_ma_ldap mitarbeiter.ma_ldap%TYPE;
    l_smodify_form VARCHAR2(80);
    l_sform_typ VARCHAR2(80);
    l_sheader VARCHAR2(200);
    l_nurlsource NUMBER;
    l_nurldestination prosturl.pur_id%type;
    l_ma_like VARCHAR2(100) DEFAULT NULL;
    l_nma_typ NUMBER;
    l_bshow BOOLEAN;
    l_counter NUMBER DEFAULT 0;
    cursor ma_list_not_all_detail(
    p_ma_like IN VARCHAR2 DEFAULT NULL,
    p_ma_kuerzel IN VARCHAR2 DEFAULT NULL,
    p_sta_id IN VARCHAR2 DEFAULT NULL,
    p_org_id IN VARCHAR2 DEFAULT NULL,
    p_typ_id IN VARCHAR2 DEFAULT NULL,
    p_mihi_beginn IN VARCHAR2 DEFAULT NULL,
    p_pv_like IN VARCHAR2 DEFAULT NULL,
    p_ma_ausgeschieden IN VARCHAR2 DEFAULT NULL,
    p_ma_ldap IN VARCHAR2 DEFAULT NULL
    ) IS
    SELECT /*+ first_rows */
    ma.ma_id ma_id
    , view_fkt.display_ma(mihi.typ_id_mt
    , view_fkt.cat_maname(ma.ma_name
    , ma.ma_zusatz
    , ma.ma_titel
    , ma.ma_vorname)) name
    , view_fkt.display_ma(mihi.typ_id_mt,ma.ma_kuerzel) ma_kuerzel
    , typ.typ_value mt_kuerzel
    , substr(org.typ_id,4,length(org.typ_id)) || ' ' || org.org_name||' ('||org.org_ktr||')' org_name
    , to_char(mihi.mihi_beginn, 'dd.mm.yyyy') beginn
    , decode(pv.ma_name ||' '|| pv.ma_titel ||' '|| pv.ma_vorname
    , ' ',prost_cons.t_blank
    , pv.ma_name||', '||pv.ma_titel||' '||pv.ma_vorname) pv_kuerzel
    , mihi.sta_id sta_id
    , nvl(to_char(ma.ma_ausgeschieden,'dd.mm.yyyy'), ' ') ausgeschieden
    , nvl(to_char(mihi.mihi_wochenarbeitszeit,'90D00'),' ') wochenarbeitszeit
    , nvl(to_char(mihi.mihi_taz_mo,'90D00'),' ') taz_mo
    , nvl(to_char(mihi.mihi_taz_di,'90D00'),' ') taz_di
    , nvl(to_char(mihi.mihi_taz_mi,'90D00'),' ') taz_mi
    , nvl(to_char(mihi.mihi_taz_do,'90D00'),' ') taz_do
    , nvl(to_char(mihi.mihi_taz_fr,'90D00'),' ') taz_fr
    , nvl(to_char(mihi.mihi_taz_sa,'90D00'),' ') taz_sa
    , nvl(to_char(mihi.mihi_taz_so,'90D00'),' ') taz_so
    , nvl(ma.ma_ldap, ' ') ma_ldap
    , mihi.mihi_beginn mihi_beginn
    , mihi.mihi_order_no mihi_order_no
    , mihi.mihi_order_pos mihi_order_pos
    FROM organisationseinheit org
    , typ typ
    , mitarbeiter pv
    , mitarbeiter ma
    , v$mihi_id mid
    , mitarbeiter_historie mihi
    , v$access_orgs_th_t th
    WHERE mihi.org_id = th.org_id
    AND mid.mihi_id = mihi.mihi_id
    AND ma.ma_id = mid.ma_id
    AND ma.ma_delete = 'n'
    AND ma.ma_virtualitaet = 'N'
    AND (p_ma_like IS NULL
    OR ma.ma_name LIKE p_ma_like)
    AND (p_ma_kuerzel IS NULL
    OR ma.ma_kuerzel LIKE p_ma_kuerzel)
    AND (p_sta_id IS NULL
    OR mihi.sta_id = p_sta_id)
    AND (p_org_id IS NULL
    OR org.org_id = p_org_id)
    AND (p_typ_id IS NULL
    OR typ.typ_id = p_typ_id)
    AND mihi_beginn >= nvl(p_mihi_beginn,to_date('01.01.1960','dd.mm.yyyy'))
    AND (p_pv_like IS NULL
    OR pv.ma_name LIKE p_pv_like)
    AND (ma.ma_ausgeschieden >= nvl(p_ma_ausgeschieden,to_date('01.01.1960','dd.mm.yyyy'))
    AND ma.ma_ausgeschieden - 1 < nvl(p_ma_ausgeschieden,to_date('01.01.1960','dd.mm.yyyy'))
    OR p_ma_ausgeschieden IS NULL)
    AND (p_ma_ldap IS NULL
    OR ma.ma_ldap LIKE p_ma_ldap)
    AND pv.ma_id (+)= mihi.ma_id_pv
    AND org.org_id (+)= mihi.org_id
    AND typ.typ_id = mihi.typ_id_mt
    ORDER BY upper(ma.ma_name), upper(ma.ma_vorname);
    l_result ma_list_not_all_detail%ROWTYPE;
    BEGIN
    l_nMA_Typ := pmitarbeiter.cn_Incomplete_Ma;
    l_ma_like := NULL;
    l_ma_kuerzel := NULL;
    l_sta_id := NULL;
    l_org_id := 'KST0000421301';
    l_typ_id := NULL;
    l_mihi_beginn := NULL;
    l_pv_like := NULL;
    l_ma_ausgeschieden := NULL;
    l_ma_ldap := NULL;
    IF (l_ma_like IS NOT NULL
    OR l_ma_kuerzel IS NOT NULL
    OR l_sta_id IS NOT NULL
    OR l_org_id IS NOT NULL
    OR l_typ_id IS NOT NULL
    OR l_mihi_beginn IS NOT NULL
    OR l_pv_like IS NOT NULL
    OR l_ma_ausgeschieden IS NOT NULL
    OR l_ma_ldap IS NOT NULL) THEN
    -- fuer Mitarbeiter unvollstandig wird ein andere cursor angesprochen
    -- um der Mitarbeiter vollstandig zu kriegen soll ein Standort,
    -- Arbeitszeitmodel, Bereich und Tagesarbeitszeiten ausgevult wirden
    -- Wenn er dan gespeichert wirdt wirden die betriffende velder gespeichert
    -- und wirdt das Feld Virtualiteat auf R gesetzt (war N)
    l_counter := 0;
    dbms_output.put_line(to_char(sysdate, 'sssss'));
    FOR j IN ma_List_Not_All_Detail(
    l_ma_like,
    l_ma_kuerzel,
    l_sta_id,
    l_org_id,
    l_typ_id,
    l_mihi_beginn,
    l_pv_like,
    l_ma_ausgeschieden,
    l_ma_ldap
    ) LOOP
    l_counter := l_counter + 1;
    dbms_output.put_line(l_counter);
    dbms_output.put_line(j.ma_kuerzel);
    END LOOP;
    dbms_output.put_line(to_char(sysdate, 'sssss'));
    END IF;
    return;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line(sqlerrm);
    END;
    =============
    Thank you

  • Using accept command within PL/SQL block

    Hi all i have a following Pl/SQL block which ia =as follows :-
    declare
    begin
    ...certain statements using while
    end;
    i need to take the user input using accept
    if i put the accept stmt betweeen begin and end i am getting following error :-
    accept myv number default 10 prompt 'Enter a number: '
    ERROR at line 48:
    ORA-06550: line 48, column 8:
    PLS-00103: Encountered the symbol "MYV" when expecting one of the following:
    := . ( @ % ;
    ORA-06550: line 48, column 30:
    PLS-00103: Encountered the symbol "PROMPT" when expecting one of the following:
    * & = - + ; < / > at in is mod remainder not rem
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between || multiset member SUBMULTISET_
    Let me know how can i include accept stmt in Pl/SQL block
    Thanks

    You're missing a fundamental concept here.
    PL/SQL = embedded 4GL programming language in the Oracle database.
    SQL*Plus = CLI (Command Line Interface) client for an Oracle database.
    The ACCEPT command is a SQL*Plus command. Not a PL/SQL command.
    The PL/SQL engine sits inside the Oracle Server Process that services your client (SQL*Plus) session. That server process does not know who/what/where you are as a physical client. It does not know what platform and o/s you are using. It does not know what client you are using. It is after all a server process and should not and need not to know that.
    Nor can that Oracle Server Process running on the Data Server Platform access you client's hard drive, keyboard, mouse, screen, printer and so on.
    PL/SQL running in this Oracle Server Process therefore cannot read your keyboard to accept end-user input. PL/SQL therefore cannot write data to your screen.
    You need to make a clear distinction between SQL*Plus (a client) and Oracle PL/SQL (the server).

  • How to execute .bat file within pl/sql block

    Hi,
    I want to execute a batch file (.bat) file withing a pl/sql procedure. Please guide me for it.
    Regards

    There are several possible ways to make a call-out from a PL/SQL program to the OS on the database server (but not to the client computer).
    You could use java or an external procedure (you'll need to code it in C) for example.
    You might be able to make use of UTL_HTTP to talk HTTP to another server or UTL_TCP to talk TCP to another server.
    What is it you are trying to do?

  • Use Chains, or PL/SQL Block of calls.

    I currently have a half dozen cron jobs that kick off different batches of processing. Originally, these were generally a sequence of C programs that did different operations (fetch student info from student record system and load into IdM system, process directory changes, etc). Over the years, most of the program logic has been rewritten as PL/SQL packages and the cron jobs basically drop into SQL*PLUS and do things like:
    prompt "Do Spbpers delta"
    execute simon.employee_maint.Spbpers_Delta;
    commit;
    prompt "Do People.Update_From_Employees"
    execute simon.People_Maint.Update_From_Employees;
    commit;
    prompt "Do SGBSTDN_Full"
    execute Simon.Bstudent_Maint.Sgbstdn_Full;
    commit;
    prompt "Do SPRIDEN_Full (Student)"
    execute Simon.Bstudent_Maint.Spriden_Full;
    These procedures generally connect to other Oracle databases and get or push data around, and are hitting a number of different databases. The biggest of these scripts has 45 execute statements in it. (This script started in 1992.....)
    Anyway, we are getting some issues with and it is time to clean things up. This is my first foray into Scheduler and I am hoping to get some philosophical guidance on how best I should restructure things. One obvious thing, is to break up the big script into a couple of smaller ones. In some cases, order matters and in other, it doesn't - although I would prefer not to have several jobs hitting the admin system at the same time.
    I have been playing a bit with the scheduler, mostly via the EM web interface, and have come up with a few questions - some pretty specific, others more stylistic.
    1) Procedures as jobs - it seemed to want stand alone procedures, and NOT procedures that were part of a package. True?
    2) How fine grained should I make the steps in a chain? For example, I call 5 procedures in the same package (student_maint), each to to some specific aspect of the processing (each represents a different source table). Should I create 5 programs, and make them 5 steps in the chain, or just have 5 calls in a PL/SQL block in one program?
    3) I don't care what order these 5 run in, but I don't want more than one running at once - thoughts on approaches to this?
    4) I will on occasion want to turn off sets of these tasks (like when the remote system is going to be down for an upgrade) - how best to structure things to make this easy to do (and how do I do this?)
    The Scheduler system seems to be a very rich and flexible environment, with a lot more options and features than I need, but I feel I should do more than just scheduling a single program with 45 procedure calls in it....

    Hi,
    I can try to answer some of these questions
    1) Procedures as jobs - it seemed to want stand alone procedures, and NOT procedures that were part of a package. True?
    False. The EM interface does have this restriction, but if you use dbms_scheduler directly there is no such restrisction. Even in the EM interface you can workaround this by using a PL/SQL block which calls the package procedure (although argument handling is a little less flexible this way).
    2) How fine grained should I make the steps in a chain? For example, I call 5 procedures in the same package (student_maint), each to to some specific aspect of the processing (each represents a different source table). Should I create 5 programs, and make them 5 steps in the chain, or just have 5 calls in a PL/SQL block in one program?
    The answer to this depends on what you are doing. If the 5 steps run serially one after the other, using one pl/sql block may be easier. If you want some pieces to run in parallel, then creating a simple chain is better. A bit more effort spent setting up the chain will result in much faster execution times if you can run pieces in parallel.
    3) I don't care what order these 5 run in, but I don't want more than one running at once - thoughts on approaches to this?
    This has come up on the forum a few times and there are basically two different approaches. One is to use dbms_lock to ensure that only one runs at a time. This is the easiest way and the way that I recommend.
    The other way is to set up a job class with a resource consumer group and put into effect a resource consumer plan that specifies that only one session from that resource consumer group can run at a time. This is easily extensible to cases where you want 2 or more running at a time from a certain job class (which dbms_lock doesn't support).
    Code on how to set this up and more discussion is located here
    Run Jobs One After Another
    4) I will on occasion want to turn off sets of these tasks (like when the remote system is going to be down for an upgrade) - how best to structure things to make this easy to do (and how do I do this?)
    Jobs and programs can be disabled. But if a job or chain tries to run a disabled program it will result in a failure (though it will be retried if you say that the job can be restarted).
    [ 5) ] The Scheduler system seems to be a very rich and flexible environment, with a lot more options and features than I need, but I feel I should do more than just scheduling a single program with 45 procedure calls in it....
    The Scheduler was intended to accommodate a wide range of usage from simple one-off background tasks to complex sequences of interrelated tasks. As with any other software development you should use it in the simplest way possible that does what you need it to do.
    Hope this helps. Feel free to post any further questions.
    -Ravi

  • Spawning multiple Processes in PL/SQL Block

    Hi All
    Does anyone know if it is possible within PL/SQL block to 'spawn' multiple versions of a procedure as parallel processes.
    What I would like to do is something like
    WHILE x = 'CONTINUE LOOP
    load process1...load process2..load process3.
    I could create a UNIX script to run the procedure as a background process multiple times but I would prefer to use PL/SQL solution if one exists.
    Many thanks inadvance

    Hi Martin,
    you should have a look into the package "dbms_Job". With the routines in this package it is possible to submit the execution of stored procedures by the Oracle job scheduler.
    If you are in 10g you could alternatively use the "dbms_Scheduler" package.
    Have a nice day.
    Björn Hachmann

  • Run SQL cmd from PL/SQL block

    Is it possible to run SQL command Eg. "ALTER SESSION SET PLSQL_DEBUG=TRUE"
    within PL/SQL block in a form
    thax
    shabar

    Dear shabar!
    Yes, it is!
    BEGIN
    --Here as some PL/SQL-Commands
    --And here is the SQL-Command
    EXECUTE IMMEDIATE 'ALTER SESSION SET PLSQL_DEBUG=TRUE';
    --And here are some more PL/SQL-Commands
    END;I hope this will help you along!
    Yours sincerely
    Florian W.

  • Call to concurrent program in a pl/sql block does not COMMIT data to table

    I have the following PL/SQL block.
                             apps.create_po(x_org_id,x_document_num,x_agent_name,x_vendor_id,x_vendor_site_id,x_ship_to_location,x_bill_to_location,x_creation_date,new_isbn,new_print_key,new_unit_setup_cost,new_unit_run_cost,x_item,x_category_id,x_item_description,x_unit_of_measure,x_quantity,x_unit_price,x_ship_to_org_id,x_promise_date,x_qty_rcv_tolerance, x_deliver_to_location,x_destination_org_id, x_destination_subinventory,x_segment2,x_segment4);
                                  COMMIT;
    FND_GLOBAL.APPS_INITIALIZE(v_user_id,v_resp_id,201);
    v_po_req_id := apps.fnd_request.submit_request('PO','POXPOPDOI',NULL,NULL,NULL,
                                  NULL,'STANDARD',NULL,'Y',NULL,'APPROVED',NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
                                  DBMS_OUTPUT.PUT_LINE('Request ID is:' || v_po_req_id);
                                  IF v_po_req_id <> 0 THEN
                                       dbms_lock.sleep(60);
                                       dbms_output.Put_line('Sleep executed');
                                       COMMIT;
                                       select PHASE_CODE,STATUS_CODE INTO v_phase_code,v_status_code
                                       FROM FND_CONCURRENT_REQUESTS
                                       WHERE REQUEST_ID = v_po_req_id;
                                       dbms_output.put_line('After commit Phase and status codes are = '||v_phase_code || v_status_code);
                                  ELSE
                                       ROLLBACK;
                                  END IF;
                                  dbms_output.put_line('New Po is' || x_document_num);
                                  dbms_output.put_line('Quantity Is'|| x_quantity);
                                  apps.receive_po(x_document_num,x_quantity);
                                  v_rcv_req_id := apps.fnd_request.submit_request('PO','RVCTP',NULL,NULL,NULL,
                                  'BATCH',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
                                  NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL
                                  DBMS_OUTPUT.PUT_LINE('Request ID is:' || v_rcv_req_id);
                                  IF v_rcv_req_id <> 0 THEN
                                       COMMIT;
                                       DBMS_OUTPUT.PUT_LINE('COMMITED RECEIVING');
                                  ELSE
                                       ROLLBACK;
                                  END IF;
    Presently when this block runs, i can see the new PO number created. Commit is also successfully executed. The last output for the program is
    New Po is 20651
    Quantity Is 450
    But due to some reason, the receiving program(receive_po) cannot retrieve the same PO from the base table.
    But once this pl/sql block is complete, and i call the receving procedure from a different session, the Po is retrieved and receiving against the PO is executed successfully.
    Can someone please suggest a work around ? Is the code missing something ? Since POXPOPDOI is a concurrent program which is executed as an asyncronous process, the commit statement after the call to concurent program does not work but the commit is executed only after it exits the pl/sql block.

    Thanks for responding.
    receive_po() program just inserts the data into RCV_HEADERS_INTERFACE and RCV_TRANSACTIONS_INTERFACE tables based on the PO that is created in the previous step. So basically the new PO created has to be received and the receive_po() just inserts data into the interface tables so that RVCTP can be called after that for receiving.
    Here is the code for the procedure.
    SET SERVEROUTPUT ON;
    --FND_GLOBAL.APPS_INITIALIZE(3,20707,201);
    --Procedure for receiving interface to load data to RCV_HEADERS_INTERFACE and RCV_TRANSACTIONS_INTERFACE
    CREATE OR REPLACE PROCEDURE receive_po (x_ponum IN VARCHAR2,x_quantity IN NUMBER) AS
    v_vendor_site_id NUMBER;
    v_vendor_id NUMBER;
    v_agent_id NUMBER;
    v_ship_to_organization_id NUMBER;
    v_item_id NUMBER;
    v_uom_code varchar2(25);
    v_subinventory varchar2(25);
    v_ship_to_location_id NUMBER;
    BEGIN
    --header information in variables
    dbms_output.put_line('Entering Receiving Insert Procedure');
    dbms_output.put_line('Po number ='||x_ponum||'$');
    dbms_output.put_line('Quantity is ='||x_quantity||'$');
    select pvsa.vendor_site_id into v_vendor_site_id
    FROM po_headers_all pha,po_vendors pv, po_vendor_sites_all pvsa
    where pha.vendor_id = pv.vendor_id
    and pv.vendor_id = pvsa.vendor_id
    and pha.segment1 = x_ponum;
    dbms_output.put_line('Vendor Site ID is' ||v_vendor_site_id);
    select pv.vendor_id into v_vendor_id
    FROM po_headers_all pha,po_vendors pv, po_vendor_sites_all pvsa
    where pha.vendor_id = pv.vendor_id
    and pv.vendor_id = pvsa.vendor_id
    and pha.segment1 = x_ponum;
    dbms_output.put_line('Vendor ID is' ||v_vendor_id);
    select plla.SHIP_TO_ORGANIZATION_ID into v_ship_to_organization_id
    from PO_HEADERS_ALL pha, PO_LINE_LOCATIONS_ALL plla
    where pha.PO_HEADER_ID = plla.PO_HEADER_ID
    and pha.segment1 = x_ponum;
    dbms_output.put_line('Ship to org is' ||v_ship_to_organization_id);
    select agent_id into v_agent_id
    FROM po_headers_all
    WHERE segment1 = x_ponum;
    dbms_output.put_line('Agent ID is' ||v_agent_id);
    --printing header table information
    dbms_output.put_line('vendor id is:'||v_vendor_id);
    dbms_output.put_line('vendor site id is:'||v_vendor_site_id);
    dbms_output.put_line('agent id is:'||v_agent_id);
    dbms_output.put_line('ship to organization id is:'||v_ship_to_organization_id);
    --line information in variables
    --derive item id
    select pla.item_id into v_item_id
    from po_headers_all pha, po_lines_all pla
    where pha.po_header_id = pla.po_header_id
    and pha.org_id = pla.org_id
    and pha.segment1 = x_ponum;
    --derive uom
    select pla.unit_meas_lookup_code into v_uom_code
    from po_headers_all pha, po_lines_all pla
    where pla.po_header_id = pha.po_header_id
    and pla.org_id = pha.org_id
    and pha.segment1 = x_ponum;
    --derive subinventory
    select pda.destination_subinventory into v_subinventory
    from po_headers_all pha, po_lines_all pla,po_distributions_all pda
    where pha.po_header_id = pla.po_header_id
    and pla.po_header_id = pda.po_header_id
    and pla.po_line_id = pda.po_line_id
    and pha.org_id = pla.org_id
    and pla.org_id = pda.org_id
    and pha.segment1 = x_ponum;
    --derive ship to location id
    select ship_to_location_id into v_ship_to_location_id
    from po_headers_all
    where segment1 = x_ponum;
    --printing transaction table details
    dbms_output.put_line('item id is:'||v_item_id);
    dbms_output.put_line('UOM is:'||v_uom_code);
    dbms_output.put_line('subinventory is:'||v_subinventory);
    dbms_output.put_line('ship to location id is:'||v_ship_to_location_id);
    --insert data into the receiving interface header table
    INSERT INTO RCV_HEADERS_INTERFACE
    HEADER_INTERFACE_ID          ,
    GROUP_ID               ,
    PROCESSING_STATUS_CODE      ,
    RECEIPT_SOURCE_CODE          ,
    TRANSACTION_TYPE          ,
    LAST_UPDATE_DATE          ,
    LAST_UPDATED_BY          ,
    LAST_UPDATE_LOGIN,
    CREATION_DATE               ,
    CREATED_BY               ,
    VENDOR_ID               ,
    VENDOR_SITE_ID               ,
    SHIP_TO_ORGANIZATION_ID ,
    EXPECTED_RECEIPT_DATE          ,
    EMPLOYEE_ID               ,
    VALIDATION_FLAG          
    SELECT
    RCV_HEADERS_INTERFACE_S.NEXTVAL,
    RCV_INTERFACE_GROUPS_S.NEXTVAL,
    'PENDING',
    'VENDOR',
    'NEW', -- 'CANCEL',
    sysdate,
    3,
    3,
    sysdate,
    3,
    v_vendor_id,
    v_vendor_site_id,
    v_ship_to_organization_id,
    sysdate+5,
    v_agent_id,
    'Y'
    FROM DUAL;
    commit;
    --insert data into the interface transaction table
    for i in 1..1 loop
    INSERT INTO RCV_TRANSACTIONS_INTERFACE
    (INTERFACE_TRANSACTION_ID     ,
    HEADER_INTERFACE_ID     ,
    GROUP_ID               ,
    LAST_UPDATE_DATE          ,
    LAST_UPDATED_BY          ,
    CREATION_DATE               ,
    CREATED_BY               ,
    LAST_UPDATE_LOGIN,
    TRANSACTION_TYPE          ,
    TRANSACTION_DATE          ,
    PROCESSING_STATUS_CODE      ,
    PROCESSING_MODE_CODE          ,
    TRANSACTION_STATUS_CODE     ,
    QUANTITY               ,
    UNIT_OF_MEASURE          ,
    ITEM_ID ,
    AUTO_TRANSACT_CODE          ,
    RECEIPT_SOURCE_CODE          ,
    SOURCE_DOCUMENT_CODE          ,
    SUBINVENTORY               ,
    DOCUMENT_NUM               ,
    SHIP_TO_LOCATION_ID           ,
    VALIDATION_FLAG
    SELECT
    RCV_TRANSACTIONS_INTERFACE_S.NEXTVAL,
    RCV_HEADERS_INTERFACE_S.CURRVAL,
    RCV_INTERFACE_GROUPS_S.CURRVAL,
    SYSDATE,
    3,
    SYSDATE,
    3,
    3,
    'RECEIVE', --'RECEIVE', -- 'SHIP', --'06-JAN-1998',--question here
    sysdate,
    'PENDING',
    'BATCH',
    'PENDING',
    x_quantity,
    v_uom_code,
    v_item_id,
    'DELIVER', -- 'RECEIVE', --'DELIVER',
    'VENDOR',
    'PO',
    v_subinventory,
    x_ponum,
    v_ship_to_location_id,
    'Y'
    FROM DUAL;
    end loop;
    commit;
    END receive_po;
    I am really stuck and looking out for work arond. Please help.
    Thanks,
    Natasha

  • Can't create a sequence within a pl/sql block with execute immediate.

    Hi All. I created a user and granted it the 'create sequence' privilege though a role. In a pl/sql block I try to create a sequence using 'execute immediate' but get a 1031-insufficient privileges error. If I grant create sequence directly to the user, the pl/sql block completes successfully. Can anyone explain this behavior? We're running 11.2 Enterprise Editon.
    Thanks,
    Mark

    In a definer's rights stored procedure (the default), you only have access to privileges that have been granted directly, not via a role.
    There are two basic reasons for that. First, roles can be enabled or disabled, default and non-default, password-protected, etc. so the set of roles a particular user actually has is session-specific. Oracle needs to know at compile time what privileges the owner of the procedure has. The only way to do that (without deferring the privilege check) is to ignore privileges granted through roles.
    Second, since 99% of privilege management DBAs do involves granting and revoking roles, it's helpful that changing role privileges will never cause objects to be marked invalid and recompiled which can have side-effects on applications. DBAs only need to worry about causing problems on those rare cases where they are granting or revoking direct privileges to users.
    You can create an invoker's rights stored procedure by adding the clause (AUTHID CURRENT_USER). That defer's the security check to run-time but allows the procedure to see privileges granted through roles in the current session. But that means that the caller of the procedure would need to have the CREATE SEQUENCE privilege through the role, not the owner of the procedure.
    And just to make the point, dynamic object creation in PL/SQL is almost always a red flag that there is something problematic in your design. If you are creating sequences dynamically, that means that you'd have to refer to them dynamically throughout your code which means that your inserts would need to use dynamic SQL. That's not a particularly easy or safe way to develop code.
    Justin

  • Not able to display javascript alert message from within a pl/sql block

    Hello,
    Can anyone please help me out with this issue. I wanted to display an javascript alert message from within a pl/sql block for an update button. Below is sample code which i am using. P1_ITEM is my hidden item on the report.
    begin
    if :P1_ITEM IS NOT NULL then
    HTP.p ('<script type="text/javascript">');
    HTP.p ('alert(''Please complete the item which is already assigned to you!'');');
    HTP.p ('</script>');
    end if;
    end;
    and I have made this code to be executed conditionally when request = Expression1
    Expression1: SUBMIT
    The thing is I am not able to display an alert message when the update button is clicked.
    Can anyone please help me with this one.
    Thanks,
    Orton

    varad but I also have an update statement within that block for the update button something like this i want to achieve.
    begin
    if :P1_ITEM IS NULL THEN
    update sample_tbl
    set col1 =:APP_USER,
    col2 = 'Y'
    where pk_col = ---;
    commit;
    HTP.p ('<script type="text/javascript">');
    HTP.p ('alert(''Successfully assigned an item!'');');
    HTP.p ('</script>');
    end if;
    if :P1_ITEM IS NOT NULL then
    HTP.p ('<script type="text/javascript">');
    HTP.p ('alert(''Please complete the item which is already assigned to you!'');');
    HTP.p ('</script>');
    end if;
    end;
    thanks,
    Orton

  • Javascript function call from PL/SQL block

    Hello,
    I am writing this pl/sql block that has checkbox and onselect, it calls javascript function.
    I defined javascript function in page header, even though I get error that says function is not defined.
    Please help.
    Thank you,
    H.

    I got it resolved...!!!

  • Calling sql script from pl/sql block

    Hi
    I want to call a sql script from pl/sql block.
    like
    CREATE OR REPLACE procedure DataBaseExport(user_name in varchar2, pwd in varchar2)
    as
    begin
    execute immediate  '@ C:\Documents and Settings\umesh\emp.sql';
    end DataBaseExport;
    /

    Try something like this -
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "Host" AS
    import java.io.*;
    public class Host
         public static void executeCommand(String command)
         try {
                String[] finalCommand;
                   if (isWindows())
                        finalCommand = new String[4];
                        // Use the appropriate path for your windows version.
                        finalCommand[0] = "C:\\windows\\system32\\cmd.exe"; // Windows XP/2003
                        //finalCommand[0] = "C:\\winnt\\system32\\cmd.exe"; // Windows NT/2000
                        finalCommand[1] = "/y";
                        finalCommand[2] = "/c";
                        finalCommand[3] = command;
                   else
                        finalCommand = new String[3];
                        finalCommand[0] = "/bin/sh";
                        finalCommand[1] = "-c";
                        finalCommand[2] = command;
              final Process pr = Runtime.getRuntime().exec(finalCommand);
             pr.waitFor();
             new Thread(new Runnable()
                public void run()
                      BufferedReader br_in = null;
                   try
                        br_in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
                        String buff = null;
                        while ((buff = br_in.readLine()) != null)
                                  System.out.println("Process out :" + buff);
                               try {Thread.sleep(100); } catch(Exception e) {}
                        br_in.close();
                   catch (IOException ioe)
                        System.out.println("Exception caught printing process output.");
                        ioe.printStackTrace();
                 finally
                     try {
                              br_in.close();
                          } catch (Exception ex) {}
         ).start();
         new Thread(new Runnable()
           public void run()
                BufferedReader br_err = null;
                try
                   br_err = new BufferedReader(new InputStreamReader(pr.getErrorStream()));
                   String buff = null;
                   while ((buff = br_err.readLine()) != null)
                        System.out.println("Process err :" + buff);
                        try
                           Thread.sleep(100);
                         } catch(Exception e) {}
                   br_err.close();
               catch (IOException ioe)
                   System.out.println("Exception caught printing process error.");
                   ioe.printStackTrace();
              finally
                  try
                          br_err.close();
                   catch (Exception ex) {}
          ).start();
         catch (Exception ex)
                  System.out.println(ex.getLocalizedMessage());
      public static boolean isWindows()
              if (System.getProperty("os.name").toLowerCase().indexOf("windows") != -1)
              return true;
              else
              return false;
    CREATE OR REPLACE PROCEDURE Host_Command (p_command IN VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'Host.executeCommand (java.lang.String)';
    --- THE PERMISSIONS ---
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.io.FilePermission', '<<ALL FILES>>', 'read ,write, execute, delete');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    call dbms_java.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');And, finally,
    create or replace procedure call_sql_file(usr  in varchar2,
                                              pwd  in varchar2,
                                              host_str in varchar2)
    is
    begin
       host('sqlplus -s usr/pwd@host_str C:\UAX_Auto_Count.sql');
    exception
      when others then
        dbms_output.put_line(sqlerrm);
    end;Now, you can pass all the argument in order to execute that file.
    N.B.: Not Tested...
    Regards.
    Satyaki De.

Maybe you are looking for

  • Content is not allowed in Prolog error while configuring File to Mail

    Hi Expert, I have a scenario where I have to pick up a file from FTP using sender File adapter and send this file as an attachment using Receiver Mail adapter. There are 3 requirements : 1) File name of the attachment in the Mail should be same as th

  • Making PDFs Fillable - Why are they 3xs the size of the Original w/Acrobat Pro 9

    What I'm Doing: I have been creating documents out of InDesign that I export to PDF Format and then go into Acrobat 9.0 Pro to make fillable.  In Acrobat 9.0, I'll begin with a PDF that is around 1M.  Normally, once the fields are added it may increa

  • Ags_work_incident_create_app - Unable to maintain system and client

    Hi, When creating a support message from the Incident work center, the fields system and client are greyed out and thus not maintainable. I have no problems creating support messages using the SAPWEBGUI or through transaction NOTIFCREATE, it is only

  • MacBook Air problem please help.

    This is soooo frustrating... I have just turned my MBA on and I had my Samsung camera plugged in. A message came up, and it was the Bluetooth tool trying to find a keyboard?..... I have no idea why I have never used a Bluetooth keyboard....... And at

  • Need some help with a small issue.

    Im running my computer with a K8T Neo2, a Gigabyte Maya II R9700Pro, and 4x512 400 Mhz memorys (Unsure about the label.). Recently i also purshased & installed a Creative X-Fi Platinum (Togheter with the sound system i bought a few days earlier.) Als