Execute procedure with WebRowSet

I want to execute stored procedures created in a sql 2000 database using webrowset.
I tried the following:
1. wrs.setCommand("proc1")
2. wrs.setCommang("exec proc1")
both of them gave me the following error:
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]No rows affected.
I need to use the webrowset for xml
How can i then execute the procedures using webrowset??

Well, I couldn't find any way to execute stored procedures directly using WebRowSet. Instead I used a statement that queries a stored procedure and populated the resulting resultset with a webrowset, like this:
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("proc1");
WebRowSet xmlSet = new WebRowSetImpl
xmlSet.populate(rs);
This method works

Similar Messages

  • Reg:execute procedure with in out parameters

    hi,
    what is the code to execute a procedure with in out parameters.can anyone give me an example
    thanks

    872296 wrote:
    thanks for the reply.
    i am very much new to oracle database.i need this code to put in one of my informatica mapping.
    so can you just elaborate what does 'karthick' mean?is it the name of the procedure.No, karthick is the value of the variable that is being passed into the procedure called "P" in karthicks example, then if that procedure changes the value inside, the variable will have that new value passed back out of the procedure to it.
    PROCEDURE prc_mv (name VARCHAR2)
    IS
    BEGIN
    dbms_mview.refresh (mv_name);
    END prc_mv;
    PROCEDURE refresh (response IN OUT NUMBER)
    IS
    BEGIN
    dbms_mview.refresh('mv1','C');
    dbms_mview.refresh('mv2','C');
    response := 1;
    EXCEPTION
    WHEN OTHERS
    THEN
    response := 0;
    END refresh;
    can you give the code for this procedure.Yes.
    DECLARE
      v_response NUMBER;
    BEGIN
      refresh(v_response);
    END;Though your code is awful. There's no point in having the response parameter as an IN OUT if you're not going to pass IN a value and use that in the code anywhere. In your case it only needs to be an OUT parameter because you're just passing back OUT a value. You are also masking any exceptions that happen by using a WHEN OTHERS clause.
    Better code would be something like...
    FUNCTION refresh (mv_name) RETURN NUMBER IS
      v_response NUMBER := 0; -- default response value
      e_mv_not_exist EXCEPTION; -- exception variable
      PRAGMA EXCEPTION_INIT(e_mv_not_exist, -23401); -- connect exception name to internal oracle error number
    BEGIN
      dbms_mview.refresh(mv_name,'C');
      v_response := 1;
    EXCEPTION
      WHEN e_mv_not_exist THEN -- handle specific expected exception
        -- if the materialized view does not exist, handle it gracefully as we don't want to stop
        response := 0;
    END refresh;
    declare
      v_response NUMBER;
    begin
      v_response := refresh('mv1');
      if v_response = 0 then
        -- the materialized view did not exist
      else
        -- the materialized view refreshed ok
      end if;
    end;where your exception handler explicity checks for expected exceptions such as :
    ORA-23401: materialized view "SCOTT"."FRED" does not exist... and any other exceptions that you're not expecting will be raised for you to see.
    It's also better as a function because you don't need to pass in a response value, you just want to get a response value back.
    There's rarely a good need to use OUT or IN OUT parameters. (there's some cases, but it's not something to consider doing as part of your regular design)

  • Executing procedures with OUT parameters using Named notation

    I have a procedure with two out parameters (p_errortext and p_returncode) and i want to execute this proc in SQL*plus using named notation(using association operator ' => '). For position based execution i usually declare variables to hold the OUT parameter's value. But how can i do this while executing using named notation (using => )
    begin
         packagename.generate_ref_record(p_userid  => 'THELMA',
                                      p_ref_code       => '9A',
                                      p_item_id    => '9990000011163',
                                      p_shipno     => '0PH',
                                      p_errortext  =>  ??
                                      p_returncode =>  ??);
    end;

    SQL>variable x varchar2(30);
    SQL>variable y varchar2(30);
    SQL>exec packagename.generate_ref_record(p_userid  => 'THELMA',     
                                          p_ref_code       => '9A',       
                                          p_item_id    => '9990000011163',     
                                          p_shipno     => '0PH',     
                                          p_errortext  =>  :x        
                                          p_returncode =>  :y);

  • Execute procedure with hr_maintain_masterdata

    Hi all,
    I'm trying to execute a procedure using hr_maintain_masterdata. I'm encountering some problems. The procedure consists of 2 infotypes 0 & 1.
    On the infotype 0 screen I have a field 'Q0000-rfpnr' that needs to be filled out (but is not required). Using the 'proposed values' I can not set this value.
    Also, I can not get to the second screen. I have tried to put the ok_codes, but no success there.
    Can anyone help me?
    Regards,
    Luk
    Hereby the calling code...
      CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'
       EXPORTING
         pernr                    = l_pernr
         massn                    = lc_massn
    *     actio                    = 'INS'
    *      TCLAS                    = 'A'
    *      BEGDA                    = SY-DATUM
    *      ENDDA                    = '99991231'
    *      OBJPS                    =
    *      SEQNR                    =
    *      SPRPS                    =
    *      SUBTY                    =
    *      werks                    = lc_werks
    *      persg                    = lc_persg
    *      persk                    = lc_persk
    *      plans                    = im_plans
          dialog_mode              = '1'
    *      LUW_MODE                 = '1'
          no_existence_check       = 'X'
          no_enqueue               = 'X'
    *    IMPORTING
    *      RETURN                   =
    *      RETURN1                  =
    *      HR_RETURN                =
        TABLES
          proposed_values          = lt_prop
    *      MODIFIED_KEYS            =

    Hi Luk,
    if you work with reference personnel numbers you will also consider infotype 0031 for your procedure. There is a relationship (Q0000-RFPNR) between the infotypes 0000 and 0031.
    Regards
    Michael

  • Executing Procedure with default parameters !!

    hi want a small help ...
    I have a
    procedure p1(p1 in number default 2, p2 in number default 3)
    begin
    end;
    When the procedure will be called without passing parameters it will execute with default parameters.
    That time I want to dispay message saying
    " AS paramters are not passed, procedure is being executed with foll. default parameters:
    Param 1 = 2
    Param 2 = 3 "
    Now issue is how do I capture this condition that , the parameters are being passed and it is using default parameters ?
    Thanks

    The IF NOT NULL check for the parameters cannot be inside the same procedure becuase when you reach that statement, even though the parameter are not passed to this procedure, at that stage, the parameters will acquire the dfault values already assigned to them. So you never reach the else part of it.
    That;s why i said, use third parameter and assign the value to this third parameter from the calling environment.
    here is the short test case that might help you to understand better.
    SQL> create or replace procedure myproc
      2  (p1               number default 1
      3  ,p2               number default 2
      4  ,parameter_passed char default 'Y') is
      5  begin
      6    if parameter_passed = 'Y' then
      7      dbms_output.put_line('Input values are :'||p1||'='||p2);
      8    else
      9      dbms_output.put_line('Default values are :'||p1||'='||p2);
    10    end if;
    11  end;
    12  /
    Procedure created.
    SQL> PROMPT Test for Case one with input parameter values
    Test for Case one with input parameter values
    SQL>
    SQL> declare
      2   param1 number := 5;
      3   param2 number := 6;
      4  begin
      5   if param1 is not null and param2 is not null then
      6     myproc(param1,param2);
      7   else
      8     myproc(parameter_passed=>'N');
      9   end if;
    10  end;
    11  /
    Input values are :5=6                                                          
    PL/SQL procedure successfully completed.
    SQL>
    SQL> PROMPT Test for Case two with no parameter values
    Test for Case two with no parameter values
    SQL>
    SQL> declare
      2   param1 number := null;
      3   param2 number := null;
      4  begin
      5   if param1 is not null and param2 is not null then
      6     myproc(param1,param2);
      7   else
      8     myproc(parameter_passed=>'N');
      9   end if;
    10  end;
    11  /
    Default values are :1=2                                                        
    PL/SQL procedure successfully completed.
    SQL>

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

  • Executing procedure with IN OUT parameters using SQL developer

    Hi, I'm trying to exceute the below procedure in SQL developer. Here the IN OUT cursor 'journal_cursor' is already defined.
    PROCEDURE LIST_FORPROJECT (
              p_project_sid IN NUMBER,
              p_journal_cursor IN OUT journal_cursor,
         AS
         BEGIN
              OPEN p_journal_cursor FOR
              -- get the journal
                   SELECT j.JOURNAL_KEY AS "Journal_SID",
                             j.JOURNALTEXT AS "Entry",
                             j.CREATEDATE AS "CreateDate",
                             --j.COMMENT_ AS "Comment",
                             j.PROJECTPHASETASK_KEY AS "ProjectPhaseTaskSet_SID",
                             j.person_key AS "Person_SID"
    FROM vdl_JOURNAL j
                   INNER JOIN vdl_PROJECTJOURNAL pj ON pj.JOURNAL_KEY = j.JOURNAL_KEY
                   WHERE pj.PROJECT_KEY = p_project_sid
                   ORDER BY j.CREATEDATE ASC, j.JOURNAL_KEY ASC;
    END LIST_FORPROJECT;
    When trying to run the above procedure through SQL developer, I get the below code generated.
    DECLARE
    P_PROJECT_SID NUMBER;
    P_JOURNAL_CURSOR journal_cursor;
    BEGIN
    P_PROJECT_SID := 5974;
    -- Modify the code to initialize the variable
    -- P_JOURNAL_CURSOR := NULL;
    -- Modify the code to initialize the variable
    LIST_FORPROJECT(
    P_PROJECT_SID => P_PROJECT_SID,
    P_JOURNAL_CURSOR => P_JOURNAL_CURSOR,
    -- Modify the code to output the variable
    DBMS_OUTPUT.PUT_LINE('P_JOURNAL_CURSOR' || P_JOURNAL_CURSOR);
    END;
    But executing the above sql doesn't print the cursor as output but errors out saying 'wrong number or type or arguments in call to ||'. Can somebody please help me in finding a way test and view the results of such a procedure through SQL developer?
    Any help is highly appreciated.
    Regards,
    Ranganath

    Hi,
    I was able to solve the problem.. My cursor was declared like this.
    TYPE journal_def IS RECORD
              journal_sid                    NUMBER(10),
              journaltext                    CLOB,
              createdate                    DATE,
              projectphasetaskset_sid     NUMBER(10),
              person_sid                    NUMBER(10)
    TYPE journal_cursor                    IS REF CURSOR RETURN journal_def;
    I used the journal_def type to fetch the records.
    Here is how my final sql looked like.
    DECLARE
    P_PROJECT_SID NUMBER;
    P_JOURNAL_CURSOR journal_cursor;
    P_J_CURSOR journal_def;
    BEGIN
    P_PROJECT_SID := 11171;
    -- Modify the code to initialize the variable
    -- P_JOURNAL_CURSOR := NULL;
    LIST_FORPROJECT(
    P_PROJECT_SID => P_PROJECT_SID,
    P_JOURNAL_CURSOR => P_JOURNAL_CURSOR,
    -- Modify the code to output the variable
    BEGIN
    --open P_JOURNAL_CURSOR;
    loop
    fetch P_JOURNAL_CURSOR into P_J_CURSOR;
    exit when P_JOURNAL_CURSOR%NOTFOUND;
    DBMS_OUTPUT.put_line(P_J_CURSOR.journal_sid);
    end loop;
    --close P_JOURNAL_CURSOR;
    END;
    END;
    This gave me results. Thanks a ton ALL for your help..... :)..
    Regards,
    Ranganath

  • Executing procedure with collection TYPE as IN param

    Hi ,
    I am using Oracle Version 10.2.0.4.0.
    I have created a TYPE AE_SEQ_TAB1 IS TABLE OF number;
    This is my SP header:
    PROCEDURE test_data
    ip_table_nm IN VARCHAR2,
    ip_ae_seq_no IN      AE_SEQ_TAB1,
    op_error_cd OUT VARCHAR2,
    op_error_desc OUT VARCHAR2,
    op_active_data OUT SYS_REFCURSOR
    I want to pass multiple values to ip_ae_seq_no while testing this SP. So I am doing like.
    DECLARE
    REF_CUR SYS_REFCURSOR;
    ERR     VARCHAR2(1000);
    ERR1     VARCHAR2(1000);
    ip_ae_seq_no ae_seq_tab1;
    BEGIN
    ip_ae_seq_no :=ae_seq_tab1(1,2,3);
    test_data('CP_TBL',ip_ae_seq_no,ERR,ERR1,REF_CUR);
    END;
    This gives me the error with :
    ORA-06550: line 8, column 1:
    PLS-00306: wrong number or types of arguments in call to test_data
    Whats the mistake I am doing in this?
    Also can I check the count of elements from this table at run time something like
    SELECT COUNT(1) INTO l_tab_type_cnt from TABLE(ip_ae_seq_no);
    Rgds,
    Aashish
    Edited by: Aashish S. on Jan 27, 2010 1:41 PM

    Just initialize you collection...
    Without values:
    SQL> DECLARE
      2  REF_CUR SYS_REFCURSOR;
      3  ERR VARCHAR2(1000);
      4  ERR1 VARCHAR2(1000);
      5  ip_ae_seq_no ae_seq_tab1:=ae_seq_tab1();
      6  BEGIN
      7  test_data('CP_TBL',ip_ae_seq_no,ERR,ERR1,REF_CUR);
      8  END;
      9  /
    collection size=0
    PL/SQL procedure successfully completed.or with values:
    SQL> DECLARE
      2  REF_CUR SYS_REFCURSOR;
      3  ERR VARCHAR2(1000);
      4  ERR1 VARCHAR2(1000);
      5  ip_ae_seq_no ae_seq_tab1:=ae_seq_tab1(1,2,3,4);
      6  BEGIN
      7  test_data('CP_TBL',ip_ae_seq_no,ERR,ERR1,REF_CUR);
      8  END;
      9  /
    collection size=4
    PL/SQL procedure successfully completed.Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2010/01/23/la-forza-del-foglio-di-calcolo-in-una-query-la-clausola-model/]
    Edited by: Massimo Ruocchio on Jan 27, 2010 9:20 AM
    Added second example

  • Executing Procedures with an ODBC Passthrough query

    Hi all,
    Our current environment is oracle 8.1.7 db with an MS Access front end.
    We are currently working on migrating the backend to 9.2.0.4, however testing has shown that sql passthrough statements that call stored procedures on the database now throw an ODBC error.
    Has anyone else encountered this? and what was your solution.
    P.S. budget restrictions preclude the obvious prefered solution - the front end will not change.

    I recall seeing some documents in Microsoft's Knowledge Base back when 9i was new that said that things like ODBC and OLEDB were not going to support connectivity to Oracle 9i. For 9i .NET would have to be used instead. I don't know if this is still true, but the MS KB should be a good place for you to look.

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

  • Please help....execute procedure with out parameter -cursor

    HI all plese help me,
    i create a stored procedure like this.hw cani execute the IN out parameter which is a cursor ir..RCT1 is cursor..
    please help...
    CREATE OR REPLACE PROCEDURE ST_GetTravelTypeID
         TravelType IN      VARCHAR2 DEFAULT NULL,
         RCT1 IN OUT      GLOBALPKG.RCT1
    AS
    BEGIN
         OPEN RCT1 FOR
         SELECT
                   TravelTypeCode,
                   TravelTypeDesc
         FROM ST_MS_TravelTypes
         WHERE     TravelType = ST_GetTravelTypeID.TravelType;
    END;
    Message was edited by:
    neethu

    Your reference is invalid:
    WHERE TravelType = ST_GetTravelTypeID.TravelType;
    This should not (cannot) refer to the name of the procedure - but simply to the variable in it. I.e.
    WHERE TravelType = TravelType;
    However, as you can see, the variable name is now the same as the column name.
    One method around this is to use explicit scope reference. E.g.
    SELECT
      t.TravelTypeCode,
      t.TravelTypeDesc
    FROM  ST_MS_TravelTypes t
    WHERE t.TravelType = TravelType;I suggest that you consider this a standard for your PL/SQL programming. Always alias SQL tables in PL/SQL code and use explicit column references.
    Another standard we use is to use underscore characters for columns - camel case is fine for variables in a programming language. This is not really acceptable for column names, as by default Oracle uses uppercase. Thus "TravelType" is valid as variable name, but invalid as a column name - it should be defined/written as "travel_type" or "TRAVEL_TYPE" instead.

  • Executing procedure for period

    Hi all,
    My need is to execute procedure with parameter date for period from 01.03.2011 till 31.03.2011.
    One way is to type dates one per line:
    EXEC schemename.pkg_name.procedure_name date '2011-03-01';
    EXEC schemename.pkg_name.procedure_name date '2011-03-02';
    EXEC schemename.pkg_name.procedure_name date '2011-03-30';
    EXEC schemename.pkg_name.procedure_name date '2011-03-31';But how do I execute it using more simple code?

    Hello
    It kind of depends what you mean by simpler. If you want to avoid having 31 separate calls to the procedure listed on 31 lines, you can use a loop like so...
    SQL> DECLARE
      2
      3      ldt_StartDate       DATE := TO_DATE('01/03/2011','dd/mm/yyyy');
      4      ldt_EndDate         DATE := TO_DATE('31/03/2011','dd/mm/yyyy');
      5
      6  BEGIN
      7
      8      FOR lc_Dates IN (   SELECT
      9                              ldt_StartDate + (rownum -1) dt
    10                          FROM
    11                              dual
    12                          CONNECT BY
    13                              LEVEL <= CEIL(ldt_EndDate - ldt_StartDate) + 1
    14                      )
    15      LOOP
    16          dbms_output.put_line(lc_Dates.dt);
    17      END LOOP;
    18
    19  END;
    20  /
    01-MAR-11
    02-MAR-11
    03-MAR-11
    04-MAR-11
    05-MAR-11
    06-MAR-11
    07-MAR-11
    08-MAR-11
    09-MAR-11
    10-MAR-11
    11-MAR-11
    12-MAR-11
    13-MAR-11
    14-MAR-11
    15-MAR-11
    16-MAR-11
    17-MAR-11
    18-MAR-11
    19-MAR-11
    20-MAR-11
    21-MAR-11
    22-MAR-11
    23-MAR-11
    24-MAR-11
    25-MAR-11
    26-MAR-11
    27-MAR-11
    28-MAR-11
    29-MAR-11
    30-MAR-11
    31-MAR-11
    PL/SQL procedure successfully completed.HTH
    David

  • Return code for EXECUTE PROCEDURE (native SQL)

    Hi Experts,
    I've seen in the Note 364707 that the field %_ERRCODE is no longer supported since WAS 6.10 for stored procedures like this:
    EXEC SQL.
      EXECUTE PROCEDURE proc [(parameter list)] %_ERRCODE INTO :rc
    ENDEXEC.
    So an Upgrade to WAS 7.00 gives this programms an error.
    Has anybody an idea for an alternative?
    Regards,
    Stefan

    Hello Peluka,
    i have seen you have worked with 'execute procedure'.
    I want to execute a procedure with two Parameters and one structure. Example:
    EXECUTE PROCEDURE test.p_getdata ( in :i_ls_nr , in :vdatum , out :vtest ).
    vtest has the simple structure with field lieferscheinnr (char25).
    When i execute the procedure, i get the error <b>wrong number or types of arguments in call</b>.
    Do you know, whether execute procedure with structures is not possible?
    Thank you in advance.

  • How can I execute a Procedure with OUT variable is %ROWTYPE on SQL Prompt

    Hi,
    I have a procedure with OUT variable is %ROWTYPE
    How can I execute the following procedure on SQL prompt.
    (without creating anonymous block)
    CREATE OR REPLACE PROCEDURE zz_sp_EMP(VEMPNO IN EMP.EMPNO%TYPE,
    V_REC IN OUT EMP%ROWTYPE)
    AS
    BEGIN
    SELECT * INTO V_REC FROM EMP WHERE EMPNO = VEMPNO;
    END;
    Thanks & Regards,
    Naresh

    as previous posters said: it's not possible to do this without declaring a variable in the anonymous block.
    With anonymous block it would look like this (had to change it a bit, since i'm using hr-schema on oracle XE):
    declare
    l_rec EMPLOYEES%ROWTYPE;
    begin
    zz_sp_EMP(VEMPNO => 100, V_REC => l_rec);
    DBMS_OUTPUT.PUT_LINE ( 'first_name = ' || l_rec.first_name );
    DBMS_OUTPUT.PUT_LINE ( 'last_name = ' || l_rec.last_name );
    end;
    first_name = Steven
    last_name = King

  • Execute a procedure with a list of array in sql server 2008

    HI all,
    I have a procedure which has a list of values passed as an array . How can i execute my procedure with array list? how to implement this?Please help me.
    Thanks in advance
    Deepa

    Hi Deepa,
    basically Microsoft SQL Server does not support arrays as data types for procedures. What you can do is creating a type which represents a table definition. This type can than be used in a procedure as the following demo will show:
    The first script creates the environment which will be used for the execution
    -- 1. create the table as a type in the database
    CREATE TYPE OrderItems AS TABLE
    ItemId int PRIMARY KEY CLUSTERED
    GO
    -- 2. demo table for demonstration of results
    CREATE TABLE dbo.CustomerOrders
    Id int NOT NULL IDENTITY (1, 1) PRIMARY KEY CLUSTERED,
    CustomerId int NOT NULL,
    ItemId int
    GO
    -- 3. Insert a few records in demo table
    INSERT INTO dbo.CustomerOrders
    (CustomerId, ItemId)
    VALUES
    (1, 1),
    (2, 1),
    (3, 3),
    (1, 3);
    GO
    -- 4. Create the procedure which accepts the table variable
    CREATE PROC dbo.OrderedItemsList
    @Orders AS OrderItems READONLY
    AS
    SET NOCOUNT ON;
    SELECT o.*
    FROM dbo.CustomerOrders AS O INNER JOIN @Orders AS T_O
    ON (o.ItemId = T_O.ItemId);
    SET NOCOUNT OFF;
    GO
    The above script creates the table data type and a demo table with a few demo data. The procedure will accept the table data type as parameter. Keep in mind that table variable parameters have to be READONLY as parameter for procedures!
    The second script demonstrates the usage of the above scenario
    When the environment has been created the usage is a very simple one as you can see from the next script...
    -- 1. Fill the variable table with item ids
    DECLARE @o AS OrderItems;
    INSERT INTO @o (ItemId)
    VALUES
    (1), (3);
    -- 2. Get the list of customers who bought these items
    EXEC dbo.OrderedItemsList @Orders = @o;
    MCM - SQL Server 2008
    MCSE - SQL Server 2012
    db Berater GmbH
    SQL Server Blog (german only)

Maybe you are looking for