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.

Similar Messages

  • Execute procedure with out parameter in sql*plus

    HI All,
    I am executing an stored proc with OUT parameter from sql*plus.
    Getting this error message:
    SQL> execute sp1_cr_ln_num('01',0,3);
    BEGIN sp1_cr_ln_num('01',0,3); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to
    'sp1_cr_ln_num'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Whereas it works fine using Toad. 4th parameter is for output.
    Thanks.

    then you can see the value either using print :var or execute dbms_output.put_line(:var)

  • How can I get the data array from SQL Server Database?

    Hi,
    I can write a data array(2D)into a table of my SQL Server Database. The data array was writen to a column with image type. I know a data array is transformed a binary string when writing into database, but I dont know how to get the data array when I fetch the binary string from database.
    My question is:
    How to transform the binary string into data array? which vi's should I use? I have tried unflatten from string but failed.
    Any response is appriciated.
    Red

    happyxh0518 wrote:
    > I can write a data array(2D)into a table of my SQL Server Database.
    > The data array was writen to a column with image type. I know a data
    > array is transformed a binary string when writing into database, but I
    > dont know how to get the data array when I fetch the binary string
    > from database.
    >
    > My question is:
    > How to transform the binary string into data array? which vi's should
    > I use? I have tried unflatten from string but failed.
    In order to use Unflatten from string you first need to Flatten it
    before writing it. Also depending on the database driver, the returned
    data may actually not be binary but Hexadecimal encoded ASCII which you
    would first have to decode to binray.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to return a value from sql plus activity

    Hi,
    I want to return a value from sqlplus activity to a processflow variable.
    SQL PLUS activity has a property :"RESULT_CODE", whenever i run the process flow this value is always reurned as 0.
    in sqlplus activity i have written some pl/sql block....
    for example
    begin
    end;
    exit
    i want to do something like
    begin
    if v=100 then
    return 1
    else
    return 0;
    end if;
    end;
    exit
    can some please tell me how can i return value from this pl/sql block to proessflow.
    Regards,
    RD_RBS

    table ==> function
    input param from table to function. ==> input mapping paramter to store the output from the mapping.
    Will this now work.

  • How to pass table type variable into function from SQL*PLUS ?

    How to pass a table type variable from sql*plus prompt into a function ?
    Thanx in advance.

    Krishna,
    Do you mean like this?SQL> DECLARE
      2      TYPE t_tbl IS TABLE OF VARCHAR2(20);
      3      l_sample_tbl           t_tbl;
      4
      5      FUNCTION print_contents ( p_tbl IN t_tbl )
      6      RETURN VARCHAR2
      7      IS
      8          l_string            VARCHAR2(1000);
      9      BEGIN
    10          FOR i IN 1..p_tbl.COUNT LOOP
    11              IF (i = 1) THEN
    12                  l_string := p_tbl(i);
    13              ELSE
    14                  l_string := l_string || ', ' || p_tbl(i);
    15              END IF;
    16          END LOOP;
    17          RETURN (l_string);
    18      END print_contents;
    19
    20  BEGIN
    21      l_sample_tbl := t_tbl();
    22      l_sample_tbl.EXTEND;
    23      l_sample_tbl(1) := 'one';
    24      l_sample_tbl.EXTEND;
    25      l_sample_tbl(2) := 'two';
    26      l_sample_tbl.EXTEND;
    27      l_sample_tbl(3) := 'three';
    28      l_sample_tbl.EXTEND;
    29      l_sample_tbl(4) := 'four';
    30      l_sample_tbl.EXTEND;
    31      l_sample_tbl(5) := 'five';
    32      DBMS_OUTPUT.PUT_LINE(print_contents(l_sample_tbl));
    33  END;
    34  /
    one, two, three, four, five
    PL/SQL procedure successfully completed.
    SQL> HTH,
    T.

  • If the result from the stored procedure returns 0 rows I get this error returned:

    If the result from the following stored procedure returns 0
    rows I get this error returned:
    faultCode:Server.Processing faultString:'Variable transfers
    is undefined.' faultDetail:''
    How can I get round this?

    Well if I try this in a cfm page:
    <cfstoredproc procedure="GetTransfers"
    datasource="datasource" returncode="true">
    <cfprocparam type="in" cfsqltype="CF_SQL_VARCHAR"
    value="4">
    <cfprocparam type="in" cfsqltype="cf_sql_date"
    value="12/09/2006 08:42:00">
    <cfprocparam type="in" cfsqltype="cf_sql_date"
    value="12/09/2008 08:42:00">
    <cfprocresult name="transfers">
    I get an error like:
    [Macromedia][SQLServer JDBC Driver][SQLServer]Procedure or
    function 'GetTransfers' expects parameter '@fromdate', which was
    not supplied.
    But this procedure only accepts 3 parameters.

  • How execute this stored procedure from SQL PLUS???

    Hello folks....
    Help me please...
    I have this procedure....
    CREATE OR REPLACE PROCEDURE TEST(COD OUT VARCHAR2, NUM OUT
    VARCHAR2, ID OUT VARCHAR2)
    AS
    BEGIN
    END;
    SO, I4D LIKE TO EXECUTE IT FROM SQL PLUS::
    BUT, I DONT KNOW HOW TO DO..PLEASE SEND ME A SAMPLE..
    THANK U

    Thank u man!!!
    look, my error before was :
    SQL> set serveroutput on
    SQL> declare
    SQL> cod varchar2(100);
    SQL> num varchar2(100);
    SQL> id varchar2(100);
    SQL> begin
    SQL> TEST( cod, num, id );
    SQL> EXEC DBMS_OUTPUT.put_line( cod || ' ' || num || ' ' ||
    id );
    SQL> end;
    SQL> /
    i put the EXEC....
    thank u!!!

  • CREATE OR REPLACE PROCEDURE return data like SELECT statement

    "SELECT * FROM SEARCH_KEYWORD" is successfully done and return the data of the tables. Now, I want to run that on server side using PROCEDURE.
    I successfully executed the below scripts. Please teach me how to call the sp_test procedure. OR if you have other way or maybe my scripts are wrong.
    CREATE OR REPLACE PACKAGE GLOBALPKG
    AS
         TYPE RCT1 IS REF CURSOR;
         TRANCOUNT INTEGER := 0;
         IDENTITY INTEGER;
    END;
    CREATE OR REPLACE PROCEDURE LPG.sp_test
         RCT1 IN OUT      GLOBALPKG.RCT1
    AS
    BEGIN
         OPEN RCT1 FOR
         SELECT *
         FROM SEARCH_KEYWORD;
    END;
    Here is my table definition:
    CREATE TABLE LPG.SEARCH_KEYWORD
    FRACTION VARCHAR2(50),
    KEYWORD VARCHAR2(50),
    PURPOSE VARCHAR2(50),
    REMARKS VARCHAR2(50),
    DATE_INSERTED DATE DEFAULT sysdate
    PCTFREE 10
    PCTUSED 40
    MAXTRANS 255
    TABLESPACE SYSTEM
    STORAGE(INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    NOCACHE
    LOGGING
    Eros
    Japan

    Wrong forum. You should ask this question in the SQL and PL/SQL forum.
    Couple of comments though. Oracle is not SQL-Server. So calling a procedure that returns a ref cursor is different from a T-SQL macro procedure that functions like a view.
    Also, there is no need to use the SQL-Server standard (and silly one at that) of prefixing stored procedures using the text "sp_". In fact, the whole concept of Hungarian-like notation is something of the past and has no place in today's paradigm of software engineering.
    As for calling a a proc that returns a ref cursor, from SQL*Plus it will look as follows:
    SQL> var c refcursor
    SQL>
    SQL> exec LPG.sp_test( :c )
    SQL> print c
    Ref cursor needs to be supported by the client language you use to make this call to Oracle.

  • Custom database functoid to return multiple rows from database

    Hi,
    I have created a custom database fucntoid to execute a stored procedure which returns just single row from the database.But I could not manage to return multiple rows from the database.
    Does anyone know how to return multiple rows from DB and create a node with that many occurrences in the target schema?
    Thanks
    JB

    If you want to do this in messaging-only way without orchestration, then only option let to you is using .NET in BizTalk:
    We had similar requirement with one of our clients, where they didn’t want to use orchestration (though we emphasised on less impact orch would have compared to manageability),
    they still wanted to have pure-messaging only.
    We extended the custom XslTransform component that ships with BizTalk SDK (<BizTalk installation directory>\SDK\Samples\Pipelines\XslTransformComponent)).
    Created a custom disassembler pipeline component, used the XslTransform component from SDK to execute the map’s XSLT. Here we created a map with every links except the database ones. After executing the map, access the database, execute the store procedure
    which returns more than one row/dataset, enrich the XSLT transformed message with the dataset from your database in disassembler.
    Since .NET gives you the flexibility of access the dataset with more than one row, you can enrich the message in custom pipeline code.
    Other option is code the message transformation completely in .NET code in custom disassembler by passing the received message to method/code which would code the map/enrichment.
    While enriching you can execute the store procedure which returns more than one row/dataset, enrich the message further with the dataset from db.
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • JDeveloper + WebServices, RETURN multiple rows from pl/sql

    I need to return multiple rows from pl/sql procedure or function and publish it as a Web Service through JDeveloper.
    I try to use ref cursor, but then found that it is impossible to use ref cursor as a return value in Web Services.
    Please, help me to achieve result.

    Hello. I tried to make commands from article, but got errors
    "C:\Program Files\Java\jdk1.6.0_18\bin\java" -jar D:\oracle\Middleware\oracle_common\modules\oracle.webservices_11.1.1\wsa.jar -plsqlAssemble -appName Echo -sql wo -dataSource jdbc/OracleManagedDS -dbConnection jdbc:oracle:thin:@192.168.246.2:1521:data -dbUser syd/manager -style rpc -use encoded
    Error: Interface oracle.generated.wo: The class could not be loaded from the class path.

  • How to exit from SQL*Plus based on the return value of a SQL select stment?

    Hi
    I have a SQL script executed from SQL*Plus. I would like to know if SQL*Plus
    supports any kind of branching or exiting from script execution based on a
    returned value of a SQL select statement. I am on 9i.
    Regards,
    Tamas Szecsy

    in sqlplus, you have whenever
    ex:
    whenever sqlerror exit failure
    insert into ...
    -- if this fails, then you will be out
    insert into ...
    -- if this fails, then you will be out
    whenever sqlerror continue
    insert into ...
    -- if this fails, this continues
    insert into ...and you have PL/SQL
    declare x number;
    begin
    select count(*) into x from emp;
    if (x=14) then null; end if;
    end;
    /note that you can mix those in some case
    -- exit if there is no row in emp
    whenever sqlerror exit 1
    var dummy number
    exec select count(*) into :dummy from emp having count(*)!=0

  • How we can automate the data loading from BI-BPC

    Dear  Guru's
    Thanks for watching this thread,my question is
                  How we can load the data from BI7.0 to BPC.My environment is SAP-BI 7.0 and BPC is 7.5 MS version and 2008SQL.
    How we can automate the data loading from  BI- BPC Ms version.Is manual flat file load is mandatory in ms version.
    Thanks in Advance,
    Srinivasan.

    Here are some options
    1) Use standars packages and schedule them :
        A) Openhub masterdata file into a flat file/ BPC App server  and Schedule the package - Import Master Data from a Data File and  other relevent packages.
    2 ) Using Custom Tasks in Custom Packages ( SSIS)
    Procedure
    From the Microsoft SQL Server Business Intelligence Developer Studio, open the Microsoft SSIS folder.
    Create a new package, or select an existing package to modify.
    Choose  Task  Register Custom Task .
    In the Task Location field, browse for the target .dll file.
    Note
    By default, the .dll files are stored in BPC/Websrvr/bin.
    End of the note.
    Enter a task description, select an appropriate icon, then click OK.
    Drag the icon to the designer window. Enter data as required.
    Save the package.

  • How to view  a stored procedure from sql plus

    Can anyone please tell what is the command for viewing the content of the stored procedure from sql plus ?
    Thanks

    Hi,
    I use this simple script to retrieve.......
    EDTRAD@T_E_S_9-->l
    1 select text from all_source where name = 'GET_MAN' -- proc name here
    2* order by line asc
    EDTRAD@T_E_S_9-->/
    TEXT
    FUNCTION get_man (in_man SSBOSS.CLNTWORK.manager%type)
    RETURN varchar2 IS
    CURSOR get_man(in_man SSBOSS.CLNTWORK.manager%type) IS
    SELECT name
    FROM ssboss.clntwork
    WHERE agency = 'TM'
    AND manager = in_man
    AND manager is not null
    AND manager != '**OB**';
    v_man SSBOSS.CLNTWORK.name%type := null;
    BEGIN
    OPEN get_man(in_man);
    FETCH get_man INTO v_man;
    IF get_man%notfound THEN
    v_man := 'Manager Not Found !';
    RETURN (v_man);
    CLOSE get_man;
    END IF;
    RETURN (v_man);
    CLOSE get_man;
    END;
    21 rows selected.
    EDTRAD@T_E_S_9-->

  • How To Access PAGE ITEM (single row) from HTML source

    Hi Guys,
    I have a page Item that return a string.
    I would like to show this string
    How To Access PAGE ITEM (single row) from HTML source?
    My desire final output is
    <marquee>:P1_PAGE_ITEM</marquee>
    Can please help me
    Thanks

    Hi,
    You can refer the page items in your page header as &itemname. For example, if I have page item P15_TEST, I will add the following in header:
    <marquee>
       &P15_TEST.
    </marquee>But make sure that you have a process before header to populate the value in your page item. Otherwise, there will be a null scrolling (which you can't see!) :)
    Regards,
    Zahid

  • 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 ;)

Maybe you are looking for

  • Can not open .pdf using Adober Reader XI

    I downloaded Adobe Reader XI and now am having problems opening .pdf files.  Is there any way that I can revert back to Adobe Reader X?

  • Time Capsule Restarting Problem

    I just bought a Time Capsule (4th Generation) about a week ago. Works great except it keeps restarting itself, or at least that what I think its doing. All of the ethernet lights on the back of the capsule will turn off, I will loose network connecti

  • MSI-180: Radio is very quiet

    Hello I have the following problem with my MSI-180: The volume of the radio is very quiet. The volume level is much lower than for all other devices (like DVD, TV, etc). Even setting the volume of the Mixer in Windows to max is not enough to ajust th

  • [SOLVED] How to limit cpu usage by makepkg?

    I tried cpulimit -l 30 makepkg but the cpu usage still reaches 100% + 100% due to conky (i have 2 core cpu). OK, I've found out that cpulimit does not restrict child processes but cgroup is promised to do that. So I installed it from AUR and did the

  • Send pdf as attachment to web email

    If my company switched to a gmail emai account, how do I change properties in Adobe Acrobat to reflect that instead of automatically attaching to an email through Outlook?