How to execute stored procedure in the SQL Commands page

i'm oracle express edition newbie :) i have this stored procedure. it not belong to a package.
create or replace procedure "LIST_MEMBERS"
("MEMBER_CUR" OUT SYS_REFCURSOR)
is
begin
OPEN MEMBER_CUR FOR
SELECT * FROM members;
end;
now, in the SQL Commands page, how to run the stored procedure and return the records. i do this:
begin
execute list_members();
end;
but i'm getting some errors. just need some immediate help :) thanks!!!

Example of using a ref cursor:
SQL> ed
Wrote file afiedt.buf
  1  create or replace procedure open_cur(c IN OUT SYS_REFCURSOR) is
  2  begin
  3    open c for 'select rownum rn from dual connect by rownum <= 10';
  4* end;
SQL> /
Procedure created.
SQL> ed
Wrote file afiedt.buf
  1  declare
  2    c     SYS_REFCURSOR;
  3    v_val NUMBER;
  4  begin
  5    open_cur(c);
  6    loop
  7      fetch c INTO v_val;
  8      exit WHEN c%NOTFOUND;
  9      dbms_output.put_line(v_val);
10    end loop;
11    close c;
12* end;
SQL> /
1
2
3
4
5
6
7
8
9
10
PL/SQL procedure successfully completed.
SQL>

Similar Messages

  • How to execute Stored Procedures ?

    How can we execute a Stored Procedure through the JDBC adapter ? Does the JDBC adapter support this ? Has anyone been successfully able to do this ?
    Help appreciated.  Thanks.

    Hi,
    did you take a look at StatementName5 on:
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
    you can find an example on how to do it.
    I haven't tried that yet but it looks like it's possible:)
    Regards,
    michal

  • Found a bug in "Execute Stored Procedure..." command

    Hi...I've found one interesting "feature": if I do click "Execute Stored Procedure"on SP, which contains an XML parameter (doesn't matter if it's input or output), Management Studio generates script without declaring datatype of that
    parameter. But if I click "Generate Script" everything works fine. This situation can be observed in SQL Server 2005-2012.

    Hello,
    Please submit a product feedback on Microsoft Connect:
    https://connect.microsoft.com/sqlServer/
    Thank you for sharing what you have discovered.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • How to execute stored procedure that returns a cursor?

    How to execute a stored procedure that returns a cursor?
    Follow the code:
    CREATE OR REPLACE PROCEDURE stp_cashin_grupo
    (p_func IN VARCHAR
    ,p_cod_grup IN Integer
    ,p_des_grup IN VARCHAR
    ,p_logi IN VARCHAR
    ,p_curs_rset OUT infoc.pck_cashin_grupo.curs_rset
    IS
    BEGIN
    if p_func = '1' then
    OPEN p_curs_rset FOR
    select
    cod_grup
    ,des_grup
    ,dat_manu_grup
    ,des_logi_manu
    from infoc.tbl_cashin_grupo
    order by des_grup;
    end if;
    END stp_cashin_grupo;
    and the package:
    CREATE OR REPLACE PACKAGE pck_cashin_grupo
    AS
    TYPE curs_rset IS REF CURSOR;
    END pck_cashin_grupo;
    My question is how to execute in sql plus?
    EXEC stp_cashin_grupo('1',0,'','465990', my doubt is how to pass the cursor as return
    Thanks

    my doubt is how to pass the cursor as returnExample :
    TEST@db102 > var c1 refcursor;
    TEST@db102 > create or replace procedure ref1 (
      2     v1 in varchar2,
      3     cur1 out sys_refcursor)
      4  is
      5  begin
      6     open cur1 for 'select * from '||v1;
      7  end;
      8  /
    Procedure created.
    TEST@db102 > exec ref1('dept',:c1);
    PL/SQL procedure successfully completed.
    TEST@db102 > print c1
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    TEST@db102 >

  • How to read stored procedure/function in SQL*PLUS?

    I created procedure and stored in Oracle. Now, I want to read it or may be modify it.
    I know "Oracle Enterprise Manager" can make it, but if I don't have it, how can I achieve it?
    I don't want to use "CREATE OR REPLACE PROCEDURE ..." because I need to read it first. How can I do?
    Thanks!!!
    Anne

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Anne:
    I created procedure and stored in Oracle. Now, I want to read it or may be modify it.
    I know "Oracle Enterprise Manager" can make it, but if I don't have it, how can I achieve it?
    I don't want to use "CREATE OR REPLACE PROCEDURE ..." because I need to read it first. How can I do?
    Thanks!!!
    Anne<HR></BLOCKQUOTE>
    Anne -
    On SQLPLUS use follwings -
    Set long 50000 ;
    Spool procname.txt
    and then write the SQL query which was given
    in earlier reply.If You u have problem let us know.
    Thanks
    Ajeet
    null

  • 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 a procedure in the same db session of the framework page

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

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

  • Calling mysql stored procedure having insert sql commands within cftransaction is not getting rolled back

    Hi,
    cftransaction is working perfectly when all the insert
    updates are called by cfqquery.
    But when there is a mysql stored procedure call with in
    cftrnsaction and that mysql stored procedure is having many inserts
    and updates, cftransaction is not able to roll back insert/updates
    happened in stored procedure.
    I am using InnoDB tables/database of mysql.
    Did anybody faced a similar problem and is it a coldfusion
    bug or mysql bug.
    We checked with Java and java is able to roll back the
    transaction, but coldfusion cftransaction is failing.
    Please help.
    Regards,
    Saikumar

    Mark,
    I believe the syntax of your formatted search is not right. I guess you are trying to get the U_Width from Item Master and the other values from the current form.
    SELECT @Width = T0.U_WTH FROM [dbo].[OITM] T0.WHERE T0.ItemCode = $[$38.1.0]
    EXEC TBC_CHOP @Width, $[$38.U_LINETYPE.0], $[$38.U_LI.0], $[$38.U_LN.0],
    $[$38.U_LD.0], $[$38.U_HI.0], $[$38.U_HN.0], $[$38.U_HD.0], $[$38.U_QTYORD.Number]
    If you see I have added a third parameter which is the Type to the formatted seach field selection $[$Item.Column.Type]
    I have made then all 0 but you may change it as per the col type.  This Type should be 0 for Char type columns, Number for numeric columns and Date for Date type cols
    Suda

  • How to execute a procedure and function at command line?

    I tried to execute the following function at command line.
    CREATE OR REPLACE FUNCTION FN_IS_SYSDATE_TICKING
    RETURN BOOLEAN
    IS
    ls_value     VARCHAR2(100) DEFAULT 'NONE';
    BEGIN
    SELECT value
    INTO ls_value
    FROM V$PARAMETER
    WHERE name = 'fixed_date';
    IF ls_value = 'NONE' THEN
    RETURN TRUE;
    ELSE
    RETURN FALSE;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN TRUE;
    END FN_IS_SYSDATE_TICKING();
    At Command Line, I entered
    var v1 BOOLEAN;
    exec :v1 := RSSC.FN_IS_SYSDATE_TICKING();
    print v1;
    It is giving boolean is not declared.

    Works for me:
    SQL> CREATE OR REPLACE FUNCTION FN_IS_SYSDATE_TICKING RETURN VARCHAR2
      2  IS
      3    ls_value VARCHAR2(100) DEFAULT 'NONE';
      4  BEGIN
      5    SELECT value
      6      INTO ls_value
      7      FROM V$PARAMETER
      8     WHERE name = 'fixed_date'
      9    ;
    10    IF ls_value = 'NONE'
    11    THEN
    12      RETURN 'TRUE';
    13    ELSE
    14      RETURN 'FALSE';
    15    END IF;
    16  EXCEPTION
    17  WHEN OTHERS THEN
    18    RETURN 'TRUE';
    19  END FN_IS_SYSDATE_TICKING;
    20  /
    Functie is aangemaakt.
    SQL> var v1 varchar2(5);
    SQL> exec :v1 := FN_IS_SYSDATE_TICKING;
    PL/SQL-procedure is geslaagd.
    SQL> print v1;
    V1
    FALSE{code}Note that I had to specify a length for the varchar2.
    Regards,
    Rob.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to invoke a stored procedure on MS Sql Server with Java?

    I started writing Enterprise Java Beans and created an ODBC dsn with MS Sql Server 2000 which I can access using jdbc:odbc:mySqlDSN. This all works fine using Java Sql Statements. What kind of Java/Java Sql statement can I use to invoke a stored procedure on the Sql Server? Is it possible to use ADO/ADO command objects with Java? Is it possible to import/implement Mdac2.6 ActiveX data objects libary in Java?
    Thanks

    Thanks all for your replies. I will search the api for callable statements. I am curious though, the reply that suggests using a prepared statement - can I put the name of a stored procedure in a prepared statment or is this just suggestions an action query like Insert Into, Update, Delete? Like with ADO you can say
    cmdObject.CommandType = adStoredProcedure
    cmdObject.CommandText = "NameOfStoredProc"
    cmdObject.ExecuteNonQuery()
    Once I am calling/importing/implementing the proper libraries/interfaces in Java, can a prepared statement reference a stored procedure as above?
    Thanks

  • Execute Stored Procedure from C#

    Hi, im new to using stored procedures and i have the following stored procedure...
    CREATE OR REPLACE PROCEDURE DRL_PROCEDURE2(var_SOURCE_OBJECTID IN varchar2, var_NEW_OBJECTID OUT varchar2)
    AS
    BEGIN
    SELECT MAX(NEW_OBJECTID)
    INTO var_NEW_OBJECTID
    FROM DRL_CONVERSION
    WHERE SOURCE_OBJECTID = var_SOURCE_OBJECTID;
    END;
    I want to be able to call this procedure from my windows form application and display the result of the stored procedure into a label...could someone please help me! Thanks in advance!

    http://www.csharpfriends.com/articles/getarticle.aspx?articleid=78
    You can find how to call stored procedure (in the above link you will find an example of SQL Server 2005 which also work for you as of your oracle stored procedure) in C#.
    HTH
    Girish Sharma

  • How to retrieve Stored Procedure Output Parameter?

    Hi,
    I'm using a stored procedure with MS SQL Server. The stored procedure creates the required table entries correctly. After executing the procedure i free the resulting recordset reference and am able to retrieve the return value of the stored procedure. However,
    I am not able to retrieve the output parameters of the procedure. I am connected to the database using the MS OLE DB Provider for SQL Server. I tried using ODBC as well. Didn't work either. I know this issue has been addressed before, did anyone come up with a solution for this problem?
    Thanks in advance,
    Marco

    I can tell you what I do with LabSQL and a single output parameter. After I open the connection to the database, I execute a SQL statement that looks like this:
    declare @resultID int
    execute spInsUUTResult @SerialNumber = '999DEBUGXXX',
    @SequenceName = 'Sequence File2.seq',
    @CategoryID = 2,
    @TypeID = 1,
    @StartDateTime = '10-10-2003 13:42:45',
    @ExecutionTime = 3.5698713,
    @UUTStatus = 'Passed',
    @UserName = 'Dennis Knutson',
    @StationName = 'DENNIS-KNUTSON',
    @UUTResultID = @resultID OUTPUT
    This query result is the output parameter. I first debugged the call to the stored procedure in the SQL Server Query Analyzer and then just copied that straight into my LabVIEW code. You may be using something other than LabSQL but you should have a function t
    hat allows for raw SQL commands.

  • How to use Stored Procedure Call in Sender JDBC adapter

    Hi All,
             Could someone send me a blog on how to use Stored Procedure call in Sender JDBC adapter?
    Xier

    Hi Xler
    refer these links
    /people/yining.mao/blog/2006/09/13/tips-and-tutorial-for-sender-jdbc-adapter
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
    Also, you can check Sriram's blog for executing Stored Procedures,
    /people/sriram.vasudevan3/blog/2005/02/14/calling-stored-procs-in-maxdb-using-sap-xi
    /people/jegathees.waran/blog/2007/03/02/oracle-table-functions-and-jdbc-sender-adapter
    This blog might be helpfull on stored procedures for JDBC
    JDBC Stored Procedures
    /people/siva.maranani/blog/2005/05/21/jdbc-stored-procedures
    Please go through these threads and see if it helps...
    Re: How to execute Stored Procedure?
    Re: Problem with JDBC stored procedure
    Thnaks !!

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • How to execute an stored procedure from the Report Region

    Have stored procedure "LER_KRONOS_PAYCODE_HOURS_P" compiled and ready.
    (previously tested)
    Region Source:
    DECLARE
    v_SITE_ID VARCHAR2(8);
    v_SDATE VARCHAR2(8);
    v_EDATE VARCHAR2(8);
    v_LEVEL3 VARCHAR2(60);
    BEGIN
    v_SITE_ID :=P4_SITES_LOV;
    v_SDATE :=P4_SDATE;
    v_EDATE :=P4_SEDATE;
    v_LEVEL3 :=P4_LEVEL3;
    EXECUTE LER_KRONOS_PAYCODE_HOURS_P(v_SITE_ID,v_SDATE,v_EDATE,v_LEVEL3);
    END;
    Error When run the page:
    ORA-06550: line 11, column 12: PLS-00103: Encountered the symbol "LER_KRONOS_PAYCODE_HOURS_P" when expecting one of the following: := . ( @ % ; immediate The symbol ":=" was substituted for "LER_KRONOS_PAYCODE_HOURS_P" to continue.

    You need the execute keyword only when you run it directly from sqlplus.. that will tell sqlplus to append the keyword begin and end after the procedure call.
    Example.
    SQL > exec proc1 (input1);
    will tell sqlplus to run it as a block.. saying
    sql> Begin
              proc1(input1);
          end;Inside the procedure , in your code, you dont need the execute keyword.
    But, why do you want to execute a procedure inside the source for a report region..?

Maybe you are looking for

  • [Time].[Date].[Date] vs. [Time].[Date].Members in a Scope

    Hi folks, I'm just trying to understand how the subcubes are created using SCOPE. Example 1: SCOPE([Measures].[Credit Note CA]); SCOPE([Date NextYear].[Date].[Date], [Time].[Date].Members, [Currencies].[Currency].[Currency]); THIS = [Measures].[Credi

  • 2 pages to work on Pages

    I'm looking to have 2 side by side pages to work on Apple Pages (5.2) and I can't find ... Thanks for help Anaïs

  • Adding a frame border to rounded corners photo

    New to PS..running current ver of 11.x... I found the rounded corners tutorial and that helps alot...but I have a number of photos on a website that I would like to also add a "border" to. sample image corner here:  http://members.cox.net/trinaz/roun

  • Is it possible to move .emlx files to a new machine?

    I just bought a new laptop and wanted to move my old offline messages into the new mail. I tried copying the folders into the new library/mail folder, but that just confused mail.app. So, I deleted those folders (both in finder and in mail.app) an st

  • Importing page

    Hello, we use iWeb to do our company web site. Two person work on the web usin 2 different MACs The first is the "master" where is also stored into a local folder the full web site The second is the "slave" which helps making new pages. To do this he