How to execute procedure

Hi,
I have a procedure which is returning the cursor. Like this:
Create Procedure rptschool
cur_out OUT SYS_REFCURSOR
IS
BEGIN
OPEN cur_out FOR
SELECT      *
FROM xxx
END;
Now I need to execute the above procedure from SQLPLUS. So I am calling like this:
Begin
Exec rptschool
End;
It is giving error. How to execute the procedure from SQLPLUS tool or PLSQL Developer tool.
Thanks in advance

this?
SQL> ed
Wrote file afiedt.buf
  1  Create or replace Procedure rptschool(cur_out OUT SYS_REFCURSOR)
  2  IS
  3  BEGIN
  4    OPEN cur_out FOR
  5    SELECT *
  6    FROM emp
  7    where deptno=10;
  8* END;
SQL> /
Procedure created.
SQL> var cout refcursor;
SQL> execute rptschool(:cout);
PL/SQL procedure successfully completed.
SQL> print :cout;
     EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
      7839 KING       PRESIDENT            17-NOV-81       5000                    10
      7934 MILLER     CLERK           7782 23-JAN-82       1300                    10

Similar Messages

  • How to execute procedure in toad software

    hiii guy's i run my procedure on sql prompt and it run properly
    but when i tried this on toad i got an problem
    after compiling my procedure on toad
    when i write
    execute procedure_name(parameter1,parameter2);
    then i get an error i.e
    ORA-00900: invalid SQL statement
    can someone tell me how to execute procedure on toad
    thanks in adv...........

    how to execute procedure in toad softwareIn TOAD's schema browser you can go to the procedures tab - right click on the procedure in question and choose execute procedure - a window should pop up, where you can give optional parameters - the rest should be almost self explanatory ;)

  • How to execute procedure in SQL Worksheet ?

    Hi, anybody know, how I can execute procedure here?
    I try EXEC sec_roles, EXEC security_admin.sec_roles, EXECUTE - there is a SQL statement error. When I use CALL - there is no such procedure (I have execute previleges).
    Although in SQLPlus EXEC works, but there are problems with standard SQL commands (all of them returns "2" no matter what content is).
    Any ideas?
    Regards
    Krzysztof

    exec procedure(parameters) is a sql plus (and a few others) shortcut for
    BEGIN
       procedure(parameters);
    END;So try that then pressing/clicking whatever it is in sql worksheet that makes a statement run.
    Note that if your procedure has parameters defined as OUT or IN OUT, you will need to supply a variable to accept the returned value(s).
    John

  • How to execute procedure with dynamic where condition.

    Hi All,
    I am facing a probelem
    Issue :
    I am having a parameter p_id in my procedure based on the value of this parameter i want to change the where condition.
    How to do so?
    Code:---------
    create or replace procedure p_1
    ( p_id in emp_dummy.empno%type)
    is
    parameter_1 varchar2(2000);
    v_sal number;
    begin
    if p_id = 1 then
    parameter_1 := 'where empno = 1';
    else
    parameter_1 := 'where 1=1';
    end if;
    select salary into v_sal from emp_dummy||' '||parameter_1;
    end;

    Dynamic SQL is not the best of ideas, but if you must...
    EXECUTE IMMEDIATE 'select salary from emp_dummy where empno=nvl(:x,empno)' into v_sal using p_id;Then if you pass in the p_id to the procedure it will select the salary for that employee and if null is passed in then it will select the salary for all employees. Now here's a problem because you are trying to return a single value and if you don't specify the employee then it will try and return multiple values from that select, so you probably want to do something like give the sum of the salaries...
    EXECUTE IMMEDIATE 'select sum(salary) from emp_dummy where empno=nvl(:x,empno)' into v_sal using p_id;

  • How to execute procedure returning data rows from sql plus

    Hi,
    I want to execute a stored procedure that returns data rows from sql plus. please let me know the syntax for the same.
    Thanks,
    YG

    user13065317 wrote:
    Even if i get the result set into the cursor, do i have to do normal fetch into all the coumn variables within a loop
    But suppose no of columns in my result set varies depending on a parameter to the stored procedure.
    Is there any straightforward way to retrieve all the data irrespective of no of columns in the result set.There is no such thing as a "+result set+". Oracle does not create a temporary data set in memory that contains the results of your query. What would happen if this result set is a million rows and is too large to fit into memory? Or there are a 100 clients each with a 100,000 row result set?
    This is not scalable. You will be severely limited in the number and sizes of these "+result sets+" that can be created in server memory.
    A cursor is in fact a "program" that is created by compiling the SQL source code that you provide. This source code is parsed and compiled into what Oracle calls an execution plan. This is nothing but a series of instructions that the cursor will execute in order to return the rows required.
    Thus the result set is actually the output from a cursor (a program). Likewise, bind variables are the input parameters to this program.
    All SQLs are parsed and compiled as cursors and stored in the SQL Shared Pool. Oracle gives you handle in return to use to address this cursor - bind values to it, execute it, describe the output structure returned by the cursor, and fetch the output from the cursor.
    On the client side, this handle is used in different ways. In PL/SQL alone, this cursor handle can be used as an implicit cursor (you do not even see or use the cursor handle in your PL/SQL code). Or you can use a PL/SQL cursor variable. Or a DBMS_SQL cursor variable. Or a reference cursor variable.
    Why so many different client structures for the very same SQL cursor handle returned by Oracle? Because to allow you, the programmer, all kinds of different features and flexibility.
    The ref cursor feature is the ability to pass this cursor handle around, not only between PL/SQL code, but also from PL/SQL to the actual client process (Java. VB, SQL*Plus, TOAD, etc).
    The primary thing to remember - irrespective of what the client calls this (e.g. ref cursor, SQL statement handle, etc), this all refers to the same SQL cursor in the Shared Pool. And that this SQL cursor is a program that outputs data, and not a result set in itself.

  • How to execute procedure without having extra connection

    I am asking this question again, i want to execute the oracle database procedure from within the JDeveloper without getting any extra connection like JDBC connection. I tried this using dbaccess.executeretrieval()and executecommand() method, but not finding any solution. My procedure has two input parameters and four output parameters.
    can anybody help on this??
    vikas
    null

    this can be done using the CallableStatement class.
    typecast the reference of the application module that you have to applicationmoduleimpl. ApplicationModuleImpl class has a method PrepareCallableStatement that returns an object of type CallableStatement. the prepare method takes 2 parameters. one is the statement to execute and one is the number of expected return rows. inorder to call an SP, the statement should be call <name od sp in caps>.
    to execute the statement, the callable statement class provides the execute() method. it has methods for specifying the IN OUT parameters also (go through jdeveloper help for details).

  • How to execute another schema procedure from toad?

    Hi,
    i want to execute procedure from another schema from toad. already i have created synonym for that procedure and provided execute permission.
    how to execute procedure from toad?
    Thanks,

    Hi,
    The vendor of that product is running their own forums
    http://toadfororacle.com/index.jspa
    Not sure how they feel about
    Handle:      user2017273
    Status Level:      Newbie
    Registered:      Oct 4, 2009
    Total Posts:      64
    Total Questions:      44 *(36 unresolved)*

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

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

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

  • How to execute multiple queries in one stored procedure.

    Hi,
    I am Kumar,
    How to execute multiple queries in one stored procedure.
    here is the my requirements,
    1. get the max value from one table and sum of the that value.
    2. insert the values and also sum of the max value.
    using stored procedure
    I am using SQL server 2000 database.
    Please help me.
    Advance thanks
    by,
    Kumar

    This is not a java question and it is not even a problem: your only problem is
    1) lack of knowledge
    2) lack of interest to find a manual
    But you are going to have to change both by actually reading a book or a manual that explains the stored procedure language of SQL Server. It is the same as Sybase I think, so you could also look for a manual for that DBMS.

  • How to Execute a Remote Procedure in Portal using Database Link

    Hi,
    I followed the instructions to create a Portal form for a remote procedure. But I am encountering the following error. Can someone advise what may be the cause?
    Failed to execute - Missing string(create_package_body) language(us) domain (wwv) sub_domain (wwv_builder) (WWV-04300)
    ORA-04020: deadlock detected while trying to lock object PUBLIC.PORTLET_SCHEMA (WWV-11230)
    Failed to parse as PORTAL - (WWV-08300)
    PURPOSE
    How to execute a remote procedure in Portal using Database Link.
    DESCRIPTION
    This procedure assumes that you have two databases, one of which is remote, and Portal is configured in the other.
    Remote Database A:
    ==================
    1) Create a procedure as follows: Create or Replace PROCEDURE SCOTT.ADD_TWO_VALUES ( v_one IN NUMBER, v_two IN NUMBER, v_result OUT NUMBER) as begin v_result :=v_one+v_two; end; 2) Grant execute privileges to PUBLIC on the procedure.
    Database B (where Portal is configured): ========================================
    1) Create a public database link and choose to connect as a specific user (say SYSTEM). By default, in an Oracle 8i database, the "global_names" parameter in initSID.ora (or init.ora) file is set to "true". This Global Naming parameter enforces that a dblink has the same name as the database it connects to. Therefore, if the remote global database (A) name is "ora8.acme.com" then the database link should also be named as "ora8.acme.com".
    2) Create a synonym for the procedure in Database A. Make sure you fully qualify the procedure name in the remote database (like SCOTT.ADD_TWO_VALUES).
    3) Create a dynamic page to execute the procedure. The ORACLE tags in the dynamic page will look similar to the following: <ORACLE> DECLARE v_total NUMBER; BEGIN ADD_TWO_VALUES(:v_one,:v_two, v_total); htp.p('The total is => '); htp.p('<input type="TEXT" VALUE='||v_total||'>'); htp.para; htp.anchor('http://<machine.domain:port#>/pls/portal30/SCOTT.DYN_ADD_TWO_VALUES.show_parms', 'Re-Execute Procedure'); END; </ORACLE>
    4) Portal does not have an option to create a form based on a synonym. Therefore, if you want to create a form instead of a dynamic page, create a wrapper procedure and then create a form based on this procedure. For example: Create or Replace PROCEDURE PORTAL30.ADD_TWO_VALUES_PR ( v_one IN NUMBER, v_two IN NUMBER, v_total OUT NUMBER) as begin add_two_values(v_one, v_two, v_total); end;
    5) Grant execute privileges to PUBLIC on the procedure.

    hello...
    any input will welcomed... Thanks..

  • How to execute the procedure in sap b1

    Hai to all,
                 I done a procedure in sql server .but i don't know how to execute that  procedure in sap b1?
    can anyone help me immediately.
    Regards,
    Ramya.S

    Dear Ramya.S,
    You could execute the store procedure by using Recordset object in SDK DI code. It is like:
    Dim myRecordSet As SAPbobsCOM.Recordset
    myRecordSet =                                   
    SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecord
    set)
    myRecordSet.Command.Name = "TestStoredProcedure"
    myRecordSet.Command.Parameters.Item("@ItemLike").Value = "IT%"
    myRecordSet.Command.Parameters.Item(2).Value = "C0001"
    myRecordSet.Command.Execute()

  • How to execute stored procedure in sqlplus

    i have procedure something like this
    create or replace "gettimeslots"
    v_acc in varchar,
    slot_cursor in out sys_refcursor
    as
    begin
    open slot_cursor for
    select * from tslots where tid=v_acc;
    end
    how to execute this proc in sqlplus?please help in this regard

    As you perfectly know (since you're a member for more than a year now) you could have looked that up via google or the forum search. Just one link for you:
    SQLPLUS in Morgan's Library!

  • How to execute the parametered stored procedure in sql *plus ?

    how to execute the parametered stored procedure in sql *plus ?
    my storedprocedure format
    CREATE OR REPLACE PROCEDURE SMS_SELECTMPLOYEE
    (empDOB out date, empEmpName out varchar2)
    thanks & regards
    mk_mur

    Oh, sorry... making many reading-too-fast mistakes today...
    You can't declare date variables in SQL*Plus (seel help var), but you can cast to varchar2:
    TEST> CREATE OR REPLACE PROCEDURE SMS_SELECTMPLOYEE (empDOB out date, empEmpName out varchar2) IS
      2  d date := sysdate;
      3  e varchar2(10) := 'bob';
      4  begin
      5  empdob := d;
      6  empempname := e;
      7  end;
      8  /
    Procedure created.
    TEST> var d varchar2(30)
    TEST> var n varchar2(30)
    TEST> call  SMS_SELECTMPLOYEE(:d,:n);
    Call completed.
    TEST> print d n
    D
    11/07/06
    N
    bobYoann.

  • How to Execute SSIS package through MySQL Procedure

    Hi Everyone,
    How to Execute SSIS package from MySQL Stored Procedure.
    Please share your suggestions on this.
    Regards,
    Vaishu

    I am not sure whether you have SSIS license version installed in the system where MYSQL is there. In order to run SSIS package we need to have DTEXEC executable file and it comes with SSIS license version.
    An SSIS package can be executed from command prompt as,
    C:\>dtexec /f E:\package.dtsx
    I am not expert in MYSQL however in TSQL we can run dos command or scripting language such as vbscript.
    Similarly you need to check in MYSQL. This is MSSQL Server forum.
    Refer
    http://www.ehow.com/how_8789576_call-ssis-package-vbscript.html
    http://www.mssqltips.com/sqlservertip/1775/different-ways-to-execute-a-sql-server-ssis-package/
    Regards, RSingh

  • How to execute a stored procedure/function in TOAD?

    Hi, All ,
    Can someone please tell me how to execute a stored procedure/function in TOAD?
    I have tired
    EXECUTE PROCEDURENAME(888), but it doesn’t work.
    TOAD give me the error: invalid SQL statement.
    Thanks a lot

    Write PL/SQl block.
    i.e Begin
    Procedure name..
    end;
    Then it will be excuted.
    Ashutosh

Maybe you are looking for

  • How can I get the pluginID in Effect type plugins?

    Hi, I am craeting Effcet plugin and I want to get the PluginID because I want to execute the script file using AEGP_ExecuteScript() function?. so Could you please tell me how can I get the pluginID in Effect plugins? Thanks Manjunath G

  • Need ouput more than 4000 characters

    Hi , how to create a script that fetches more than 4000 charaters in the ouput

  • Tutorial: Azure AD integration with Mozy Enterprise

    Click reply and tell us what you think: Azure AD integration with Mozy Enterprise Markus Vilcinskas, Knowledge Engineer, Microsoft Corporation

  • Preventing servlet output stream to flush

    I increased the buffersize in the response object in order to make it possible for the entire jsp page to process before writing any output to the webclient. BUT since I use dynamic jsp-includes I fail to accomplish this, since according to the JSP1.

  • Screen flashes on and off when trying to delete app

    I Was trying to delete an app. When i pressed the x in the corner the app and several apps next to it began to flash on and off. The only way i could stop it was to completely shut down the ipad and restart?