Authid current_user using

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

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

Similar Messages

  • Using AUTHID = CURRENT_USER and Apex

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

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

  • Equivalent for AUTHID CURRENT_USER in view

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

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

  • AUTHID CURRENT_USER

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

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

  • Defining AUTHID CURRENT_USER dynamically

    HI,
    I would like to set up all my Oracle 10G procedures and functions to be defined as AUTHID CURRENT_USER dynamically, such as
    ALTER PROCEDURE MYPROC1 AUTHID CURRENT_USER.
    Is there a way to do this dynamically or do I have to owerwrite every sources to do this ?
    Thx in advance.

    Hi,
    I need to do this in a specific migration case where I do have several schemas having the same tables.
    I'm really surprised I can't do this dynamically, perharps by changing the sys table named procedure$

  • Not able to create an object using dbms_metadata.put function

    Hi,
    I have the metadata of an object in one of my database table as xml. I failed to recreate the object in the other schema using metadata api. I developed a stored function to do the above job. My function doesn't throw any error meanwhile it doesn't create the object.
    My code snippet is
    CREATE OR REPLACE PROCEDURE DDI.move_table(
    table_name in VARCHAR2,
    from_schema in VARCHAR2,
    to_schema in VARCHAR2 )
    AUTHID CURRENT_USER
    IS
    -- Define local variables.
    h1 NUMBER; -- handle returned by OPEN
    h2 NUMBER; -- handle returned by OPENW
    th1 NUMBER; -- handle returned by ADD_TRANSFORM for MODIFY
    th2 NUMBER; -- handle returned by ADD_TRANSFORM for DDL
    xml XMLTYPE; -- XML document
    errs sys.ku$_SubmitResults := sys.ku$_SubmitResults();
    err sys.ku$_SubmitResult;
    result BOOLEAN;
    BEGIN
    SELECT REPOS INTO xml from ddi.ddi_repos_t where obj_id = '1801';
    -- Specify the object type using OPENW (instead of OPEN).
    h2 := DBMS_METADATA.OPENW('TABLE');
    -- First, add the MODIFY transform.
    th1 := DBMS_METADATA.ADD_TRANSFORM(h2,'MODIFY');
    -- Specify the desired modification: remap the schema name.
    DBMS_METADATA.SET_REMAP_PARAM(th1,'REMAP_SCHEMA',from_schema,to_schema);
    -- Now add the DDL transform so that the modified XML can be
    -- transformed into creation DDL.
    th2 := DBMS_METADATA.ADD_TRANSFORM(h2,'DDL');
    -- Call PUT to re-create the object.
    result := DBMS_METADATA.PUT(h2,xml,0,errs);
    DBMS_METADATA.CLOSE(h2);
    IF NOT result THEN
    -- Process the error information.
    FOR i IN errs.FIRST..errs.LAST LOOP
    err := errs(i);
    FOR j IN err.errorLines.FIRST..err.errorLines.LAST LOOP
    dbms_output.put_line(err.errorLines(j).errorText);
    END LOOP;
    END LOOP;
    END IF;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    RAISE_APPLICATION_ERROR(-20510,'No xml is available as metadata');
    END;
    Could you tell me where is the probelm?
    The schema where i created and execute my function having dba privilege also.
    Regards,
    Madhavi.

    Hi Madhavi,
    The below code works for me:
    SQL> conn sys as sysdba
    Connected.
    SQL> select count(*) from dba_objects where object_name = 'DEPT' and owner = 'OE';
      COUNT(*)                                                                     
             0                                                                     
    SQL> CREATE OR REPLACE PROCEDURE move_table(
      2  table_name in VARCHAR2,
      3  from_schema in VARCHAR2,
      4  to_schema in VARCHAR2 )
      5  AUTHID CURRENT_USER
      6  IS
      7  -- Define local variables.
      8  h1 NUMBER; -- handle returned by OPEN
      9  h2 NUMBER; -- handle returned by OPENW
    10  th1 NUMBER; -- handle returned by ADD_TRANSFORM for MODIFY
    11  th2 NUMBER; -- handle returned by ADD_TRANSFORM for DDL
    12  xml clob; -- XML document
    13  errs sys.ku$_SubmitResults := sys.ku$_SubmitResults();
    14  err sys.ku$_SubmitResult;
    15  result BOOLEAN;
    16  BEGIN
    17 
    18  select DBMS_METADATA.GET_XML('TABLE','DEPT','SCOTT') into xml from dual;
    19 
    20  -- Specify the object type using OPENW (instead of OPEN).
    21  h2 := DBMS_METADATA.OPENW('TABLE');
    22 
    23  -- First, add the MODIFY transform.
    24  th1 := DBMS_METADATA.ADD_TRANSFORM(h2,'MODIFY');
    25 
    26  -- Specify the desired modification: remap the schema name.
    27  DBMS_METADATA.SET_REMAP_PARAM(th1,'REMAP_SCHEMA',from_schema,to_schema);
    28 
    29  -- Now add the DDL transform so that the modified XML can be
    30  -- transformed into creation DDL.
    31  th2 := DBMS_METADATA.ADD_TRANSFORM(h2,'DDL');
    32 
    33  -- Call PUT to re-create the object.
    34  result := DBMS_METADATA.PUT(h2,xml,0,errs);
    35 
    36  DBMS_METADATA.CLOSE(h2);
    37  IF NOT result THEN
    38 
    39  -- Process the error information.
    40  FOR i IN errs.FIRST..errs.LAST LOOP
    41  err := errs(i);
    42  FOR j IN err.errorLines.FIRST..err.errorLines.LAST LOOP
    43  dbms_output.put_line(err.errorLines(j).errorText);
    44  END LOOP;
    45  END LOOP;
    46  END IF;
    47  EXCEPTION
    48  WHEN NO_DATA_FOUND THEN
    49  RAISE_APPLICATION_ERROR(-20510,'No xml is available as metadata');
    50  END;
    51  /
    Procedure created.
    SQL> exec move_table('DEPT','SCOTT','OE');
    PL/SQL procedure successfully completed.
    SQL> select count(*) from dba_objects where object_name = 'DEPT' and owner = 'OE';
      COUNT(*)                                                                     
             1                                                                     
    SQL> spool off;The xml returned by the get_xml function contains the tablespace name and storage parameters of the schema in which the object is present.
    Check these parameters for both your schemas.

  • Error while creating Project using API - PA_PROJECT_PUB.CREATE_PROJECT

    I am working on Projects conversion and currently trying to create a project using the API.
    I have recetified all the errors it was giving and struck at 1 error. please find the error message below.
    "You have submitted invalid parameters to this process, preventing its successful completion. Please contact your system administrator."
    It gives me this error and I was not able to know the cause for this error. Please let me know how to bypass this error and go ahead with projects conversion???
    Attached below is my package:
    Thanks,
    Kesava
    =====================================================================================================================
    CREATE OR REPLACE PACKAGE xxbwp.xxbwp_pa_proj_conv_pkg AUTHID CURRENT_USER
    IS
         PROCEDURE xxbwp_pa_proj_conv_proc(errbuf           OUT      VARCHAR2
                             ,retcode           OUT      VARCHAR2);
    END xxbwp_pa_proj_conv_pkg;
    CREATE OR REPLACE PACKAGE BODY xxbwp.xxbwp_pa_proj_conv_pkg
    IS
         PROCEDURE xxbwp_pa_proj_conv_proc(errbuf           OUT      VARCHAR2
                             ,retcode           OUT      VARCHAR2)
         IS
    v_data VARCHAR2(2000);
    v_index_out NUMBER;
         v_msg_count               NUMBER;
         v_msg_data               VARCHAR2(2000);
         v_return_status               VARCHAR2(1);
         v_api_version_number          NUMBER          :=     1.0;
         v_commit               VARCHAR2(1)     :=     apps.fnd_api.g_false;
         v_init_msg_list               VARCHAR2(1)     :=      apps.fnd_api.g_false;
         v_workflow_started          VARCHAR2(1)      :=      'Y';
         v_pm_product_code          VARCHAR2(30)      :=      NULL;
         v_op_validate_flag          VARCHAR2(1)      :=      'Y';
         v_project_in               apps.pa_project_pub.project_in_rec_type;
         v_project_out               apps.pa_project_pub.project_out_rec_type;
         v_customers_in               apps.pa_project_pub.customer_tbl_type;
         v_key_members               apps.pa_project_pub.project_role_tbl_type;
         v_class_categories          apps.pa_project_pub.class_category_tbl_type;
         v_tasks_in               apps.pa_project_pub.task_in_tbl_type;
         v_tasks_in_rec apps.pa_project_pub.task_in_rec_type;
    v_tasks_out               apps.pa_project_pub.task_out_tbl_type;
         v_org_roles               apps.pa_project_pub.project_role_tbl_type;
         v_structure_in               apps.pa_project_pub.structure_in_rec_type;
         v_ext_attr_tbl_in          apps.pa_project_pub.pa_ext_attr_table_type;
         v_deliverables_in          apps.pa_project_pub.deliverable_in_tbl_type;
         v_deliverable_actions_in     apps.pa_project_pub.action_in_tbl_type;
    -- Variables declaration related to project_in_rec_type
    l_pm_project_reference VARCHAR2(25);
    l_pa_project_id NUMBER;
    l_pa_project_number VARCHAR2(25);
    l_segment1 VARCHAR2(25);
    l_project_name VARCHAR2(30);
    l_description VARCHAR2(250);
    l_long_name VARCHAR2(240);
    l_department_mapping VARCHAR2(50);
    l_department_mapping_c VARCHAR2(50);
    l_department_mapping_e VARCHAR2(50);
    l_created_from_project_id NUMBER;
    l_carrying_out_organization_id NUMBER;
    l_proj_start_date DATE;
    l_completion_date DATE;
    l_temp_project_type VARCHAR2(30);
    l_company_id VARCHAR2(10);
    l_company_id_c VARCHAR2(10);
    l_company_id_e VARCHAR2(10);
    l_proj_type VARCHAR2(30);
    l_cnt NUMBER := 0;
    l_task_cnt NUMBER := 0;
    l_responsibility_id NUMBER;
    l_application_id NUMBER;
    l_user_id NUMBER;
    l_global_info_msg_count NUMBER;
    l_global_info_msg_data VARCHAR2(2000);
    l_global_info_return_status VARCHAR2(1);
    CURSOR C1 IS
    SELECT *
    FROM xxbwp.xxbwp_pa_proj_conv_tbl
    WHERE proj_type = 'STORAGE';
    begin
    FOR C1_REC in C1
    LOOP
    SELECT APPS.pa_projects_s.nextval
    INTO l_pa_project_id
    FROM DUAL;
    BEGIN
    SELECT description
                   INTO     l_proj_type
                   FROM apps.fnd_lookup_values
                   WHERE lookup_type = 'BWP_PROJECT_TYPES_LKP'
                   AND     lookup_code = C1_REC.proj_type
                   AND     1 = 1;
    END;
    BEGIN
    SELECT project_id, project_type, carrying_out_organization_id
    INTO l_created_from_project_id, l_temp_project_type, l_carrying_out_organization_id
    FROM apps.pa_projects_all
    WHERE project_type = l_proj_type
    AND template_flag = 'Y';
    END;
    BEGIN
    SELECT rt.responsibility_id, rt.application_id
    INTO l_responsibility_id, l_application_id
    FROM apps.fnd_responsibility_tl rt
    WHERE rt.responsibility_name = 'BWP PA Projects Superuser';
    EXCEPTION WHEN OTHERS THEN
    RETURN;
    END;
    BEGIN
    SELECT u.user_id
    INTO l_user_id
    FROM APPS.fnd_user u
    WHERE u.user_name = 'CHUNDURK';
    EXCEPTION WHEN OTHERS THEN
    RETURN;
    END;
    -- Set the environment
    APPS.pa_interface_utils_pub.set_global_info
    (p_api_version_number => 1.0
    ,p_responsibility_id => l_responsibility_id
    ,p_user_id => l_user_id
    ,p_resp_appl_id => l_application_id
    ,p_msg_count => l_global_info_msg_count
    ,p_msg_data => l_global_info_msg_data
    ,p_return_status => l_global_info_return_status);
    --Assign values to project_in_rec_type
    v_project_in.pm_project_reference := C1_REC.PROJ_NUM;
    v_project_in.pa_project_id := l_pa_project_id;
    v_project_in.pa_project_number := C1_REC.PROJ_NUM;
    v_project_in.project_name := C1_REC.PROJ_NAME;
    v_project_in.description := NULL;
    v_project_in.long_name := C1_REC.PROJ_LONG_NAME;
    v_project_in.created_from_project_id := l_created_from_project_id;
    v_project_in.carrying_out_organization_id := l_carrying_out_organization_id;
    v_project_in.start_date := C1_REC.trans_start_date;
    v_project_in.completion_date := C1_REC.trans_end_date;
    v_project_in.scheduled_start_date := C1_REC.trans_start_date;
    v_project_in.scheduled_finish_date := C1_REC.trans_end_date;
    v_project_in.project_status_code := 'APPROVED';
    FOR x IN (SELECT person_id, project_role_type, start_date_active, end_date_active
    FROM apps.pa_project_players
    WHERE project_id = 262)
    LOOP
    APPS.fnd_file.put_line(APPS.FND_FILE.LOG,'PERSON ID '||x.person_id);
    APPS.fnd_file.put_line(APPS.FND_FILE.LOG,'PROJECT ROLE TYPE '||x.project_role_type);
    l_cnt := l_cnt + 1;
    v_key_members(l_cnt).person_id := x.person_id;
    v_key_members(l_cnt).project_role_type := x.project_role_type;
    v_key_members(l_cnt).start_date := x.start_date_active;
    v_key_members(l_cnt).end_date := x.end_date_active;
    END LOOP;
    -- Retrieving and assigning tasks from template to a project
    FOR x IN (SELECT task_id, parent_task_id, task_name, long_task_name, task_number, description,
    billable_flag, cint_eligible_flag, chargeable_flag
    FROM apps.pa_tasks t
    WHERE t.project_id = l_created_from_project_id
    START WITH parent_task_id IS NULL CONNECT BY PRIOR task_id = parent_task_id)
    LOOP
    l_task_cnt := l_task_cnt + 1;
    v_tasks_in_rec.pm_task_reference := x.task_id;
    v_tasks_in_rec.task_name := x.task_name;
    v_tasks_in_rec.long_task_name := x.long_task_name;
    v_tasks_in_rec.pa_task_number := x.task_number;
    v_tasks_in_rec.task_description := x.description;
    v_tasks_in_rec.task_start_date := C1_REC.trans_start_date;
    v_tasks_in_rec.task_completion_date := C1_REC.trans_end_date;
    v_tasks_in_rec.scheduled_start_date := C1_REC.trans_start_date;
    v_tasks_in_rec.scheduled_finish_date := C1_REC.trans_end_date;
    v_tasks_in_rec.pm_parent_task_reference := x.parent_task_id;
    v_tasks_in_rec.billable_flag := x.billable_flag;
    v_tasks_in_rec.cint_eligible_flag := x.cint_eligible_flag;
    v_tasks_in_rec.chargeable_flag := x.chargeable_flag;
    v_tasks_in_rec.tasks_dff := 'Y';
    v_tasks_in_rec.attribute1 := l_pa_project_id;
    v_tasks_in(l_task_cnt) := v_tasks_in_rec;
    END LOOP;
    v_class_categories(0).class_category := 'Reimbursable';
    v_class_categories(0).class_code := 'No';
    APPS.FND_MSG_PUB.initialize;
    apps.pa_project_pub.create_project
    (p_api_version_number => v_api_version_number
    ,p_commit => v_commit
    ,p_init_msg_list => v_init_msg_list
    ,p_msg_count => v_msg_count
    ,p_msg_data => v_msg_data
    ,p_return_status => v_return_status
    ,p_workflow_started => v_workflow_started
    ,p_pm_product_code => v_pm_product_code
    ,p_op_validate_flag => v_op_validate_flag
    ,p_project_in => v_project_in
    ,p_project_out => v_project_out
    ,p_customers_in => v_customers_in
    ,p_key_members => v_key_members
    ,p_class_categories => v_class_categories
    ,p_tasks_in => v_tasks_in
    ,p_tasks_out => v_tasks_out
    ,p_org_roles => v_org_roles
    ,p_structure_in => v_structure_in
    ,p_ext_attr_tbl_in => v_ext_attr_tbl_in
    ,p_deliverables_in => v_deliverables_in
    ,p_deliverable_actions_in => v_deliverable_actions_in
    APPS.fnd_file.put_line(APPS.FND_FILE.LOG,v_return_status||' '||v_msg_count);
    IF v_msg_count > 0 THEN
    FOR i in 1 .. v_msg_count
    LOOP
    apps.pa_interface_utils_pub.get_messages
    (p_encoded => 'F'
    ,p_msg_count => v_msg_count
    ,p_msg_index => i
    ,p_msg_data => v_msg_data
    ,p_data => v_data
    ,p_msg_index_out => v_index_out);
    APPS.fnd_file.put_line(APPS.FND_FILE.LOG,v_data);
    END LOOP;
    END IF;
    END LOOP;
    end xxbwp_pa_proj_conv_proc;
    end xxbwp_pa_proj_conv_pkg;
    show errors;
    Edited by: user644005 on Sep 11, 2009 11:02 AM

    Hi Kesava,
    I notice that in the package you used the application user_name=CHUNDUK calls the API pa_project_pub.create_project.
    I wonder if you used chunduk as database user to execute the package Or you used APPS to execute the package?
    The APi document states that it is a requirement to create a db username as the same name with the application username.
    I have been running the problem to execute API 's delete project and try to figure what could be my problem.
    TIA

  • Using EXECUTE IMMEDIATE with Create Table SQL Statement not working

    Hi ,
    I am all the privileges given from the SYSTEM user , but still i am not able to create a table under procedure . Please see these and advice.
    create or replace procedure sp_dummy as
    begin
    Execute Immediate 'Create table Dummy99_99 (Dummy_Field number)';
    end;
    even i tried this way also
    create or replace PROCEDURE clearing_Practise(p_file_id in varchar2, p_country in VARCHAR2,p_mapId in VARCHAR2)
    AUTHID CURRENT_USER AS
    strStatusCode VARCHAR2(6);
    BEGIN
    EXECUTE IMMEDIATE 'create table bonus(name varchar2(50))';
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line('ERROR Creating Table');
    END ;

    William Robertson wrote:
    Since the syntax is correct, my guess is you do not have CREATE TABLE system privilege granted directly to your account. A common scenario is that you have this privilege granted indirectly via a role, allowing you to create tables on the command line, but stored PL/SQL is stricter and requires a direct grant and therefore the procedure fails with 'insufficient privileges'.A bit like he's already been told on his first thread...
    Using of Execute Immediate in Oracle PLSQL
    Generally you would not create tables from stored PL/SQL. Also as you have found out, it's best not to hide exceptions with 'WHEN OTHERS THEN [some message which gives less detail than the one generated by Oracle]'.Again like he was told on the other thread.
    There's just no telling some people eh! :)

  • How to use bind variable in this select statement

    Hi,
    I have created this procedure where table name and fieldname is variable as they vary, therefore i passed them as parameter. This procedure will trim leading (.) if first five char is '.THE''. The procedure performs the required task. I want to make select statement with bind variable is there any possibility to use a bind variable in this select statement.
    the procedure is given below:
    create or replace procedure test(tablename in varchar2, fieldname IN varchar2)
    authid current_user
    is
    type poicurtype is ref cursor;
    poi_cur poicurtype;
    sqlst varchar2(250);
    THEVALUE NUMBER;
    begin
         sqlst:='SELECT EMPNO FROM '||TABLENAME||' WHERE SUBSTR('||FIELDNAME||',1,5)=''.THE ''';
         DBMS_OUTPUT.PUT_LINE(SQLST);
    OPEN POI_CUR FOR SQLST ;
    LOOP
         FETCH POI_CUR INTO THEVALUE;
              EXIT WHEN POI_CUR%NOTFOUND;
              DBMS_OUTPUT.PUT_LINE(THEVALUE);
              SQLST:='UPDATE '||TABLENAME|| ' SET '||FIELDNAME||'=LTRIM('||FIELDNAME||',''.'')';
              SQLST:=SQLST|| ' WHERE EMPNO=:X';
              DBMS_OUTPUT.PUT_LINE(SQLST);
                   EXECUTE IMMEDIATE SQLST USING THEVALUE;
    END LOOP;
    COMMIT;
    END TEST;
    Best Regards,

    So you want to amend each row individually? Is there some reason you're trying to make this procedure run as slow as possible?
    create or replace procedure test (tablename in varchar2, fieldname in varchar2)
    authid current_user
    is
       sqlst      varchar2 (250);
       thevalue   number := 1234;
    begin
       sqlst := 'update ' || tablename || ' set ' || fieldname || '= ltrim(' || fieldname || ',''.'')  where substr(' || fieldname
          || ',1,5) = ''.THE ''';
       dbms_output.put_line (sqlst);
       execute immediate sqlst;
    end test;will update every row that satisfies the criteria in a single statement. If there are 10 rows that start with '.THE ' then it will update 10 rows.

  • Use of Cursors in Forms!!

    Hi all,
    Here i want to write a generic procedure, which creates a cursor with query based on the users' choice of table and the given query....
    the procedure looks like the following....
    Procedure xyz(iv_table_name IN VARCHAR2,
    iv_where_condition IN VARCHAR2)
    IS
    Cusor lcur_generic IS
    Select field1, field2
    from <iv_table_name> -- Here i want to use the above parameter..
    and i want to attach the iv_where_condition string
    as where condition...
    Could any one help me in this issue,
    It is very important and urgent
    I'm Using Forms 6
    Help is appreciated.
    Tnx
    RK Raju

    IN THE FORMS PREPARE THE STATEMENT
    :BLOCK1.DT:='SELECT FIELD1,FIELD2,FIELD3,FIELD4 FROM TABLE1 WHERE FIELD1=XXX';
    THEN YOU CAN CALL THE PROCEDURE
    IN THE BLOCK PROPERTIES INSTEAD OF TABLE USE PROCEDURE
    QUERY DATA SOURCE NAME 'CUR.RCURSOR'
    QUERY DATA SOURCE COLUMNS
    SET FIELD1 TYPE VARCHAR2 ......
    FIELD2 TYPE VARCHAR2 ......
    FIELD3 TYPE VARCHAR2 ......
    FIELD4 TYPE VARCHAR2 ......
    QUERY DATA SOURCE ARGUMENTS
    SET RESULTSET TYPE REFCURSOR
    TYPE NAME CUR.FINSTYPE
    MODE INOUT
    DT TYPE VARCHAR2
    MODE IN
    VALUE :BLOCK1.DT
    THIS WILL WORK ON THE BLOCK EXECUTE QUERY
    MAKE SURE THE FIELD1,FIELD2,FIELD3,FIELD4 ARE DATABASE SET TO YES
    HERE IS THE CODE FOR THE PACKAGE YOU NEED TO CREATE..
    Package CUR /* IF YOU USE authid current_user */ IS
    type FINSTYPE is ref cursor ;
    PROCEDURE RCUR(RESULTSET IN OUT finstype,DT IN VARCHAR2 );
    END CUR;
    -------------------------------BODY-------------
    Package CUR
    IS
    PROCEDURE RCUR(RESULTSET IN OUT FINSTYPE ,DT VARCHAR2 )
    IS
    BEGIN
    OPEN RESULTSET FOR
    DT;
    EXCEPTION WHEN OTHERS THEN
    NULL;
    END;
    END ;
    IF YOU
    DECLARE
    FCURSOR CUR.FINSTYPE;
    STATEMENT1 VARCHAR2(2000):='SELECT FIELD1,FIELD2,FIELD3,FIELD4 FROM TABLE1 WHERE FIELD1=X';
    BEGIN
    CUR.RCUR(FCURSOR,STATEMENT1);
    FETCH ..... LOOP
    END LOOP;
    CLOSE STATEMENT1;
    END;
    THIS WILL WORK INSIDE OTHER PROCEDURES OR FUNCTIONS BUT NOT INSIDE FORMS PLSQL.
    TO WORK INSIDE FORMS PLSQL
    YOU HAVE TO CREATE IN THE PACKAGE
    RECORDX OF TYPES FIELD1,FIELD2,FILED3,FIELD4
    AND THEN
    INSTEAD OF
    type FINSTYPE is ref cursor ;
    YOU SAY
    type FINSTYPE is ref cursor OF RECORDX ;
    GOOD LUCK
    I HOPE WHAT I WROTE MAKES SENCE BECAUSE IT WORKS...

  • How to Use this function

    I am not sure how to call this Function correctly and how to pass the IN parameter, I am still new and learning, please help!
    So far I have compiled it, and it compiled fine and saved it in my schema.
    It is supposed to be able to calculate the compression ratio for say TABLE_1234 to see how much space it would save if
    I used the COMPRESS option in 10G.
    CREATE OR REPLACE function Y775.compression_ratio (tabname varchar2)
    return number is
    pragma autonomous_transaction;
    -- sample percentage
    pct number := 0.000099;
    -- original block count (should be less than 10k)
    blkcnt number := 0;
    -- compressed block count
    blkcntc number;
    begin
    execute immediate ' create table TEMP_UNCOMPRESSED pctfree 0
    as select * from ' || tabname ||
    ' where rownum < 1';
    while ((pct < 100) and (blkcnt < 1000)) loop
    execute immediate 'truncate table TEMP_UNCOMPRESSED';
    execute immediate 'insert into TEMP_UNCOMPRESSED select * from ' ||
    tabname || ' sample block (' || pct || ',10)';
    execute immediate 'select
    count(distinct(dbms_rowid.rowid_block_number(rowid)))
    from TEMP_UNCOMPRESSED' into blkcnt;
    pct := pct * 10;
    end loop;
    execute immediate 'create table TEMP_COMPRESSED compress as
    select * from TEMP_UNCOMPRESSED';
    execute immediate 'select
    count(distinct(dbms_rowid.rowid_block_number(rowid)))
    from TEMP_COMPRESSED' into blkcntc;
    execute immediate 'drop table TEMP_COMPRESSED';
    execute immediate 'drop table TEMP_UNCOMPRESSED';
    return (blkcnt/blkcntc);
    end;
    /

    Ok, ok - so I have updated the function and it compiled, fine, but now nothing is returned, I thought that a number was returned ?
    CREATE OR REPLACE function Y775.compression_ratio (tabname varchar2)
    return number
    AUTHID CURRENT_USER
    is
    pragma autonomous_transaction;
    -- sample percentage
    pct number := 0.000099;
    -- original block count (should be less than 10k)
    blkcnt number := 0;
    -- compressed block count
    blkcntc number;
    begin
    execute immediate ' create table TEMP_UNCOMPRESSED pctfree 0
    as select * from ' || tabname ||
    ' where rownum < 1';
    while ((pct < 100) and (blkcnt < 1000)) loop
    execute immediate 'truncate table TEMP_UNCOMPRESSED';
    execute immediate 'insert into TEMP_UNCOMPRESSED select * from ' ||
    tabname || ' sample block (' || pct || ',10)';
    execute immediate 'select
    count(distinct(dbms_rowid.rowid_block_number(rowid)))
    from TEMP_UNCOMPRESSED' into blkcnt;
    pct := pct * 10;
    end loop;
    execute immediate 'create table TEMP_COMPRESSED compress as
    select * from TEMP_UNCOMPRESSED';
    execute immediate 'select
    count(distinct(dbms_rowid.rowid_block_number(rowid)))
    from TEMP_COMPRESSED' into blkcntc;
    execute immediate 'drop table TEMP_COMPRESSED';
    execute immediate 'drop table TEMP_UNCOMPRESSED';
    return (blkcnt/blkcntc);
    end;
    /

  • How to get restriction contents using eclipse xsd while reading schema's

    Hello,
    I am using XSD package from eclipse to read my schema structure (which is very complex) The code part where i am problem is as:
    If the schema is having element like :
    <xs:element name="Alignment" default="Center">
    <xs:annotation>
    <xs:documentation>
         Alignment can be any of the following three.     Left Right Center
    </xs:documentation>
    </xs:annotation>
    <xs:simpleType>
    <xs:restriction base="xs:string">
         <xs:enumeration value="Left"/>
         <xs:enumeration value="Center"/>
         <xs:enumeration value="Right"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    Then i am able to read all part. By the way the problem is how to read the restriction part (that is the base ) from the simple part. Any body is having any clue ?
    Regards,

    Pleast take a look at "Definer's rights and invoker's rights" in the following article:
    http://docs.oracle.com/cd/E11882_01/timesten.112/e21639/accesscntl.htm#BABDDCHC
    I guess you need to define a stored procedure with "invoker's rights".
    If this is what you are looking for will have to define it in the stored procedure that you are going to call.
    The syntax is as follows:
    create or replace procedure <yourprocedure> authid current_user ...
    ...or (the following is the default, you don't have to use the "authid definer" keywords):
    create or replace procedure <yourprocedure> authid definer ...
    ...hm

  • Unable to register XSD into Oracle using trigger / procedure

    Hi,
    I am using Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production.
    I have a table which stores XSD and i need to register this XSD. I am able to register the XSD if dbms_schema is executed from PLSQL anonymous block. But if i mention the same code in trigger / procedure is not working . Getting the error as insufficient privileges.
    Table, trigger and procedure are in same schema. This schema has all the privs required for XSD registration globally.
    create table t_vkk ( n number, xsd xmltype)
    alter table t_vkk add active varchar2(1)
    create sequence seq_vkk start with 1 increment by 1
    CREATE OR REPLACE TRIGGER TRG_t_vkk_xsd
    AFTER INSERT OR UPDATE
    ON t_vkk
    REFERENCING OLD AS old NEW AS new
    FOR EACH ROW
    BEGIN
    IF INSERTING AND :new.active = 'Y'
    THEN
    prc_reg_xsd(:new.n, :new.xsd);
    END IF;
    -- Applied when updating rows in the table
    IF UPDATING
    THEN
    IF :new.active = 'Y' -- XSD re-registration since template id is still active
    THEN
    prc_reg_xsd(:old.n, :old.xsd);
    ELSIF :new.active = 'N' -- XSD de-registration
    THEN
    BEGIN
    dbms_xmlschema.deleteschema (
    schemaurl => :old.n
    , delete_option => dbms_xmlschema.delete_cascade_force
    EXCEPTION
    WHEN OTHERS
    THEN
    NULL; -- This XSD was not registered
    END;
    END IF;
    END IF;
    END TRG_t_vkk_xsd;
    This fails -
    insert into t_vkk
    values (0,XMLTYPE(
    '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:books" xmlns:bks="urn:books">
    <xsd:element name="books" type="bks:BooksForm"/>
    <xsd:complexType name="BooksForm">
    <xsd:sequence>
    <xsd:element name="book" type="bks:BookForm" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="BookForm">
    <xsd:sequence>
    <xsd:element name="author" type="xsd:string"/>
    <xsd:element name="title" type="xsd:string"/>
    <xsd:element name="genre" type="xsd:string"/>
    <xsd:element name="price" type="xsd:float"/>
    <xsd:element name="pub_date" type="xsd:date"/>
    <xsd:element name="review" type="xsd:string"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:string"/>
    </xsd:complexType>
    </xsd:schema>'
    ), 'Y')
    This works :
    After inserting the record into t_vkk (Trigger is disabled)
    declare
    begin
    for x in (select * from t_vkk)
    loop
    dbms_output.put_line (x.xsd.getstringval());
    BEGIN
    dbms_xmlschema.deleteschema (
    schemaurl => x.n
    , delete_option => dbms_xmlschema.delete_cascade_force
    EXCEPTION
    WHEN OTHERS
    THEN
    NULL; -- This XSD was not registered
    END;
    dbms_xmlschema.registerschema (schemaurl => x.n
    , schemadoc => x.xsd
    , local => false);
    end loop;
    end;
    This Fails:
    create or replace procedure prc_reg_xsd
    as
    begin
    for x IN (select * from t_vkk)
    loop
    BEGIN
    dbms_xmlschema.deleteschema (
    schemaurl => x.n
    , delete_option => dbms_xmlschema.delete_cascade_force
    EXCEPTION
    WHEN OTHERS
    THEN
    NULL; -- This XSD was not registered
    END;
    dbms_xmlschema.registerschema (schemaurl => x.n
    , schemadoc => x.xsd
    , local => false);
    end loop;
    end;
    BEGIN
    prc_reg_xsd;
    END;
    -Vinod K

    Thanks everyone. I got the solution from one of my colleague. I can invoke dbms_xmlschema.registerschema through my standalone procedure by using current_user authid.
    create or replace procedure prc_reg_xsd
    (in_id IN NUMBER
    , in_xsd IN XMLTYPE)
    authid current_user
    as
    begin
    dbms_output.put_line (' startd');
    BEGIN
    dbms_xmlschema.deleteschema (
    schemaurl => in_id
    , delete_option => dbms_xmlschema.delete_cascade_force
    EXCEPTION
    WHEN OTHERS
    THEN
    dbms_output.put_line (' Failed'); -- This XSD was not registered
    END;
    dbms_xmlschema.registerschema (schemaurl => in_id
    , schemadoc => in_xsd
    , local => false);
    dbms_output.put_line (' done');
    end;
    DECLARE
    x number:=9;
    t xmltype := XMLTYPE(
    '<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:books" xmlns:bks="urn:books">
    <xsd:element name="books" type="bks:BooksForm"/>
    <xsd:complexType name="BooksForm">
    <xsd:sequence>
    <xsd:element name="book" type="bks:BookForm" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="BookForm">
    <xsd:sequence>
    <xsd:element name="author" type="xsd:string"/>
    <xsd:element name="title" type="xsd:string"/>
    <xsd:element name="genre" type="xsd:string"/>
    <xsd:element name="price" type="xsd:float"/>
    <xsd:element name="pub_date" type="xsd:date"/>
    <xsd:element name="review" type="xsd:string"/>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:string"/>
    </xsd:complexType>
    </xsd:schema>');
    BEGIN
    prc_reg_xsd(x,t);
    END;
    This worked for me. The procedure is in the same schema which has XDBADMIN role. So i am able to register the XSD.
    Vinod

  • Using non public callable API

    Hello All,
    I had a post before about using work incident API but nobody responded to me. Here is the link:
    https://forums.oracle.com/forums/message.jspa?messageID=10458788#10458788
    Any way, I found out how should I find the incident reference . Actually, the incident reference is getting generated from the system and how the system does generate that is, it calls a non public callable api. Now for my procedure I want to try to call that non public api, and here is just the test code but I get this error:
    Error(5,2): PLS-00221: 'GET_OSHA_CASE_NUMBER' is not a procedure or is undefined
    my code is:
    create or replace
    PROCEDURE INCIDENT_REFERENCE
    AUTHID CURRENT_USER AS
    begin
    APPS_APPLMGR.per_inc_bus.get_osha_case_number (to_date('01-OCT-03 22:39:04'), 0);
    end;
    Could you please advise me how I can call this api? Or is there any code that I need to use before calling it.
    Thanks,

    Haisa.M wrote:
    Error(5,2): PLS-00221: 'GET_OSHA_CASE_NUMBER' is not a procedure or is undefinedThis means one of 2 things:
    a) you are calling a function as a procedure
    b) you are calling a procedure that does not exist
    From the code unit's name, it would seem that this is a function - not a procedure. The get in the name implies a getter code unit (as oppose to a setter). Getters are typically functions.
    E.g.:
    create or replace procedure FooProc authid current user is
    caseNumber  number;
    begin
      caseNumber := APPS_APPLMGR.per_inc_bus.get_osha_case_number ( sysdate, 0 );
      .. do something with number..
    end;

  • PL/SQL dynamic insert using cursor

    Hello all,
    I'm having big performance issues with (as you'll see below, a very simple) stored procedure. Any hints/suggestions would be really appreciated. Query below in the Loop is used to create a list of all months that fall within a member's start_date & end_date for insertion to member_months table. Can anyone suggest maybe a different approach to improve run time? It was timing out just using SQL, thought I might try PL. Thanks for anyone's help.
    CREATE OR REPLACE PROCEDURE proc_MEMBER_MONTHS authid current_user as
    /* get all Master member id's for cursor */
    CURSOR c_unique_mmi IS
        select distinct master_member_id
        from member;
    v_mmi                           member.master_member_id%TYPE;
    BEGIN
    dbms_output.enable(null);
       OPEN c_unique_mmi;
        LOOP
            FETCH c_unique_mmi INTO v_mmi;   /* pass mmi in cursor to variable */
            EXIT WHEN c_unique_mmi%NOTFOUND;
      INSERT INTO member_months   
          (mmi,                                        
          member_nbr,
          lob,
          member_month,
          member_year,
          member_month_count)
    (SELECT master_member_id mmi,
            member_nbr,
            lob,
            month member_month,
            year member_year,
            ROW_NUMBER ()
              OVER (PARTITION BY member_nbr ORDER BY lob, year, month ASC)
              member_month_count
      FROM (SELECT DISTINCT
                       master_member_id,
                       member_nbr,
                       lob,
                       TO_CHAR (ADD_MONTHS (eligibility_start_date, LEVEL - 1), 'MM')
                          as MONTH,
                       TO_CHAR (ADD_MONTHS (eligibility_start_date, LEVEL - 1),
                                'YYYY')
                          as YEAR
                  FROM (SELECT *
                          FROM mmi_data
                         WHERE master_member_id = v_mmi)              /* v_mmi is current MMI variable passed from cursor */
            CONNECT BY LEVEL <=
                            MONTHS_BETWEEN (TRUNC (eligibility_end_date, 'MM'),
                                            TRUNC (eligibility_start_date, 'MM'))
                          + 1));
        commit;
        END LOOP;
        CLOSE c_unique_mmi;
    END;
    /Edited by: BluShadow on 08-Aug-2012 14:03
    added {noformat}{noformat} tags for readability.  Please read {message:id=9360002} and learn to do this yourself.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    All you would need is a direct insert like this
         insert into member_months   
                mmi
              , member_nbr
              , lob
              , member_month
              , member_year
              , member_month_count
          select   master_member_id mmi
              , member_nbr
              , lob
              , member_month
              , member_year
              , row_number () over (partition by member_nbr order by lob, year, month asc) member_month_count
            from (
                select distinct master_member_id
                    , member_nbr
                    , lob
                    , to_char (add_months (eligibility_start_date, level - 1), 'mm') as member_month
                    , to_char (add_months (eligibility_start_date, level - 1), 'yyyy') as member_year
                  from (
                      select *
                        from mmi_data
                        join (
                            select distinct master_member_id v_mmi
                              from member
                          on master_member_id = v_mmi
               connect
                    by level <= months_between (trunc (eligibility_end_date, 'mm'), trunc (eligibility_start_date, 'mm'))+ 1
              );Your procedure should have only this nothing else. Drop the cursor and looping.
    If you want help in tuning the above query please give us the following details.
    1. DB Version.
    2. Execution Plan
    3. Table Details (Number of rows)
    4. Index Details

Maybe you are looking for