Running a procedure

I need to write a script to run a procedure already written in the package body of the schema. The procedure iterates through one table_1 and inserts each row into another table_2. If the procedure is defined in Package Body/table/table_procs, how do I run this Proc? I don't even know the command to run this.

In SQL* Plus, the syntax is
SQL>exec package_name.procedure_name;
Thanks
Nathan

Similar Messages

  • Remote Database connection error on local database while running a procedur

    Dear Gurus,
    I am trying to run a procedure to grant Select Access to all objects of a schema to all schema but getting below error messages:
    Error report:
    ORA-02019: connection description for remote database not found
    This is on local database and all required privileges have been given to run this procedure but I dont understand why this error is being thrown every time. I am able to fetch all the tables directly (i.e. SELECT object_name FROM user_objects where OBJECT_TYPE IN('TABLE','VIEW','MATERIALIZED VIEW') AND STATUS='VALID')
    Kindly let me know if you have any solution.
    Procedure detail:
    declare
    sqltxt varchar(250);
    cursor course_det is
    SELECT object_name FROM user_objects where OBJECT_TYPE IN('TABLE','VIEW','MATERIALIZED VIEW') AND STATUS='VALID';
    v_objnm user_objects.object_name%type;
    begin
    open course_det;
    loop
    fetch course_det into v_objnm;
    exit when course_det%notfound;
    sqltxt :='GRANT SELECT ON ' || v_objnm|| ' TO public with grant option';
    EXECUTE IMMEDIATE sqltxt ;
    end loop;
    end;
    System detail:
    Oracle 11.2.0.3/Linux 5.3
    Ragards.
    Edited by: 877938 on Mar 20, 2013 12:27 AM

    Hi,
    It seems you are fetching records from one database to other. for that you need to create dblink for that.
    Create dblink first and then try to fetch records using that dblink.
    ORA-02019: connection description for remote database not found
    Cause: An attempt was made to connect or log in to a remote database using a connection description that could not be found.
    Action: Specify an existing database link. Query the data dictionary to see all existing database links. See your operating system-specific Net8 documentation for valid connection descriptors. 

  • Help on ORA-06550 & PLS-00363 Error while running a procedure from a packag

    Greeting All,
    I ran the following procedure from a package on a command line in sqlplus:
    SQL> exec QUALITY_ASSURANCE.COPY_SW_RESOURCES(2009,2010,9508);Where '2009' is the old fiscal year, '2010' is the new fiscal year and '9508' is the error code passed from the calling program. But, I received the following error messages:
    ERROR at line 1:
    ORA-06550: line 1, column 53:
    PLS-00363: expression '9508' cannot be used as an assignment target
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Any thoughts, suggestions and/or advice to resolve these errors.
    Thanks in advance.

    Orchid wrote:
    Justin,
    Thanks for your response and information. Yes, Theoa was correct the 3rd parameter is an OUT variable, and it is a numeric field. The procedure was called by a form as follows:
    QUALITY_ASSURANCE.COPY_SW_RESOURCES(:BLK_CONTROL.FROMFY,:BLK_CONTROL.TOFY,V_ERR);But the form does not work so I am trying to isolate the problem by running the procedure by itself in sqlplus to make sure there is no problem with the procedure.
    Yesterday, I was able to run the procedure in Toad for Oracle to a successful completion by providing the 3 parameters: (2009, 2010, null). Just wonder why I cannot run the same procedure with the same parameters on a command line in sqlplus as follows:
    exec QUALITY_ASSURANCE.COPY_SW_RESOURCES(2009,2010,null);So, if I understand your suggestion correctly, in order to run the procedure with the 3 parameter successfully in sqlplus,
    I have to declare the 3rd parameter in PL/SQL. That is to create a PL/SQL file as suggested and run the file, correct? CORRECT!

  • How run stored procedure in Crystal report?

    I have table from query in report, but first I need to run stored procedure in report.
    How I need to do it?

    previous post not correct
      this is correct
    When I need to run my report
    1) I need to run storeed procedure ( the stored procedure will update some tables)
    I just used Add Command and added stored procedure in Database Fields, but I think the procedure doesn't work in report. Maybe I need add new commant and write there:
    exec ProcedureName par1 par2
    or
    exec ProcedureName (par1={?parameter1} par2={?parameter2})
    It's doesn't work. What I need to do?
    2) I use some query in report
    ex.
    select t1.col1, t2.col2, t6.col3 t1.col7 t4.col1
    from t1, t2, t6, t4, r4, ju, hh
    where hh.col11={?parameter1}
    and ju.col3=6
    and r4.col3={?parameter2}
    group by .....
    order by ......
    How I need to create me report? What I need to do first?
    If parameter in stored procedure par1={?parameter1} in query
    and par2={?parameter2}

  • Is it possible to trigger an error so that the running stored procedure is stopped?

    Hello all,
    I want to run an existing stored procedure and then I want to manually trigger an error/abort/interruption so see what happens and do some testing with that.
    Is it possible to manually trigger an error/abort/interruption on a running stored procedure so that it is stopped?
    If yes, how can I do that?
    I hope someone has an idea. For me it sounds not really difficult, but I just do not get the idea how to do it.
    Kind regards
    Peter

    Hello Visakh,
    I dont want to modify the existing procedure. I just want to run it and than stop it, but not with the button to stop it, but "kill" it somehow with an error (with not destroying the database).
    Nope you cant simulate an intermediate failure inside procedure code from outside. For that you have to modify the actual sp code itself
    Another way is by doing data manipulation in such a way which causes a error in procedure but for that you need to revisit the logic to ensure you do changes in such way as to cause an error
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How to use pool connection run oracle procedure?

    Hi, All:
              I am facing a difficulty I can not find the solution. Maybe you can help
              me.
              I want to call an oracle stored procedure whenever I talk to datebase to
              make the application more efficient. I was able to run the procedure using
              oracle thin driver but not the connection pool using Weblogic jDriver for
              JDBC2.0.
              Please check the following code and see what I did wrong:
              The code in JSP file in Weblogic:
              <%-- JSP page directive --%>
              <%@ page
              import="java.io.*,java.util.*,java.sql.*,weblogic.common.*,weblogic.jdbc20.c
              ommon.*" %>
              <%-- JSP Declaration --%>
              <%!
              protected Connection con = null;
              ResultSet rset = null;
              %>
              <%-- JSP Scriptlet --%>
              <% try {
              Properties props = new Properties();
              props.setProperty("user", "james");
              props.setProperty("password", "aimjames");
              Driver myDriver =
              (Driver) Class.forName
              ("weblogic.jdbc.pool.Driver").newInstance();
              con = myDriver.connect("jdbc:weblogic:pool:hdj2Pool", props);
              String userid = (String)session.getAttribute("user.id");
              int subid =
              Integer.parseInt((String)session.getAttribute("sub.id"));
              String query = "begin pkg_select.sel_req_in_001(" + userid +
              ", " + subid + ", ?); end;";
              weblogic.jdbc.common.OracleCallableStatement cstmt =
              (weblogic.jdbc.common.OracleCallableStatement)con.prepareCall(query);
              cstmt.registerOutParameter(1,java.sql.Types.OTHER);
              cstmt.execute();
              rset = cstmt.getResultSet(1);
              When I run this JSP file, the compilation is fine but the result shows
              nothing. That's means I can not get the ResultSet for some reason.
              The working file when I use oracle thin driver (NOT use a connection pool):
              String userid = (String)session.getAttribute("user.id");
              int subid = Integer.parseInt((String)session.getAttribute("sub.id"));
              String query = "begin pkg_select.sel_req_in_001(" + userid +", " +subid
              +", ?); end ";
              CallableStatement cstmt = con.prepareCall(query);
              cstmt.registerOutParameter(1,OracleTypes.CURSOR);
              cstmt.execute();
              ResultSet rset = (ResultSet)cstmt.getObject(1);
              You may notice that I am trying to bind a parameter to an Oracle cursor. Is
              there anything I did wrong in using weblogic API? I just want to let you
              that in the weblogic JSP file, I also tried to use
              weblogic.jdbc.oci.CallableStatement and
              weblogic.jdbc20.oci.CallableStatement instead of
              weblogic.jdbc.common.OracleCallableStatement, but none of them seems work.
              I did check the bea site at
              http://www.weblogic.com/docs51/classdocs/API_joci.html#1080420 for the
              example to use:
              cstmt.registerOutParameter(1,java.sql.Types.OTHER);
              and I think I followed the exact procedure the example did.
              Please help!
              James Lee
              Artificial Intelligence in Medicine, Inc.
              2 Berkeley Street, Suite 403
              Toronto, Ontario M5A 2W3
              Tel: 416-594-9393 ext. 223
              Fax: 416-594-2420
              Email: [email protected]
              

    Joseph
    Thanks for the suggestion about latest version of Weblogic Server.
    "coding best-practices" is not mentioned in the post.
    In order to make servlet application run significantly faster, my servet how to use connection poo is much moreresonable?
    It is reasonable to expect servlet to run significantly faster with connection pooling.
    Is it true that geting and close a connection whenever
    one time database access finished?
    Already answered. Applications use a connection from the pool then return it when finished using the connection.
    Will the solution affect the servlet performance?
    Yes. Already answered. Connection pooling enhances performance by eliminating the costly task of creating database connections for the application.
    Is there any official document to introduce connection pool program?
    For the latest version
    http://download.oracle.com/docs/cd/E17904_01/web.1111/e13726/toc.htm
    http://download.oracle.com/docs/cd/E17904_01/web.1111/e13737/jdbc_datasources.htm#insertedID0

  • Can't Run Stored Procedure in Package

    Hi,
    I am trying to run a stored procedure that has multiple in and out paramaters. The procedure can only be viewed in my Connections panel by navigating Oher Users | <user> | Packages | <package> | <procedure>
    If I right click <procedure>, the menu items are "Order Members By..." and "Create Unit Test" (greyed out). The ability to "Run" the procedure does not seem possible when it's accessed by user.
    I have been trying to find an example of how to create an anonymous block so that I can run the procedure as a SQL file, but haven't found anything that works.
    Does anyone know how I can execute this procedure from SQL Developer? I am using Version 2.1.1.64.
    Thanks in advance!

    Thanks for replying. I did understand the basics of an anonymous block, but what I didn't understand was how to set the out parameters. I should have been more detailed in my question. However, I did get the answer here:
    http://stackoverflow.com/questions/3991721/run-stored-procedure-in-sql-developer
    Thanks again for replying. I appreciate you taking the time.

  • Run a procedure based on a schedule

    hi dear;
    how can i schedule to run a process in specific time or every one interval of time?
    regards;

    Dear John;
    i mean a procedure in SDK and not in sql.
    exp: the procedure is copying the open sales orders to invoices.
            i want to run this procedure every 5 minutes automatically
    how can i do it in SDK?
    thank you and regards;

  • Run a procedure at the background

    Hi All,
    Is there a way to run a procedure at the background (in parallel)?
    Thanks,
    NPR

    I am trying to fetch records into a temp table based on a complex query (lot of joins and search query dynamically built based on users entry). Also display the records pagewise as soon as 100 records are fetched.
    I want to run this at background with commits inbetween so that I can access the info and display each page with certain number of rows.
    Thanks,
    NPR

  • Why there is no output after running the procedure

    Hello everyone,
    SQL> set serveroutput on size 1000000
    SQL> set echo on
    SQL> set feedback on
    SQL> declare
      2     n number(19);
      3     v_startday varchar2(100) := '7/1/2013';
      4     v_owner varchar2(100) := 'SLIMSINTDM';
      5     v_audit_tab audit_var := audit_var();
      6     v_table_name varchar2(40);
      7     type cur_type is ref cursor;
      8     v_cur cur_type;
      9     v_first_name varchar2(100);
    10     v_last_name varchar2(100);
    11     v_out_tab varchar2(100);
    12     v_lab_code varchar2(10);
    13     v_sql varchar2(20000);
    14     v_sql_1 varchar2(10000) := q'[
    15     select distinct au.first_name, au.last_name,
    16     :v_table_name table_name, lab_code
    17     from laboratory l
    18     join app_user_security aus on AUS.owning_lab_id = l.lab_id
    19     join app_user au on AU.APP_USER_ID = AUS.APP_USER join ]';
    20     v_sql_2 varchar2(10000) := q'[ t on (t.ADDED_BY = AU.APP_USER_ID
    21     or t.last_modified_by = au.app_user_id)
    22     where lab_locale = 'en_AU'
    23     and (t.added_date > to_date(:v_startday, 'MM/DD/YYYY')
    24     or t.last_modified_date > to_date(:v_startday, 'MM/DD/YYYY'))
    25     order by last_name, first_name
    26     ]';
    27  begin
    28     n := 0;
    29     for i in (select table_name from all_tables where owner = v_owner order by table_name)
    30     loop
    31         v_table_name := substr(i.table_name, 1, instr(i.table_name, '_JN') - 1 );
    32  --  dbms_output.put_line('v_table_name: ' || v_table_name ||' ; i.table_name: ' ||i.table_name);
    33         v_sql := v_sql_1 || i.table_name || v_sql_2;
    34  --  dbms_output.put_line(v_sql);
    35         begin
    36            open v_cur for v_sql using v_table_name, v_startday, v_startday;
    37            loop
    38               fetch v_cur into v_first_name, v_last_name, v_out_tab, v_lab_code;
    39               exit when  v_cur%NOTFOUND;
    40               n := n + 1;
    41               v_audit_tab.extend;
    42               v_audit_tab(n) := audit_type(v_first_name, v_last_name, v_out_tab, v_lab_code);
    43            end loop;
    44            close v_cur;
    45         exception
    46           when others then
    47              if sqlcode = -1030 then -- insufficient privs
    48                 dbms_output.put_line('No privs for ' || USER || ' on ' || i.table_name);
    49  --                  exit;
    50              end if;
    51         end;
    52     end loop;
    53      for x in (select * from table(v_audit_tab))
    54      loop
    55        dbms_output.put_line (x.first_name ||','||x.last_name||','||x.table_name||','||x.lab_code);
    56      end loop;
    57  end;
    58  /
    PL/SQL procedure successfully completed.
    Question here ,  developer can't find any output (results) as expected after running this procedure, so is ther anything wrong?
    Thank you very much.

    There is a good chance that there is another error other than -1030 but it is  going into the bit bucket never to be seen.  Check out Oracle Magazine articles on PL/SQL (http://www.oracle.com/technetwork/issue-archive/index-087690.html) for some good coding practices. Part 6, PLSQL: Error Management is relevant to exception handling. 
    You could use a PRAGMA EXCEPTION INIT(InsufficientPriv,-1030); in the declaration section and then do the following:
    EXCEPTION
      WHEN InsufficientPrivs THEN
         dbms_output.put_line('No privs for ' || USER || ' on ' || i.table_name);
      WHEN OTHERS THEN
        dbms_output.put_line('Other Error: '||SQLERRM);
    END;
    or following your example
    exception
       when others then
           if sqlcode = -1030 then -- insufficient privs
               dbms_output.put_line('No privs for ' || USER || ' on ' || i.table_name);
               -- raise;if you want to exit this block and not continue.
            else
               dbms_output.put_line('Other Error: '||SQLERRM);
               -- raise;if you want to exit this block and not continue.
           end if;
    end;

  • Run Stores Procedure,  RadioButton - Important

    Hi everyone,
    I am trying to run this Stored Procedure, I have the following:
    PROMPT(RADIOBUTTON,%MESES%,"seleccionar meses a promediar",1,{"1 mes"," 2 meses"," 3 meses"," 5 meses"},{"1","2","3","5"})
    TASK(Execute formulas,LOGICFILE,%APPPATH%..AdminApp%APP%TestAlldoraVentas2.lgf)
    TASK(Execute formulas,FORMULASCRIPT,"*FUNCTION VIGENCIA=%MESES%")
    Im just passing the time (year.month) and a number called Vigencia which is the number of months chosen in time.
    I.e. :   jan, feb, mar  ,  vigencia= 3
             jan, feb, mar, apr, may  vigencia = 5
    Having as max, 12 months for vigencia.
    I know that Run_Stored_Procedure is not supposed to coexist with WHEN/ENDWHEN structures... however, I still posted it in my script logic, therefore I got this error:
    Start time --->1:09:54 PM  -  Date:8/2/2011  (build code:7.5.105)
    User:ENGABRIE-M04PL0Administrator
    Appset:EPlanning
    App:ALLDORA_VENTAS
    Logic mode:1
    Logic by:
    Scope by:
    Data File:
    Debug File:C:PC_MSDataWebfoldersEPlanningALLDORA_VENTASPrivatePublicationsAdministratorTempFilesDebugLogic_1270_01442641174.Log
    Logic File:C:PC_MSDataWebFoldersEPlanningALLDORA_VENTAS
    ..AdminAppALLDORA_VENTASTestAlldoraVentas2.lgf
    Selection:C:PC_MSDataWebFoldersEPlanningALLDORA_VENTASPrivatePublicationsAdministratorTempFilesFROM_1270_.TMP
    Run mode:1
    Query size:0
    Delim:,
    Query type:0
    Simulation:0
    Calc diff.:0
    Formula script:*FUNCTION VIGENCIA=3
    Max Members:
    Test mode:0
    Is Modelling:1
    Number of logic calls:1
    Call no. 1, logic:C:PC_MSDataWebFoldersEPlanningALLDORA_VENTAS
    ..AdminAppALLDORA_VENTASTestAlldoraVentas2.lgf
    Building sub-query 1
    Query Type:0
    Max members:
    Executing PROMEDIO 'ALLDORA_VENTAS','3','2011.ENE,2011.FEB,2011.MAR','SPSCOPE_706810','SPLOG_185742'
    error running stored procedure PROMEDIO 'ALLDORA_VENTAS','3','2011.ENE,2011.FEB,2011.MAR','SPSCOPE_706810','SPLOG_185742': Could not find stored procedure 'PROMEDIO'.
    The outcome, is all the records for the next year posted with ZEROS..... Please help me out...
    Script:
    *SELECT(%vapi%,"id","conceptos","vap='i'")
    *SELECT(%vapc%,"id","conceptos","vap='c'")
    *SELECT(%vape%,"id","conceptos","vap='e'")
    *SELECT(%toner%,"id","consumibles","tipo='T'")
    *SELECT(%drum%,"id","consumibles","tipo='D'")
    *SELECT(%fusor%,"id","consumibles","tipo='F'")
    *SELECT(%otros%,"id","consumibles","tipo='O'")
    *XDIM_MEMBERSET conceptos=%vapi%,%vapc%,%vape%
    *XDIM_MEMBERSET consumibles=consumibles_dummy,%toner%,%fusor%,%drum%,%otros%
    *XDIM_MEMBERSET lob=servicios_out
    *XDIM_MEMBERSET metrica=precio_r,pieza_r,hojas_r,metros_r
    *XDIM_MEMBERSET moneda=usd,mxn
    *XDIM_MEMBERSET oi oi_dummy
    *XDIM_MEMBERSET vendedor = 01,02,03,04,05
    *RUN_STORED_PROCEDURE=promedio('%app%','VIGENCIA','%tiempo_set%','%scopetable%','%logtable%')
    *COMMIT
    *WHEN conceptos
    *IS %vapi%
    *WHEN metrica
    *IS hojas_r,metros_r,precio_r
    *WHEN tiempo
    *IS %tiempo_set%
    *WHEN versiones
    *IS Real_2011
    *FOR %anio%=2012
    *FOR %mes%=ene,feb,mar,abr,may,jun,jul,ago,sep,oct,nov,dic
    *REC(expression= %value% / %meses%, tiempo=%anio%.%mes%,versiones="esperado_2012")
    *NEXT
    *NEXT
    *IS Real_2012
    *FOR %anio%=2013
    *FOR %mes%=ene,feb,mar,abr,may,jun,jul,ago,sep,oct,nov,dic
    *REC(expression= %value%, tiempo=%anio%.%mes%,versiones="esperado_2013")
    *NEXT
    *NEXT
    *IS Real_2013
    *FOR %anio%=2014
    *FOR %mes%=ene,feb,mar,abr,may,jun,jul,ago,sep,oct,nov,dic
    *REC(expression= %value%, tiempo=%anio%.%mes%,versiones="esperado_2014")
    *NEXT
    *NEXT
    *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    Thanx
    Velázquez

    Hi James,
    In this company there is only 1 person that works in the BPC technical area, and this is me. Im a beginner, so I pretty much know very little about this whole application.
    Thanx for the information you provide, is very useful, specially since there is no info in the manuals about this stuff.
    I only have 2 appsets, Apshell and this one, and I cant find a S. Procedure... however i'll look for the default at least.
    If i just need to copy it and rename it, i'd be glad if you can confirm.
    If this forum is not about solving issues like this, I dont know what is the usage for.
    Thanx again
    Velázquez

  • ADF page times out for long running backend procedure

    Dear gurus,
    I have an ADF 10g web page that invokes a long running backend PL/SQL procedure.
    After some time, and while the web page awaits for the completion of the PL/SQL procedure, I get an *'Oops! This page appears broken'* from my browser (either IE or Firefox).
    Does anybody know what setting to use to make my application endure long running backend procedures without timing out ?

    What is the Application Server you are deploying to? In WebLogic for example, there are options to configure the server stuck thread timeout for instance.
    Edited by: Nick Haralabidis on Jun 20, 2011 4:57 PM
    Also, consider trying to figure out the exact exception or error message. For instance, if your are using a software load balancer solution it may be that this layer times out.

  • Error run a procedure from select sql

    Hi,
    I want run a procedure from a easy sql select.
    I have write this code to run this procedure, but response with a oracle error:
    select [procedure_name](:data1, :data2) as test from dual
    the oracle error is this:
    ORA-00904: "procedurename": invalid identifier
    how to resolve this problem?
    thanks
    Edited by: user10943416 on 12-mag-2010 3.12

    select [procedure_name](:data1, :data2) as test from dualAside from the error Oracle already reported, you can't execute a procedure from a select statement.
    You need to do this:
    SQL> exec procedure_name(:data1, :data2);

  • How to run the procedure

    Procedure test_proc(Req_Hdr_id IN VARCHAR2, uname IN VARCHAR2
    is
    l_request_id NUMBER:=0;
    p_resp_appl_id NUMBER :=401;
    p_resp_id NUMBER := 20634;
    p_user_id NUMBER := 5993;
    BEGIN
    update xxkfupm01.kfupm_mcr_request_header
    set status='Under_Proc'
    where request_hdr_id=Req_Hdr_id;
    commit;
    This is procedure is define in package .how to run this procedure.
    Regards
    Arif
    Edited by: user11309801 on Jan 2, 2011 9:38 PM

    Try This:-
    DECLARE
    req_hdr_id VARCHAR2 (200);
    uname VARCHAR2 (200);
    BEGIN
    req_hdr_id := NULL;
    uname := NULL;
    <<PackageName>>.test_proc (req_hdr_id, uname);
    COMMIT;
    END;
    Also ,add exceptions in the procedure.

  • How to run a procedure

    hello folks,
    i want to run a procedure stored in oracle...follwing is the sample procedure....
    create or replace procedure test_sample
    cv_1 in out sys_refcursor
    as
    begin
    open cv_1 for
    select * from visit;
    end;
    when i run the procedure, it only shows that...+anonymous bolck completed+.... but it never shows the output
    (assuming that table visit have around 20 columns)
    do i need to create another cursor for displaying the result(records)?
    plz help....

    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> var my_cursor refcursor;
    SQL> create or replace procedure test_proc(p_Cursor_Handle in out sys_refcursor)
      2  is
      3  begin
      4     open p_Cursor_handle
      5     for
      6     select * from dual;
      7  end;
      8  /
    Procedure created.
    SQL> exec test_proc(:my_cursor);
    PL/SQL procedure successfully completed.
    SQL> print :my_cursor;
    D
    XCheck this link for more information.
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e17126/static.htm#LNPLS572
    Regards
    Raj

Maybe you are looking for