Execute Storage Procedures Parallely

Hi,
I have a list of procedure's name in database table ProcList.
ProcList Table Contents are given below.
SrNo. ProcName
1 FetchData
2 ProcessData
3 InsertData
This all the procedures name I have to fetch from the table & execute all the procedure parallely. I can use dbms_job packet for that but the procedures name are dynamically fetch from the database table. so I'm not able to use it.
Can anybody help how to do it? Any help will be appreciable.

It will wait for the 1st procedure to complete the
interation. If I statically provide two procedures
name using dbms_job then it will execute parallely
(without loop iteration).What will wait? Submitting jobs should take no time in you calling procedure. DBMS_JOB is transactional, so you need to commit before it runs. I think you also need the semi colon in the call.
Can you run this test and see if you get the same results:
SQL>select * from v$version;
BANNER
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
PL/SQL Release 9.2.0.8.0 - Production
CORE    9.2.0.8.0       Production
TNS for 64-bit Windows: Version 9.2.0.8.0 - Production
NLSRTL Version 9.2.0.8.0 - Production
Elapsed: 00:00:00.00
SQL>
SQL>CREATE OR REPLACE PROCEDURE FetchData AS
  2  BEGIN
  3    dbms_lock.sleep(30);
  4  END;
  5  /
Procedure created.
Elapsed: 00:00:00.00
SQL>
SQL>CREATE OR REPLACE PROCEDURE ProcessData AS
  2  BEGIN
  3    dbms_lock.sleep(30);
  4  END;
  5  /
Procedure created.
Elapsed: 00:00:00.00
SQL>
SQL>CREATE OR REPLACE PROCEDURE StoreData AS
  2  BEGIN
  3    dbms_lock.sleep(30);
  4  END;
  5  /
Procedure created.
Elapsed: 00:00:00.00
SQL>
SQL>CREATE OR REPLACE PROCEDURE JobTestProc
  2  AS
  3    nJob user_jobs.job%TYPE;
  4  BEGIN
  5    FOR rJob IN (SELECT 'FETCHDATA;' what FROM dual
  6                 UNION ALL
  7                 SELECT 'PROCESSDATA;' FROM dual
  8                 UNION ALL
  9                 SELECT 'STOREDATA;' FROM dual
10                )
11    LOOP
12      dbms_job.submit(nJob,rJob.what);
13      COMMIT;
14      dbms_output.put_line ('Job: '||TO_CHAR(nJob)||' - '||rJob.what||' Submitted');
15    END LOOP;
16  END JobTestProc;
17  /
Procedure created.
Elapsed: 00:00:00.00
SQL>sho err
No errors.
SQL>exec JobTestProc
Job: 3438 - FETCHDATA; Submitted
Job: 3439 - PROCESSDATA; Submitted
Job: 3440 - STOREDATA; Submitted
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.09
SQL>
SQL>SELECT job, what, total_time
  2  FROM   user_jobs;
       JOB WHAT                                                                   TOTAL_TIME
      3439 PROCESSDATA;                                                                    0
      3440 STOREDATA;                                                                      0
      3438 FETCHDATA;                                                                      0
Elapsed: 00:00:00.00
SQL>/
       JOB WHAT                                                                   TOTAL_TIME
      3439 PROCESSDATA;                                                                    1
      3440 STOREDATA;                                                                      1
      3438 FETCHDATA;                                                                      1
Elapsed: 00:00:00.00
SQL>/
       JOB WHAT                                                                   TOTAL_TIME
      3439 PROCESSDATA;                                                                    6
      3440 STOREDATA;                                                                      6
      3438 FETCHDATA;                                                                      6
Elapsed: 00:00:00.00
SQL>/
       JOB WHAT                                                                   TOTAL_TIME
      3439 PROCESSDATA;                                                                   12
      3440 STOREDATA;                                                                     12
      3438 FETCHDATA;                                                                     12
Elapsed: 00:00:00.00
SQL>/
       JOB WHAT                                                                   TOTAL_TIME
      3439 PROCESSDATA;                                                                   17
      3440 STOREDATA;                                                                     17
      3438 FETCHDATA;                                                                     17
Elapsed: 00:00:00.00
SQL>/
       JOB WHAT                                                                   TOTAL_TIME
      3439 PROCESSDATA;                                                                   24
      3440 STOREDATA;                                                                     24
      3438 FETCHDATA;                                                                     24
Elapsed: 00:00:00.00
SQL>/
       JOB WHAT                                                                   TOTAL_TIME
      3439 PROCESSDATA;                                                                   28
      3440 STOREDATA;                                                                     28
      3438 FETCHDATA;                                                                     28
Elapsed: 00:00:00.00
SQL>/
no rows selected
Elapsed: 00:00:00.00
SQL>

Similar Messages

  • Wether "CREATE TABLE"  can be used in storage procedure of Oracle?

    I am migrating MS SQL 2000 Database to Oracle 8.1.7. But I encounter a trouble, the defind sentences of temporary table in storage procedure of MS SQL can't be migrate to oracle.
    I have try two kinds of syntax to defind temporary table, but both of them can't pass the compiler of pl/sql. Two syntax that I have try as follows:
    1.CREATE TEMP TABLE chanp1(chanpid varchar(50))
    2.CREATE GLOBAL TEMPORARY TABLE chanp1(chanpid varchar(50))
    Now, I want to know whether "CREATE TABLE" sentence can be used in storage procedure of Oracle.

    you could use EXECUTE IMMEDIATE (Oracle8i above) or DBMS_SQL pacakge to do dynamic SQL.
    since you are already on Oracle8i 8.1.7 using EXECUTE IMMEDIATE may be more easy.

  • Execute any procedure???

    Inorder to execute the job at the allotted time the user need to be able to create a procedure and execute it.
    but is execute any procedure privilege required to enable scheduling???
    what could be the reason??
    this allow the user to run procedures created by other users, right?

    Hi Visakh
    From my own notes here is what I have:
    Setting up Workbook Scheduling
    ==============================
    The workbook scheduling feature in Discoverer uses native features in the Oracle DBMS, and is therefore only available when running against the Oracle database. This feature uses the same highly scalable and reliable processing procedures within the kernel, since the summary management capability and the setup for both features is similar. These procedures use standard packages in the DBMS called DBMS_JOB.
    To enable the processing procedures for workbook scheduling in Discoverer, follow these steps:
    A. Grant Schedule Workbook Privilege to the user.
    B. Confirm that DBMS_JOBS has been installed.
    C. Specify result set storage.
    D. Set the time period at which the process kicks in.
    These procedures are described in the following sections:
    A.  Grant Schedule Workbook Privilege to the User
    The user must be granted the Schedule Workbooks privilege in the Privileges dialog. Connect to the Administration Edition, and grant the Schedule Workbooks privilege in Tools | Privileges dialog.
    B.   Confirming that DBMS_JOBS is Installed
    1. Log onto SQL*Plus as the Administrator, and execute the following SQL statement:
    SQL> select * from all_objects where object_name='DBMS_JOB' and object_type = 'PACKAGE';
    2. If you get no rows returned you need to install this package. Your DBA will know how to do it.
    C.  Specifying Result Set Storage
    When a scheduled workbook is run, the results are stored in database tables within the database. The resulting data created as part of the workbook scheduling process may be stored in one of two areas: the user's own schema or a centralized schema.
    User's Schema
    In order to enable workbook scheduling in the user's own database schema, the user requires the following database privileges:
    Create Procedure - needed to create the job
    Create Table - needed to create tenporary holding table(s) for the results, each run of the same scheduled worksheet produces a new temporary table - see general notes at end for more help
    Create View - needed to pull the results from the database
    You will also need these three grants:
    SELECT ON SYS.V_$PARAMETER;
    EXECUTE ON SYS.DBMS_JOB; won't be able to execute the job without this
    UNLIMITED TABLESPACE; needed to stop user's schema running out of space while creating the table(s) of results. Discoverer does not leave it to the DBA to set artificial limits. The only way it knows for certain that it will have enough is to have this privilese.
    As you can see, execute any procedure is not needed.
    When the schedule is first created a view is created. This allows Discoverer to run that view at the scheduled time using whatever conditions and parameters you have set. The results are populated into the table when the query is run. If you subsequently have multiple sets of results you will see them named T1, T2 and so on.
    To grant these privileges, do the following:
    1. Log onto SQL*Plus or SQLDBA as the Database Administrator.
    2. Type the following:
    SQL> Grant CREATE PROCEDURE to <USER>;
    SQL> Grant CREATE TABLE to <USER>;
    SQL> Grant CREATE VIEW to <USER>;
    where <USER> is the userid of the person who is to be allowed to schedule workbooks.
    These privileges must be granted directly to the user and not to a database role.
    Advantages: A database limit can be specified on the maximum amount of data a user can store in the database. If the result set is stored under the user's schema, then you keep control over the maximum amount of space one individual user can fill with result sets. If the user creates a scheduled workbook that fills that space, it affects only his/her own scheduled workbook.
    Disadvantage: The user is required to have the above privileges in the database.
    Repository User's Schema
    In order to enable workbook scheduling using a centralized repository user's schema, the SQL script batchusr.sql must be run in SQL*Plus or SQLDBA as a database administrator (such as, SYSTEM). This script creates a new user that is granted the above privileges.
    In addition, the administrator of the EUL must change the user so that the Repository User property is pointing to the repository user's schema just created. The centralized repository user's schema may be customized by the database administrator for space management purposes and underlying data access.
    NOTE: SELECT ANY TABLE access is given by the script batchusr.sql, but this may be limited provided the repository user's schema is granted access to the underlying data that will be accessed for workbook scheduling.
    The repository user created will not be able to directly schedule a workbook through the User Edition.
    Advantages: Each user does not need DML procedures to run scheduled workbooks.
    Disadvantages: One user can potentially run a scheduled workbook that fills the available result set space, preventing other scheduled workbooks from running until it is cleared.
    D.  Setting the Start Time for Workbook Processing
    The workbook processes run within the database on the server, and are controlled by parameters in the initialization file of the Oracle DBMS - the INIT<SID>.ORA file.
    To limit the number of processing requests that can run simultaneously:
    The parameter job_queue_processes specifies the number of concurrent processes to use to process DBMS_JOB. It controls the number of processing requests that can be handled simultaneously. The default value is zero, which means processing requests will not be created. You should set it to a minimum of 2 or more if you have any other applications that use DBMS_JOB.
    You need more than one job queue process, because if one job fails for any reason, it may keep getting re-submitted, and thus, prevent everything else in the queue from being completed. If you want to have 10 simultaneous processing requests handled, then you will need to set this to 10.
    The INIT<SID>.ORA parameter job_queue_interval is the time in seconds that controls how often the job processes wake up to process pending jobs. The default is 60, which is quite frequent. What you set this to depends on how frequently you want the process to wake up and serve the requests that have been made. Oracle recommends that you update the 60 seconds default to at least 10 minutes (a value of 600).
    NOTE: This parameter also affects summary management.
    To enable these parameters:
    1. Locate the INIT<SID>.ORA file.
    For example, on Personal Oracle7 the INIT<SID>.ORA file is held in <ORACLE_HOME>\database. Its default name is INITORCL.ORA where ORCL is the <SID> name.
    2. Enter 2 lines into the file. For example:
    job_queue_processes = 2
    job_queue_interval = 600 (equivalent to 10 minutes)
    GENERAL NOTES:
    The summary management and workbook scheduling features both use this scheduling capability within the Oracle DBMS. The interval you specify and the number of concurrent requests affect both features.
    The results from the worksheet are held in a temporary table until you remove the results or you delete the scheduled workbook.
    Tables look like this: EUL5_B060914015847Q1R1
    Views look like this: EUL5_B060914015847Q1V1
    These temporary tables are stored within the schema of the user who owns the workbook - not within the standard EUL schema. The format of the table is as follows:
    EUL5_B060914015847Q1R1 which can be broken into six separate pieces.
    These pieces are as follows:
    EUL5_ B YYMMDD HHMISS Q9 R9, where
    EUL5_ is a fixed name
    B means Batch and is a constant
    YYMMDD is the date that the worksheet was run,
    HHMISS is the time when the worksheet was run, the time is in the 24 hour clock format,
    Q9 means this is the letter Q followed by a number - E.g. Q1, which signifies the query number. I believe Oracle have some plans to allow multiple queries but for now this is always Q1,
    R9 means this is the letter R followed by a number - E.g. R1, R2 and so on. This is the run number.
    Using the above logic therefore, this is a valid example:
    EUL5_B090914015847Q1R1
    This means this is result set number 1 for query 1, run at 1:58:46 AM on 14th September 2009.
    So if you can figure out which worksheet was scheduled and when it was run you can build a view that sits on top of the latest table to give you the latest results. Something else which adds interest here is that the column names within the table do not match the column names as in your original query. The scheduled results column names use generic names such as BRVC1, BRVC2, BRD1, BRD2, BRN1 and BRN2.
    These are codes and can be interpreted as follows:
    BRCV1 and BRCV2 mean Batch Result Var Char 1 and 2,
    BRD1 and BED2 mean Batch Result Date 1 and 2,
    BRN1 and BEN2 mean Batch Result Number 1 and 2
    Best wishes
    Michael

  • Error While executing a procedure

    Hello FOlks,
    When i try to execute this procedure below i get the error saying "Compiled with errors"
    ORA--00942-Table or View does not exist
    SQL Statement ignored at Line 17.
    I tried querying the table and it returns no data. How do i debug this error.
    create or replace procedure Load_FADM_Staging_Area_test(p_data_load_date date) is
    v_start_date                date;
    v_end_date                  date;
    begin
    if  p_data_load_date is null then
        select (sysdate - 7), (sysdate - 1) into v_start_date, v_end_date from dual;
      elsif p_data_load_date is not null then
       select (p_data_load_date - 7), (p_data_load_date - 1) into v_start_date, v_end_date from dual;
      else
        raise_application_error('-20042', 'Data control - GetDataControlAuditData : Date parameter must be a date of this or a previous week.');
      end if;
    insert into STAGE_FADM_HRI_STAGE_BILL
    (select
    a.batch_id 
    ,a.beginning_service_date 
    ,a.bill_id 
    ,a.bill_method 
    ,a.bill_number 
    ,a.bill_received_date 
    ,a.bill_status 
    ,a.bill_type 
    ,a.change_oltp_by 
    ,a.change_oltp_date 
    ,a.client_datafeed_code 
    ,a.client_id 
    ,a.created_date 
    ,a.date_of_incident 
    ,a.date_paid 
    ,a.deleted_oltp_by 
    ,a.deleted_oltp_date 
    ,a.duplicate_bill 
    ,a.ending_service_date 
    ,a.event_case_id 
    ,a.event_id 
    ,a.from_oltp_by 
    ,a.oltp_bill_status 
    ,a.review_status 
    ,'HRI' schema_name
    , sysdate Load_date
    ,'ETLPROCESS001' Load_user
    ,sysdate
    from stage_bill@hri1_read_only_remote a
    where
    --created_date >= to_date('20101031 235959', 'YYYYMMDD HH24MISS')
    created_date >= v_start_date
    and
    --created_date <= to_date('20101111 235959', 'YYYYMMDD HH24MISS')
      created_date <= v_end_date
    and not exists
    (select
    b.batch_id 
    ,b.beginning_service_date 
    ,b.bill_id 
    ,b.bill_method 
    ,b.bill_number 
    ,b.bill_received_date 
    ,b.bill_status 
    ,b.bill_type 
    ,b.change_oltp_by 
    ,b.change_oltp_date 
    ,b.client_datafeed_code 
    ,b.client_id 
    ,b.created_date 
    ,b.date_of_incident 
    ,b.date_paid 
    ,b.deleted_oltp_by 
    ,b.deleted_oltp_date 
    ,b.duplicate_bill 
    ,b.ending_service_date 
    ,b.event_case_id 
    ,b.event_id 
    ,b.from_oltp_by 
    ,b.oltp_bill_status 
    ,b.review_status
    ,b.Row_Effective_Date
    from STAGE_FADM_HRI_STAGE_BILL b))
    select
    e.action_plan  e_action_plan
    ,e.action_plan_status e_action_plan_status
    ,e.batch_id e_batch_id
    ,e.client_cause_code e_client_cause_code
    ,e.client_id e_client_id
    ,e.client_datafeed_code e_client_datafeed_code
    ,e.client_policy_identifier e_client_policy_identifier
    ,e.close_date e_close_date
    ,e.created_date e_created_date
    ,e.date_of_incident e_date_of_incident
    ,e.date_typed e_date_typed
    ,e.discovery_source e_discovery_source
    ,e.employer_group_id e_employer_group_id
    ,e.event_id e_event_id
    ,e.event_status_code  e_event_status_code
    ,e.event_type_code e_event_type_code
    ,e.exclude_from_invoice e_exclude_from_invoice
    ,e.from_ncoa_date e_from_ncoa_date
    ,e.group_contract_funding_type e_group_contract_funding_type
    ,e.hmo_ppo_indemnity_type e_hmo_ppo_indemnity_type
    ,e.insurance_product_name e_insurance_product_name
    ,e.insured_termination_date e_insured_termination_date
    ,e.invoice_date e_invoice_date
    ,e.letter_status e_letter_status
    ,e.letter_status_date e_letter_status_date
    ,e.liability_analysis e_liability_analysis
    ,e.loss_city e_loss_city
    ,e.loss_description e_loss_description
    ,e.loss_state_code e_loss_state_code
    ,e.manually_moved e_manually_moved
    ,e.moved_by_user_id e_moved_by_user_id
    ,e.ncoa_code e_ncoa_code
    ,e.next_steps e_next_steps
    ,e.open_date e_open_date
    ,e.policy_holder_address1 e_policy_holder_address1
    ,e.policy_holder_address2 e_policy_holder_address2
    ,ec.action_plan
    ,ec.action_plan_status
    ,ec.batch_id
    ,ec.case_status_code
    ,ec.client_datafeed_code
    ,ec.client_id
    ,ec.client_party_identifier
    ,ec.close_date
    ,ec.created_date
    ,ec.damaged_party_address1
    ,ec.damaged_party_address2
    ,ec.damaged_party_city
    ,ec.damaged_party_dob
    ,ec.damaged_party_first_name
    ,ec.damaged_party_gender
    ,ec.damaged_party_last_name
    ,ec.damaged_party_ssn
    ,ec.damaged_party_state_code
    ,ec.damaged_party_zip
    ,ec.deductible
    ,ec.deductible_applied
    ,ec.deductible_recovered
    ,ec.deductible_recovered_full
    ,ec.event_case_id
    ,ec.event_id
    ,ec.fee_schedule_code
    ,ec.internal_coverage_code
    ,ec.litigation_flag
    ,ec.loss_injury_description
    ,ec.next_steps
    ,ec.open_date
    ,ec.payment_coverage_code
    ,ec.pursuit_level_code
    ,ec.reject_code
    ,ec.reject_comments
    ,ec.reject_date
    ,ec.reject_date
    ,ec.reject_user_id
    ,ec.setup_type
    ,ec.tot_paid_at_close
    ,eccf.Client_field_data  eccf_client_fleld_data
    ,eccf.Client_field_name eccf_client_field_name
    ,eccf.Client_id eccf_client_id
    ,eccf.Event_case_id eccf_event_case_id
    ,ecf.client_field_data  ecf_client_field_data
    ,ecf.client_field_name ecf_client_field_name
    ,ecf.client_id ecf_client_id
    ,ecf.event_id  ecf_event_id
    from
    event@hri1_read_only_remote e,
    event_case@hri1_read_only_remote ec,
    event_case_client_field@hri1_read_only_remote eccf,
    event_client_field@hri1_read_only_remote ecf,
    stg_fadm_hri_stage_bill sb
    where
    e.event_id = ec.event_id and
    e.event_id = ecf.event_id  and
    ec.event_case_id = eccf.event_case_id and
    e.event_id = ecf.event_id and
    e.client_id = ecf.client_id and
    e.client_id = ec.client_id and
    ec.client_id = ecf.client_id and
    e.event_id = sb.event_id  and
    ec.event_case_id = sb.event_case_id and
    eccf.event_case_id = sb.event_case_id and
    ecf.event_id = sb.event_id;
    end Load_FADM_Staging_Area_TEST;

    Just noticed
    I tried querying the table and it returns no data.Could be your NOT EXISTS clause, you are missing something? - "Something" exists, unless the table is empty.
    Should probably be something like:
    AND NOT EXISTS (SELECT NULL -- You are actually not selecting anything, just probing for existence
                      WHERE  <<Correlation to table "a">>Furthermore, you'll never manage to compile the procedure since your second select does not select INTO anything.
    (A more apprpriate subject would be "Error while compiling a procedure".)
    Finally, When would the ELSE be reached here?
    if p_data_load_date IS NULL then
        select (sysdate - 7), (sysdate - 1) into v_start_date, v_end_date from dual;
    elsif p_data_load_date IS NOT NULL then
        select (p_data_load_date - 7), (p_data_load_date - 1) into v_start_date, v_end_date from dual;
    ELSE
        raise_application_error('-20042', 'Data control - GetDataControlAuditData : Date parameter must be a date of this or a previous week.');
    end if;Regards
    Peter

  • Error while executing a procedure in Package

    ORA-04068: existing state of packages has been discarded
    ORA-04061: existing state of package "PLLODS.LK" has been invalidated
    ORA-04065: not executed, altered or dropped package "PLLODS.LK"
    ORA-06508: PL/SQL: could not find program unit being called
    ORA-06512: at line 1Why did this error arise when I changed a package and recompiled?

    This errors occurs when a package was executed in session A, compiled in session B, and then executed again in session A. The package executed in session A is in Oracle buffer, but its definition was changed in session B (which session A is unaware of). Now session A uses the old definition of the package but Oracle checks what is in buffer to the new definition and finds a difference. Therefore, it generates an error:
    ORA-04068: existing state of packages has been discarded
    and other related errors.
    Just execute the procedure (in the package) again and you should not see the error again.
    Make sure the stae of the package is valid, that is, when it was recompiled, the package compiled successfully.
    Shakti
    http://www.impact-sol.com
    Developers of Guggi Oracle - Tool for Developers and DBAs

  • PL/SQL: Executing a procedure from within another procedure

    Hello, I'm a newbie and I need help on how to execute procedures from within another procedure. The procedure that I call from within the procedure have return values that I want to check.
    I tried: EXECUTE(user_get_forum_info(p_forumid, var_forum_exists, var_forum_access, var_forumname));
    but I get the error message:
    PLS-00103: Encountered the symbol "USER_GET_FORUM_INFO" when expecting one of the following::= . ( @ % ; immediate
    The symbol ":=" was substituted for "USER_GET_FORUM_INFO" to continue.
    And when I tried: EXECUTE(user_get_forum_info(p_forumid, var_forum_exists, var_forum_access, var_forumname));
    I get the error message:
    PLS-00222: no function with name 'USER_GET_FORUM_INFO' exists in this scope
    PL/SQL: Statement ignored
    The procedure USER_GET_FORUM_INFO exists. (don't understand why it says "no FUNCTION with name", it's a procedure I'm executing)
    I'm stuck so thanks for any help...
    Below is all the code. I'm using Oracle 9i on RedHat Linux 7.3.
    ================================================================================
    CREATE OR REPLACE PROCEDURE user_forum_requestsaccess (
    p_forumid IN NUMBER,
    p_requestmessage IN VARCHAR2
    AS
    var_forumid NUMBER;
    var_forum_exists NUMBER;
    var_forum_access NUMBER;
    request_exists NUMBER;
    var_forumname VARCHAR2(30);
    FORUM_DOESNT_EXIST EXCEPTION;
    FORUM_USER_HAS_ACCESS EXCEPTION;
    FORUM_REQUEST_EXIST EXCEPTION;
    BEGIN
    SELECT SIGN(NVL((SELECT request_id FROM forum.vw_all_forum_requests WHERE forum_id = p_forumid AND db_user = user),0)) INTO request_exists FROM DUAL;
    EXECUTE(user_get_forum_info(p_forumid, var_forum_exists, var_forum_access, var_forumname));
    IF var_forum_exists = 0 THEN
    RAISE FORUM_DOESNT_EXIST;
    ELSIF var_forum_access = 1 THEN
    RAISE FORUM_USER_HAS_ACCESS;
    ELSIF request_exists = 1 THEN
    RAISE FORUM_REQUEST_EXIST;
    ELSE
    INSERT INTO tbl_forum_requests VALUES (SEQ_TBL_FORUM_REQ_REQ_ID.NEXTVAL, SYSDATE, p_requestmessage, p_forumid, user);
    INSERT INTO tbl_forum_eventlog VALUES (SEQ_TBL_FORUM_EVNTLOG_EVNT_ID.NEXTVAL,SYSDATE,1,'User ' || user || ' requested access to forum ' || var_forumname || '.', p_forumid,user);
    COMMIT;
    END IF;
    EXCEPTION
    WHEN
    FORUM_DOESNT_EXIST
    THEN RAISE_APPLICATION_ERROR(-20003,'Forum doesnt exist.');
    WHEN
    FORUM_USER_HAS_ACCESS
    THEN RAISE_APPLICATION_ERROR(-20004,'User already have access to this forum.');
    WHEN
    FORUM_REQUEST_EXIST
    THEN RAISE_APPLICATION_ERROR(-20005,'A request to this forum already exist.');
    END;
    GRANT EXECUTE ON user_forum_requestsaccess TO forum_user;
    ================================================================================
    Regards Goran

    you don't have to use execute when you want to execute a procedure (only on sql*plus, you would use it)
    just give the name of the funtion
    create or replace procedure test
    as
    begin
        dbms_output.put_line('this is the procedure test');
    end test;
    create or replace procedure call_test
    as
    begin
        dbms_output.put_line('this is the procedure call_test going to execute the procedure test');
        test;
    end call_test;
    begin
        dbms_output.put_line('this is an anonymous block calling the procedure call_test');
        call_test;
    end;
    /

  • How to execute a procedure in the same db session of the framework page

    i am using oaframework personalization to create a link. when the link is clicked i will execute a database procedure using /psl/DAD/procedurename. currently when the user clicks on the link it will get executed in separate database session.
    but i want execute the procedure in the db session on the current oa page. is there a way to achive this.
    Thanks
    sreekanth.g

    You can do this, create a simple stackLayout region, add an AM, Controller to it. Add a submit button or link with fireAction set on it. Write a method in your AM and call it from your controller's processFormRequest by capturing the button or link event. In the AM method you can invoke the procedure. Use personalization and attach the region to the page.

  • How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?

    Hi 
    I have a stored procedure. It can be executed like this
    exec test @p = 1;
    exec test @p = 2
    exec test @p = n;
    n can be hundred.
    I want the sp being executed in parallel, not sequence. It means the 3 examples above can be run at the same time.
    If I know the number in advance, say 3, I can create 3 different Execution SQL Tasks. They can be run in parallel.
    However, the n is not static. It is coming from a table. 
    How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?
    I think about using script task. In the script, I get the value of n, and the list of p, from the table, then running a loop with. In the loop, I create a threat and in the threat, I execute the sp like : exec test @p = p. So the exec test may
    be run parallel. But I am not sure if it works.
    Any idea is really appreciated.

    Hi nam_man,
    According to your description, you want to call stored procedures in parallel, right?
    In SSIS, we can create separate jobs with different stored procedures, then set the same schedule to kick the jobs off at the same time. In this way, we should be careful to monitor blocking and deadlocking depending on what the jobs are doing.
    We can also put all stored procedures in SSIS Sequence container, then they will be run in parallel.
    For more information about SSIS job and Sequence container, please refer to the following documents:
    http://www.mssqltips.com/sqlservertutorial/220/scheduling-ssis-packages-with-sql-server-agent/
    https://msdn.microsoft.com/en-us/library/ms139855(v=sql.110).aspx
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

  • How to execute a procedure depending on the result of a query?

    Hello, I'm new in ODI.
    I want to execute a procedure depending on the result of a query Oracle table.
    We have a Oracle Table whit a column that contains two possibles values.
    I want read the table, row by row, and depending on this value, execute a Procedure or execute another.
    How can i do?

    what you need to do is
    1. create a variable which "new_var2" which has the count of the number of rows you want to process. must be data type numeric.
    2. copy "new_var2" to the package screen.
    3. duplicate the "new_var2" on the package screen and evaluate the variable and test for "> 0" zero, call it "new_var2_E"
    3. create a new odi variable "new_var1" with a refresh of "select field1 fom (select field1,rownum as rownumber from tablex) where rownumber = #new_var2" in the relevant schema and technology.
    4. copy "new_var1" into your package (some where in the flow)
    5. right click the "new_var1" variable in you package screen and you should get the option duplicate step (click on that)
    6. select the the duplicate "new_var1" on the package screen and correct the the name to something meaning full to you "new_var1_E", also change the "type" to "evaluate variable" then you should see a "value" box. enter one of the values you want to test in the box (remember do not put in quotes ' )
    7. now back on the package screen join the "new_var1" to the "new_var1_E" with an OK line
    8 you now join "new_var2" to "new_var2_E" with OK
    9 you join "new_var2_E" to "new_var1"
    10. you then join the "new_var1_E" with an OK or a KO line to the relevant procedure.
    12. you need to duplicate "new_var2" in the package screen one more time this time and call it "new_var2_D" set the type to evaluate and then select the increment of -1
    13. the relevant procedure to "new_var2_D" with an OK
    14. join the "new_var2_D" to the "new_var2_E" with an OK
    15. this should close off the loop now the exit point is "new_var2_E" with a KO line to the next part of your process....
    Basically you should end up with a loop on new_var2 decementing, and it is used to get a specific next record row from your table.
    Hope this helps, sorry it is a little long winded..
    Edited by: DavidGD on Feb 8, 2009 3:29 PM

  • Error in executing a procedure

    Hello All,
    I am trying to use an update statement in PL/SQL procedure with some date parameters.
    Can anyone please tell me whats wrong with the syntax.
    Also please suggest any better ways to do this.
    Thanks a lot in advance.
    PROCEDURE
    CREATE OR REPLACE procedure NEW_PROGRAM_test(Enter0_if_this_Mon_ELSE_entr1 IN integer)
    is
    start_date date;
    end_date_1 date;
    end_date_3 date;
    begin
    if Enter0_if_this_Mon_ELSE_entr1:= 0 then
    start_date := trunc(add_months(LAST_DAY(SYSDATE)+1, -1));
    end_date_1 := trunc((add_months(LAST_DAY(SYSDATE), 0)));
    end_date_3 := trunc(add_months(LAST_DAY(SYSDATE), 2));
    elsif
    Enter0_if_this_Mon_ELSE_entr1:= 1
    then
    start_date := trunc(add_months(LAST_DAY(SYSDATE)+1, 0));
    end_date_1 := trunc((add_months(LAST_DAY(SYSDATE), 1)));
    end_date_3 := trunc(add_months(LAST_DAY(SYSDATE), 3));
    else
    {dbms_output.put_line('This is invalid, please retry!');
    End if;
    Update mytable1 m1
    set AT_EXP_FLAG ='Y'
    where
    --expiration_date between to_date('01-AUG-2006', 'DD-MON-YYYY') and to_date('31-OCT-2006', 'DD-MON-YYYY')
    expiration_date between start_date and end_date_3
    and exists (select contact_id
    from mytable1 m2
    where
    --((extract(year from expiration_date)=CURRENT_YEAR_AS_4digits) and (extract(month from expiration_date) = (CURRENT_MONTH_AS_2digits+1)))
    -- m2.expiration_date between to_date('01-AUG-2006', 'DD-MON-YYYY') and to_date('31-AUG-2006', 'DD-MON-YYYY')
    (m2.expiration_date between startdate and end_date_1) and (m2.contact_id = m1.contact_id));
    end;

A: Error in executing a procedure

Thank Every one,
I have taken out the curly braces { } and changed the assignment operator to comparision operator. The procedure compiles without any errors.
However, I have declared variables(start_date, End_date_1 and End_date_3). How do I use them in the statement below:
Statement
(m2.expiration_date between to_date('startdate', 'DD-MON-YYYY') and to_date('end_date_1', 'DD-MON-YYYY'))
When I use this as is, and execute the procedure with 1 as input parameter I am getting this error:
ERROR
ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at "DBUSER.NEW_PROGRAM_TEST", line 28
ORA-06512: at line 7
Here is the complete proc:
CREATE OR REPLACE procedure NEW_PROGRAM_test(Enter0_if_this_Mon_ELSE_entr1 IN integer)
is
start_date date;
end_date_1 date;
end_date_3 date;
begin
IF Enter0_if_this_Mon_ELSE_entr1= 0 then
start_date := trunc(add_months(LAST_DAY(SYSDATE)+1, -1));
end_date_1 := trunc((add_months(LAST_DAY(SYSDATE), 0)));
end_date_3 := trunc(add_months(LAST_DAY(SYSDATE), 2));
elsif
Enter0_if_this_Mon_ELSE_entr1= 1 then
start_date := trunc(add_months(LAST_DAY(SYSDATE)+1, 0));
end_date_1 := trunc((add_months(LAST_DAY(SYSDATE), 1)));
end_date_3 := trunc(add_months(LAST_DAY(SYSDATE), 3));
else
     dbms_output.put_line('This is invalid, please retry!');
End if;
Update mytable1 m1
set AT_EXP_FLAG ='Y'
where
expiration_date between start_date and end_date_3
and exists (select contact_id
from mytable1 m2
where
          (m2.expiration_date between to_date('startdate', 'DD-MON-YYYY') and to_date('end_date_1', 'DD-MON-YYYY'))
-- (m2.expiration_date between 'startdate' and 'end_date_1')
          and (m2.contact_id = m1.contact_id));
end;
Please suggest ..
Thanks in advance.
Ac

Thank Every one,
I have taken out the curly braces { } and changed the assignment operator to comparision operator. The procedure compiles without any errors.
However, I have declared variables(start_date, End_date_1 and End_date_3). How do I use them in the statement below:
Statement
(m2.expiration_date between to_date('startdate', 'DD-MON-YYYY') and to_date('end_date_1', 'DD-MON-YYYY'))
When I use this as is, and execute the procedure with 1 as input parameter I am getting this error:
ERROR
ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at "DBUSER.NEW_PROGRAM_TEST", line 28
ORA-06512: at line 7
Here is the complete proc:
CREATE OR REPLACE procedure NEW_PROGRAM_test(Enter0_if_this_Mon_ELSE_entr1 IN integer)
is
start_date date;
end_date_1 date;
end_date_3 date;
begin
IF Enter0_if_this_Mon_ELSE_entr1= 0 then
start_date := trunc(add_months(LAST_DAY(SYSDATE)+1, -1));
end_date_1 := trunc((add_months(LAST_DAY(SYSDATE), 0)));
end_date_3 := trunc(add_months(LAST_DAY(SYSDATE), 2));
elsif
Enter0_if_this_Mon_ELSE_entr1= 1 then
start_date := trunc(add_months(LAST_DAY(SYSDATE)+1, 0));
end_date_1 := trunc((add_months(LAST_DAY(SYSDATE), 1)));
end_date_3 := trunc(add_months(LAST_DAY(SYSDATE), 3));
else
     dbms_output.put_line('This is invalid, please retry!');
End if;
Update mytable1 m1
set AT_EXP_FLAG ='Y'
where
expiration_date between start_date and end_date_3
and exists (select contact_id
from mytable1 m2
where
          (m2.expiration_date between to_date('startdate', 'DD-MON-YYYY') and to_date('end_date_1', 'DD-MON-YYYY'))
-- (m2.expiration_date between 'startdate' and 'end_date_1')
          and (m2.contact_id = m1.contact_id));
end;
Please suggest ..
Thanks in advance.
Ac

  • Error while executing PlSQL Procedure

    Hi Chris,
    Procedure SPR_VISAMAST_SWITCHCATEGORIZE is created in the TimesTen interchange user. and all object used by this procedure also cached in the TimesTen.
    While executing it is giving error.
    I traced out where execution is failing, i found that update query on cached table it is giving error.
    Command> DECLARE
    > SOUTPUT VARCHAR2(4000);
    > BEGIN
    > INTERCHANGE.SPR_VISAMAST_SWITCHCATEGORIZE('123456', 'SWTCH.030709', 'v2.01', 'fl.01' , 'v2.02' , '1' , SOUTPUT);
    > END;
    > /
    5213: Bad Oracle login error in OCISessionBegin(): ORA-01017: invalid username/password; logon denied rc = -1
    5131: Cannot connect to backend database: OracleNetServiceName = "geni11g", uid = "INTERCHANGE", pwd is hidden, TNS_ADMIN = "/u01/app/oracle/product/11.1.0/db_1/network/admin", ORACLE_HOME= "/u01/app/oracle/product/11.1.0/db_1"
    8507: ORA-06512: at "INTERCHANGE.SPR_VISAMAST_SWITCHCATEGORIZE", line 39
    8507: ORA-06512: at line 4
    The command failed.
    Please tell me how to solve this issue.

    So when you execute this procedure it is actually executing as user INTERCHANGE. Any objects that the procedure references whcih do not include an explicit owner will assume the object is owned by user INTERCHANGE and this may mean that an object cannot be found.
    Here is an example...
    Let's say you have a cached table in TimesTen and the table is owned by the user 'CACHEUSER' - CACHEUSER.MyCachedtable.
    If you create a PL/SQL procedure owned by the user INTERCHANGE - INTERCHANGE.Someprocedure and within thie procedure include a statement like SELECT * FROM MyCachedtable then when the procedure is executed it will by default always look for the table INTERCHANGE.MyCachedTable even if the user executing the procedure is 'CACHEUSER'. As a result, it would not find the table MyCachedTable in TimesTen and, depending on the setting for PassThrough it might try and go to Oracle for this table.
    Another possibility is that the PL/SQL procedure is performing some cache operation that requires interaction with the Oracle DB and you did not include 'OraclePWD=xxx' to provide the password for Oracle when you connected. Remember that the procedure will be executing, by default, as the user INTERCHANGE not as the user 'CACHEUSER'.
    Chris

  • Error 01741 executing a procedure

    While executing a procedure I'm getting the following error:
    BEGIN
    ERROR at line 1:
    ORA-01741: illegal zero-length identifier
    ORA-06512: at "SYS.DBMS_STREAMS_ADM_UTL_INVOK", line 289
    ORA-06512: at "SYS.DBMS_STREAMS_ADM", line 439
    ORA-06512: at "SYS.DBMS_STREAMS_ADM", line 397
    ORA-06512: at line 2

    I mean you can try using this code:
    BEGIN
         DBMS_STREAMS_ADM.ADD_SCHEMA_RULES(
              schema_name => 'MYSCHEMA',
              streams_type => 'capture',
              streams_name => 'capture_process',
              queue_name => 'capture_queue',
              include_dml => true,
              include_ddl => true,
              include_tagged_lcr => false,
              source_database => 'ANAG',
              inclusion_rule => true);
    END;
    Just try and let me know...

  • Executing A Procedure In a Package Using DBLink

    I need to execute a procedure which is residing in a package using dblink.
    The package got a execute PUBLIC grant.
    When I execute the following statement, I am getting error ORA: 00904, Invalid Identifier
    select PKG_NAME.PROCEDURE_NAME@dblink(null,null,null,null,null,null,null,null,null,null,null) from dual
    How can I execute the above statement.
    Thanks in advance

    I have a database INLABNEW in that i have done this
    SQL> create table temp(no number)
      2  /
    Table created.
    SQL> create or replace package pkg
      2  as
      3     procedure p;
      4  end;
      5  /
    Package created.
    SQL>  create or replace package body pkg
      2   as
      3      procedure p
      4      is
      5      begin
      6             insert into temp values(1);
      7      end;
      8   end;
      9  /
    Package body created.
    SQL> select * from temp
      2  /
    no rows selectedNow i executed the procedure pkg.p from another database
    SQL> exec pkg.p@to_inlabnew
    PL/SQL procedure successfully completed.
    SQL> commit
      2  /And i query the table tmp in INLABNEW
    SQL> select * from temp
      2  /
            NO
             1Now question is have you given your procedure name properly.
    as your procedure is in a package it should be Your_package_name.Your_procedure_name@Your_db_link

  • Executing a procedure in package

    Hi,
    How to execute a procedure in a package? Below is the package
    CREATE OR REPLACE PACKAGE BODY POPULATE_GLTD_TABLES
    IS
    -- LOCAL VARIABLES
    val1 VARCHAR2(10);
    -- Create some job objects:
    v_job1_str VARCHAR2(4000) ;
    v_job1 XXMCK.XXMCK_JOB_OT;
    PROCEDURE populate_gltd_tabs1
    IS
    BEGIN
    dbms_output.put_line('Get_status=> v_job1: ');
    val1:= F_CHECK_GLTD_RECORD_EXISTS('MCK_GLTD_1');
    IF val1 != 'S' THEN
    -- Include message details value - TRUE if yes and FALSE if no
    xxmck.mck_write_log_msg.set_msg_tail(TRUE);
    xxmck.mck_write_log_msg.purge('GLTD-TASK1');
    -- set context will define the source as well as inserts data into cont exit table
    xxmck.mck_write_log_msg.set_context(v_parent_program,v_prog_desc,'GLTD-TASK1');
    xxmck.mck_write_log_msg.log(v_parent_program,'Entering in LOAD_GLTD_TABLES.populate_gltd_tabs1 ','prg','GLTD-TASK1',1);
    xxmck.mck_write_log_msg.log_tail(v_parent_program,'Entering in LOAD_GLTD_TABLES.populate_gltd_tabs1 ','prg','GLTD-TASK1');
    v_job1_str := 'XXCOGNOS.LOAD_GLTD_TABLES.populate_gltd_tabs1;';
    v_job1 := NEW XXMCK.XXMCK_JOB_OT('GLTD-TASK1', v_job1_str, 'Background job test: LOAD_GLTD_TABLES.populate_gltd_tabs1', INTERVAL '60' SECOND);
    v_job1.PRINT(); -- Display basic info about the job
    v_job1.SUBMIT(); -- Submit in background
    v_job1.WAIT();
    v_job1.PRINT();
    v_job1.get_status(v_code, v_message);
    dbms_output.put_line('Get_status=> v_job1: ' || v_code || ':' || v_message);
    -- SELECT DECODE(cont_exit, 'cont', 'cont', 'err', 'err', 'cont') INTO v_result from MCK_LOG_CONT_EXIT_CHK WHERE source = 'GLTD-TASK1';
    --IF v_result = 'err' THEN
    -- raise_application_error(-20000,'Program Aborted');
    --END IF;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN NULL;
    END populate_gltd_tabs1;
    PROCEDURE mainproc
    IS
    BEGIN
    populate_gltd_tabs1; -- CALL TO POPULATE mck_gltd_1 TABLE
    -- Mailing
    xxmck.mck_write_log_msg.send_mail( p_source_prg => v_parent_program
    ,p_source => 'GLTD-TASK1'
    ,p_msg_type => 'prg'
    ,p_from => '[email protected]'
    ,p_to => '[email protected]'
    ,p_server => 'mailhub.mckinsey.com'
    EXCEPTION
    WHEN OTHERS THEN NULL;
    END mainproc;
    END POPULATE_GLTD_TABLES;
    And below is my anonymous block to execute above package
    BEGIN
    POPULATE_MCK_GLTDFILE.mainproc;
    EXCEPTION -- exception handler begin
    WHEN OTHERS THEN NULL;
    END;
    I am trying to run above code in toad. But i am getting error as: identifier 'POPULATE_MCK_GLTDFILE.mainproc' must be declared.
    There are no parameters to be passed.
    The package is compiled successfully.
    I think this must be simplest question any one can I ask, but I cant figure out the solution.
    Please help,
    Aditya

    First remove the horrible exception handler(s) which are hiding all errors;
    ie the
    when others
    then
    null;
    end;Then remember the main syntax is
    begin
    packagename.procedurename;
    end;
    /But also remember that procedure name must be declared in the package header if you want to call it. (This is called a public procedure). A private procedure does not have to be declared in the package header and can only be called from within the same package body.
    I always use sqlplus for verification as that is delivered with oracle. You know if it works with sqlplus it will work with any othere client and if it does not, it's usually a client issue.
    from what you have posted, There is nothing obvious as to why it won't work.

  • While executing the Procedure Getting Error

    Hi I am New to ODI.
    I create one new Procedure just to delete the Target table.
    delete from <%=snpRef.getTable("L","T_CUSTOMER","D")%>. T_Customer is my target table.Technology:Oracle(Both Source and Target)
    I selected the correct Context ,Schema and Technology.
    While executing the procedure i am getting following error
    java.lang.Exception: Internal error: object ConnectConnection
    ColConnectId:null
    ColContextCode:DEV
    ColConName:null
    ColIndCommit:null
    ColIsolLevel:null
    ColLschemaName:null
    ColPlanComp:null
    ColTechIntName:null
    DefConnectId:null
    DefContextCode:DEV
    DefConName:null
    DefIndCommit:null
    DefIsolLevel:null
    DefLschemaName:FCS
    DefPlanComp:null
    DefTechIntName:ORACLE
    ExeChannel:J
    IndErr:1
    IndLogMethod:null
    IndLogNb:null
    LogLevDet:3
    Nno:1
    OrdTrt:0
    ScenTaskNo:1
    SessNo:61001
    TaskName1:Procedure
    TaskName2:Delete
    TaskName3:Delete
    TaskType:S
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execSrcOrders(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlS.treatTaskTrt(SnpSessTaskSqlS.java)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
         at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
         at com.sunopsis.dwg.cmd.e.i(e.java)
         at com.sunopsis.dwg.cmd.g.y(g.java)
         at com.sunopsis.dwg.cmd.e.run(e.java)
         at java.lang.Thread.run(Unknown Source)
    Thanks in advance.

    i Used the below syntax and checked its working fine.
    delete from <%=snpRef.getObjectName("L","T_CUSTOMER","D")%>

  • Maybe you are looking for