Commit/Rollback in Stored Procedures

I'm just confused about how this setup works. I understand that ODP.NET is in autocommit mode by default, and any INSERT, UPDATE, or DELETE commands are committed automatically. If they fail for any reason, obviously the row(s) are not modified.
But how about sprocs? Do they autocommit as well? If so how are rollbacks handled? Do I need to explicitly create a transaction and commit/rollback? Is it best practice to commit/rollback in the .NET transaction or in the sproc itself?
As you can see, I'm just really looking for info on how these two interact. Any info you can provide will be extremely helpful.
Thanks!

Hello,
When ODP.NET is operating in auto-commit mode (the default as you note) this applies to PL/SQL calls as well.
I am of the opinion that the client should be in charge of a transaction and I do not commit/rollback inside PL/SQL code (unless of course I am writing PL/SQL that is the client of other PL/SQL code).
Here's a bit from Tom Kyte on the subject:
http://tkyte.blogspot.com/2007/03/dreaded-others-then-null-strikes-again.html
Just search for the text "Who control the commit?" on that page.
Regards,
Mark

Similar Messages

  • Put a commit in a stored procedure that is called remotely, give error

    I put a commit in a stored procedure that is called remotely, this gives me an error. Why?

    Why? Because only the calling procedure - the local one - can have commits. Please read my reply to Re: DBlink: Can I access to a remote type?. In particularly read the part of the documentation it links to, about distributed transactions.
    Cheers, APC

  • Would RollBacks For Stateless Session Beans work In case of Stored Procedures or Triggers Written in Oracle PL/SQl

              We are writing a J2EE application and using Weblogic 5.1 on Unix machine. We are
              considering writing some Stored Procedures or Triggers on Oracle DBMS. Hence our
              Stateless Session Beans / Data Access Objects (DAOs) would be calling those stored
              procedures, which would reside on Oracle 8.1.7 (on Windows 2000). (These Data
              Access Objects are running under the umbrella of a Stateless Session Beans). We
              are using WebLogic's Connection Pooling.
              Our question is: Would we get reliable rollbacks from our stored procedures. I
              mean would the Transaction Management process of the EJB container work. Remember
              the SQL is written in the Database (Oracle in this case) in the form of Stored
              Procedures / Triggers through PL/SQL.
              Any ideas or tips would help.
              

              I would agree with Cameron Purdy. Be very cautious to use Oracle specific
              Triggers / Stored Procedures. Consider following, (apart from what he said):
              1. Unreliable behaviour of the Oracle JDBC drivers, specially 8.1.6 family..
              (You may visit the Oracle's web site and see the newsgroups for the JDBC drivers).
              This is enough of a reason to stop right there.
              However for interest sake you may consider following issues:
              2. By use of Oracle specific Triggers / SPs the application will not be portable.
              Vendor Lock In. Remember your choice for J2EE compliant Server (WebLogic in this
              case). The whole purpose would be defeated by going for this option.
              3. There are issues related to the extensibility of the application. I have
              my reservations and would hold my breath on two phase commit protocol transactions
              being reliable in this scenario.
              Have fun...
              Terry
              "Cameron Purdy" <[email protected]> wrote:
              >Yes, the work performed by the SPs and the triggers would be in the same
              >tx.
              >
              >What would NOT work is if the data has been read into WebLogic and then
              >it
              >gets affected by a trigger or SP on the RDBMS, the data in WebLogic is
              >not
              >automatically re-read within that same tx so you need to be careful.
              >
              >Peace,
              >
              >--
              >Cameron Purdy
              >Tangosol Inc.
              >Tangosol Coherence: Clustered Coherent Cache for J2EE
              >Information at http://www.tangosol.com/
              >
              >
              >"Ahmad" <[email protected]> wrote in message
              >news:[email protected]...
              >>
              >> We are writing a J2EE application and using Weblogic 5.1 on Unix machine.
              >We are
              >> considering writing some Stored Procedures or Triggers on Oracle DBMS.
              >Hence our
              >> Stateless Session Beans / Data Access Objects (DAOs) would be calling
              >those stored
              >> procedures, which would reside on Oracle 8.1.7 (on Windows 2000). (These
              >Data
              >> Access Objects are running under the umbrella of a Stateless Session
              >Beans). We
              >> are using WebLogic's Connection Pooling.
              >> Our question is: Would we get reliable rollbacks from our stored
              >procedures. I
              >> mean would the Transaction Management process of the EJB container
              >work.
              >Remember
              >> the SQL is written in the Database (Oracle in this case) in the form
              >of
              >Stored
              >> Procedures / Triggers through PL/SQL.
              >> Any ideas or tips would help.
              >
              >
              

  • Commit inside stored procedure

    If you call a procedure from another procedure and issue COMMIT, then you commit not just inner stored procedure, but also outside procedure. Am I right? Can we make SP smarter and commit only statement in inner SP?

    But bear in mind that a rollback will have a similar effect. A rollback of parent transaction will not undo the work done in the autonomous transaction. That might be a issue to watch out for if you wanted to undo all the changes in the event of an error.

  • Data committed by Stored Procedure can rollback ?

    Hi all !
    I have an application which uses SLSB marked as tx-Required CMT.
    However some business logic is inside Oracle Stored Procedures which issue Commit / Rollback at the end of their job.
    I wonder what happens if, in the end, the EJB rolls back the Container tx ? the data committed by the stored procedure will Rollback ?
    Thanks
    Francesco

    Francesco Marchioni wrote:
    Hi all !
    I have an application which uses SLSB marked as tx-Required CMT.
    However some business logic is inside Oracle Stored Procedures which issue Commit / Rollback at the end of their job.
    I wonder what happens if, in the end, the EJB rolls back the Container tx ? the data committed by the stored procedure will Rollback ?
    Thanks
    FrancescoHi, no. It is an unmanageable situation if WebLogic thinks it's running a
    transaction but some of the procedures being called contain transaction
    control calls. If a procedure calls a commit or rollback, everything in
    the current transaction is affected, and nothing in the future.
    For sanity's sake you must remove all transaction calls from procedures
    if they are to be called from WebLogic transactions.
    Joe

  • Stored Procedure - for update of commit problem

    HI all,
    I am getting an ORA-01002 error when rnning my stored procedure. I understnad this is because i am "commiting" when using a "For update of". But I am not sure how to commit or rollback this transaction. The procedure is below.

    oraCraft wrote:
    Do you know any way I can clean the code?Depends what's wrong with it. If you are getting the message 'Sorry, this content is not allowed' then there is a word blocked by the forum software (like 'dis&#99;ount').
    If it doesn't display at all, then it may be to do with HTML. For example, posting <tt>&lt;></tt> is tricky.

  • MDB Distributed transaction and stored procedure rollback

    Hi All,
    I am developing an asynchronous application using MDB. My application flow is as follows:
    1. From MDB onMessage i am calling another method MEthodA that
    a. calls a simple pojo1 where I am getting a Connection on XA enable datasource1 and executing Stored Procedure1 of DatabaseSchema1. In Stored Procedure1 I have some inner savpoints and rollback. No commit is inside Stored Procedure1 .
    b. In that pojo withput commiting m closing the connection and coming back in MethodA.
    c. Again from MethodA m calling an different pojo2 where I am getting a new Connection on XA enable datasource2 and executing Stored Procedure2 of DatabaseSchema1.In this pojo also without commiting m closing the connection and coming back in MethodA. In Stored Procedure2 I have some inner savpoints and rollback. No commit is inside Stored Procedure2 .
    d. Again from MethodA m calling pojo1 where I am getting a new Connection on XA enable datasource1 and executing a diffrent function of Stored Procedure1 of DatabaseSchema1.
    Now problem is:
    I have written some Savepoint and rollback inside Stored Procedure1 and inside Stored Procedure2. But these rollback is working only in inside Stored Procedure1 not in inside Stored Procedure2 in each case.
    In ejb-jar.xml transaction attributes is Required for all methods and transaction type is Container.
    Backend is Oracle 10g and init.xa has already been run on that.
    I have tested this on Oc4J and Websphere 6.0.
    I am using XaDatasource.
    Will be very obliged if any one can give a single hint of the problem as soon as possible.
    Thanks a lot

    Hi Kent;
      You have a few choices (AFAIK) with ASE...
    1)  AutoCommit = TRUE
      - must be before connect to your DB
    2) End your PB transaction first. For example
    String ls_end    =  "END TRANSACTION"
    String ls_begin  =  "BEGIN TRANSACTION"
    EXECUTE IMMEDIATE  ls_end using SQLCA;
    <call your SP>
    EXECUTE IMMEDIATE  ls_begin using SQLCA;
    3) use a 2nd Transaction Object for the SP where its AutoCommit = TRUE
    - or -
    4) In your SP ...
    Commit Transaction
    begin transaction
        insert into mytab (pub_id) values ("9999")
    commit transaction

  • Forcing a commit in a JAVA stored procedure

    Hi,
    I am using a java stored procedure which updates few tables ;only after it completes the call the commit is happening;But i wanted it to commit the tables as and when the processing happens not at the end of the call to java stored procedure because the GUI is polling for changes into the database which will be updated by the stored procedure.
    i have already set the connection.setAutoCommit(true) in the code.
    Can somebody suggest a solution ?
    Thanks in advance
    varun

    Jason,
    Works for me on Oracle 10.1.0.3 running on Red Hat Enterprise Linux AS release 3 (Taroon).
    Java code:
    import java.sql.*;
    * Oracle Java Virtual Machine (OJVM) test class.
    public class OjvmTest {
      public static void test() throws SQLException {
        Connection conn = DriverManager.getConnection("jdbc:default:connection:");
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
          ps = conn.prepareStatement("select 'TEST' from SYS.DUAL");
          rs = ps.executeQuery();
          if (rs.next()) {
            System.out.println(rs.getString(1));
        finally {
          if (rs != null) {
            try {
              rs.close();
            catch (SQLException sqlEx) {
              System.err.println("Error ignored. Failed to close result set.");
          if (ps != null) {
            try {
              ps.close();
            catch (SQLException sqlEx) {
              System.err.println("Error ignored. Failed to close statement.");
    }And my PL/SQL wrapper:
    create or replace procedure P_J_TEST as language java
    name 'OjvmTest.test()';And here is how I execute it in a SQL*Plus session:
    set serveroutput on
    exec dbms_java.set_output(2000)
    exec p_j_testGood Luck,
    Avi.

  • Rollback of JDBC Statement on error - Stored Procedure

    Hi All,
    We are using the JBDC receiver adapter for inserting the record and for that we are using the Strored Procedure and we have N number of the records for insertion in a single mapping so, we have given the occurence of the Statement 1 : unbounded as, multiple statement will be executed so, my query is if one of statement fails because of some error(Mapping error or data error) what will happen to the statement which are already executed, do they rollback? or it is not possible in case of stored procedure?
    Regards,
    Gaurav

    Hi,
    This is one of the solution but i guess there is one more issue, if we have 10 statements and third statement shows error and Stored Exception exception branch is able to catch then it will rollback the previous statement but can we able to restrict another 7 pending statement for execution or not?
    Regards,
    Gaurav

  • Do I have to add commit in SQL Server stored procedure

    In SQL Server, any statement not within a transaction is automatically commit. for example, single statement "INSERT INTO Table" is commit automatically. but in PL/SQL, you have to issue "COMMIT" after the statement. Since I have about 500 stored procedures need to be migrated from SQL Server to Oracle, Does any one has any solution for me, so I don't need to add "Commit" statement after every "Insert into Table" or "Update table" single statement.
    Thanks

    Jimmy,
    I can't think of any short cuts, only to at least commit at the end of each stored procedure as opposed to after each stmt.

  • Oracle Stored Procedure Not Accepting Comma delimited values in database

    I have a stored procedure which does the following, declares variables and assigns values retrieved from a parameter temp_table database to each variable, then it reads column headings from a master table. Using the variables assigned to each parameter from the temp_table as a filter, the rows from the MASTER TABLE are finally output by the procedure. The stored procedure works fine when dealing with single value string values passed from the parameter temp_table.
    The problem comes in when multiple values are selected and stored in the database parameter field as a comma separated string, eg. A045, A012
    So, the strored procedure has been modified to use a function to split the string into separate values: 'A045' and 'A012'. So that: A045, A012 from the database will be returned to the stored procedure variable as *('A045', 'A012')* . When testing the stored procedure using the static values *('A045', 'A012')* , data is returned.
    eg. EMPLOYEE_MASTER.CODE IN ('*A045*', '*A012*') will return results
    However, when *('A045', 'A012')* is dynamically concatenated from the function and assigned to variable:
    paramCode := split_str(paramCode) with paramCode eventually being passed: *('A045', 'A012')*
    to become:
    EMPLOYEE_MASTER.CODE IN (paramCode)
    then NO DATA is returned.
    I am stuck and don't know what the problem is. If anyone has any ideas, please feel free to help. I have included the Actual Stored Procedure below for a better understanding.
    --------------------------------------------- STORED PROCEDURE-------------------------------------------------------
    create or replace
    PROCEDURE GETEMPLOYEEDATA
    ( sesId IN VARCHAR2,
    l_cursor in out sys_refcursor
    ) is
    compCode varchar(200);
    businessUnit varchar(200);
    locCode varchar(200);
    hrDeptID varchar(200);
    glDept varchar(200);     plat varchar(200);
    deptFunc varchar(200);     empType varchar(200);
    unionCode varchar(200);     jobCode varchar(200);     
    careerLvl varchar(200);     
    empStatus varchar(200);
    zid varchar(200);
    superID varchar(200);
    counter varchar(200) ;
    token_index number;
    --v_errm VARCHAR2(256);
    BEGIN
    dbms_output.put_line('Start of BEGIN');
    /* Counter to get number of Unique Employee ID based on valid Session ID */
    select count(*) into counter from XXCCHRWEB.hr_web_sessionid_tmp where parameter_20=sesId;
    open l_cursor for SELECT counter EMPLOYEE_ID, '' LAST_NAME,
    '' FIRST_NAME from dual;
    dbms_output.put_line('OPENING FIRST CURSOR');
    /* If no valid session ID returned then error gently */
    if counter=0 then
    open l_cursor for SELECT '' EMPLOYEE_ID, '' LAST_NAME,
    '' FIRST_NAME,'' MIDDLE_NAME,'' NAME,
    '' EMPLOYEE_TYPE, '' COMPANY, '' COMPANY_DESCRIPTION,
    '' BUSINESS_UNIT, '' BUSINESS_UNIT_DESCRIPTION, '' LOCATION,
    '' LOCATION_NAME, '' HR_DEPARTMENT_ID,'' DEPARTMENT_NAME,
    '' DEPARTMENT_FUNCTION, '' PLATFORM, '' JOB_CODE,
    '' JOB_TITLE, '' BUSINESS_TITLE, '' MANAGER_LEVEL,
    '' JOB_FUNCTION, '' GL_DEPARTMENT_ID, '' GL_OP_UNIT,
    '' GL_RESPONSIBILITY_CENTER, '' HR_CHANNEL,'' FULL_OR_PART_TIME,
    '' REGULAR_OR_TEMP, '' GRADE,'' UNION_CODE,
    '' BARGAINING_UNIT, '' ANNUAL_RATE,'' HOURLY_RATE,
    '' HIRE_DATE, '' BIRTH_DATE, '' REHIRE_DATE,
    '' SERVICE_DATE, '' POSITION_NUMBER, '' REPORTS_TO,
    '' REPORTS_TO_TITLE, '' SUPERVISOR_ID, '' SUPERVISOR_NAME,
    '' LAN_ID from dual;
    dbms_output.put_line('End of counter=0');
    -- return;
    end if;
    /* read from hr_web_sessionid_tmp */
    select
    parameter_1,parameter_2, parameter_3, parameter_4,
    parameter_5,parameter_6, parameter_7, parameter_8,
    parameter_9,parameter_10, parameter_11, parameter_12,
    parameter_13, parameter_14
    into
    compCode,     businessUnit,     locCode, hrDeptID,
    glDept,     plat,     deptFunc,     empType,
    unionCode, jobCode,     careerLvl, empStatus,
    zid, superID
    from
    XXCCHRWEB.hr_web_sessionid_tmp
    where
    parameter_20= sesId;
    /*Assigning All Value to NULL superID*/
    IF superid is null then
    superID:= 'All';
    END IF;
    jobCode:='('''|| get_token(jobCode, 1)||''')'||','||'('''|| get_token(jobCode, 2)||''')';
    dbms_output.put_line('SELECTING PARAMETERS FROM TEMP TABLE WITH ROW COUNT : '||l_cursor%ROWCOUNT);
    /* read from Employee Master */
    open l_cursor for SELECT DISTINCT * FROM ( SELECT HR_EMPLOYEE_MASTER.EMPLOYEE_ID, HR_EMPLOYEE_MASTER.LAST_NAME,
    HR_EMPLOYEE_MASTER.FIRST_NAME, HR_EMPLOYEE_MASTER.MIDDLE_NAME, HR_EMPLOYEE_MASTER.NAME,
    HR_EMPLOYEE_MASTER.EMPLOYEE_TYPE, HR_EMPLOYEE_MASTER.COMPANY, HR_EMPLOYEE_MASTER.COMPANY_DESCRIPTION,
    HR_EMPLOYEE_MASTER.BUSINESS_UNIT, HR_EMPLOYEE_MASTER.BUSINESS_UNIT_DESCRIPTION, HR_EMPLOYEE_MASTER.LOCATION,
    HR_EMPLOYEE_MASTER.LOCATION_NAME, HR_EMPLOYEE_MASTER.HR_DEPARTMENT_ID, HR_EMPLOYEE_MASTER.DEPARTMENT_NAME,
    HR_EMPLOYEE_MASTER.DEPARTMENT_FUNCTION, HR_EMPLOYEE_MASTER.PLATFORM, HR_EMPLOYEE_MASTER.JOB_CODE,
    HR_EMPLOYEE_MASTER.JOB_TITLE, HR_EMPLOYEE_MASTER.BUSINESS_TITLE, HR_EMPLOYEE_MASTER.MANAGER_LEVEL,
    HR_EMPLOYEE_MASTER.JOB_FUNCTION, HR_EMPLOYEE_MASTER.GL_DEPARTMENT_ID, HR_EMPLOYEE_MASTER.GL_OP_UNIT,
    HR_EMPLOYEE_MASTER.GL_RESPONSIBILITY_CENTER, HR_EMPLOYEE_MASTER.HR_CHANNEL, HR_EMPLOYEE_MASTER.FULL_OR_PART_TIME,
    HR_EMPLOYEE_MASTER.REGULAR_OR_TEMP, HR_EMPLOYEE_MASTER.GRADE, HR_EMPLOYEE_MASTER.UNION_CODE,
    HR_EMPLOYEE_MASTER.BARGAINING_UNIT, HR_EMPLOYEE_MASTER.ANNUAL_RATE, HR_EMPLOYEE_MASTER.HOURLY_RATE,
    HR_EMPLOYEE_MASTER.HIRE_DATE, HR_EMPLOYEE_MASTER .BIRTH_DATE, HR_EMPLOYEE_MASTER.REHIRE_DATE,
    HR_EMPLOYEE_MASTER.SERVICE_DATE, HR_EMPLOYEE_MASTER.POSITION_NUMBER, HR_EMPLOYEE_MASTER.REPORTS_TO,
    HR_EMPLOYEE_MASTER.REPORTS_TO_TITLE, HR_EMPLOYEE_MASTER.SUPERVISOR_ID, HR_EMPLOYEE_MASTER.SUPERVISOR_NAME, HR_EMPLOYEE_MASTER.GENDER,
    HR_EMPLOYEE_MASTER_1.LAN_ID
    FROM
    (XXCCHR.HR_EMPLOYEE_MASTER HR_EMPLOYEE_MASTER_1
    LEFT OUTER JOIN
    XXCCHR.HR_DEPARTMENT_SECURITY HR_DEPARTMENT_SECURITY
    ON
    HR_EMPLOYEE_MASTER_1.EMPLOYEE_ID=HR_DEPARTMENT_SECURITY.EMPLOYEE_ID)
    LEFT OUTER JOIN
    XXCCHR.HR_EMPLOYEE_MASTER HR_EMPLOYEE_MASTER
    ON
    -- HR_DEPARTMENT_SECURITY.DEPARTMENT_SECURITY=HR_EMPLOYEE_MASTER.HR_DEPARTMENT_ID
    (HR_DEPARTMENT_SECURITY.DEPARTMENT_SECURITY=HR_EMPLOYEE_MASTER.HR_DEPARTMENT_ID
    or
    HR_DEPARTMENT_SECURITY.DEPARTMENT_SECURITY in ('DPALL','DPCAG009'))
    WHERE
    HR_EMPLOYEE_MASTER_1.LAN_ID=upper(zid) and
    (compCode = 'All' or HR_EMPLOYEE_MASTER.COMPANY IN compCode)
    (jobCode = 'All' or HR_EMPLOYEE_MASTER.JOB_CODE IN (jobCode) ) ) ;
    dbms_output.put_line('END OF SELECT for counter number : ' || counter ||' Cursor row count : '|| l_cursor%ROWCOUNT || ' with Job Code : ' || (jobCode));
    dbms_output.put_line('Company Code is:' || compCode);
    COMMIT;
    dbms_output.put_line('Data has been Output with session id:' || sesId);
    --delete from XXCCHRWEB.hr_web_sessionid_tmp where parameter_20= sesId;
    dbms_output.put_line('Data should have been DELETED, please check the session temp table');
    commit;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line('AN EXCEPTION HAS BEEN CAUGHT for counter number : ' || counter ||' Cursor row count : '|| l_cursor%ROWCOUNT || ' from session id : ' || sesId);
    dbms_output.put_line('The error code is ' || SQLERRM);
    END GETEMPLOYEEDATA;
    Edited by: user10384134 on Nov 4, 2009 8:37 AM

    This seems to work for me:
    define param="'ABC','XYZ'"; --- Set up a test in clause
    --- Test data
    with test as
    (select 'ABC' fld from dual union all
    select 'DEF' from dual union all
    select 'PQR' from dual union all
    select 'XYZ' from dual)
    --- Query starts here.
    select fld
    from test,
           table (sys.ODCIVarchar2List (&param)) p
    where fld = p.column_valueOr Using an actual "IN" clause:
    define param="'ABC','XYZ'";
    with test as
    (select 'ABC' fld from dual union all
    select 'DEF' from dual union all
    select 'PQR' from dual union all
    select 'XYZ' from dual
    p as
    (select column_value from table (sys.ODCIVarchar2List (&param))
    select fld
    from test
    where fld in (select column_value from p)Edited by: AlanWms on Nov 4, 2009 9:08 AM

  • I want to create stored procedure which will give output rows from "values that are passed as one parameter (comma seperated) to store procedure".

    Hello,
    I want to create stored procedure which will give output rows from "values that are passed as one parameter (comma seperated) to store procedure".
    Suppose , 
    Parameter value : person 1,person2,person3 
    table structure : 
    Project Name | officers 1 | officers 2
    here, officers 1 or officers 2 may contain names of multiple people.
    expected OUTPUT : distinct list(rows) of projects where person 1 or person 2 or person 3 is either officer1 or officer 2. 
    please explain or provide solution in detail 
    - Thanks

    Hi Visakh,
    Thanks for reply.
    But the solution you provided giving me right output only if officer 1 or officer 2 contains single value , not with comma seperated value.
    Your solution is working fine for following scenario : 
    Project 
    Officers 1
    Officers 2
    p1
    of11
    off21
    p2
    of12
    off22
    with parameter : of11,off22 : it will give expected output
    And its not working in case of :
    Project 
    Officers 1
    Officers 2
    p1
    of11,of12
    off21,off23
    p2
    of12,of13
    off22,off24
    with parameter : of11,off22 : it will not give any row in output
    I need patten matching not exact match :) 
    ok
    if thats the case use this modified logic
    CREATE PROC GetProjectDetails
    @PersonList varchar(5000)
    AS
    SELECT p.*
    FROM ProjectTable p
    INNER JOIN dbo.ParseValues(@PersonList,',')f
    ON ',' + p.[officers 1] + ',' LIKE '%,' + f.val + ',%'
    OR ',' + p.[officers 2] + ',' LIKE '%,' + f.val + ',%'
    GO
    Keep in mind that what you've done is a wrong design approach
    You should not be storing multiples values like this as comma separated list in a single column. Learn about normalization . This is in violation of 1st Normal Form
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Passing comma separated string to stored procedure

    Hi,
    There is thread with same query I created earlier and that was answered. That solution worked if I pass comma separated string containing IDs. But due to changes in the logic, I have to pass usernames instead of userIDs. I tried to modify the solution provided to use with this.
    Following the link to previous post :
    Re: Passing comma separated string to stored procedure
    ------Package-------
    TYPE refcurQID IS REF CURSOR;
    TYPE refcurPubs IS REF CURSOR;
    procedure GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID
    , TestPubs OUT Test.refcurPubs);
    ------Package-------
    ------Package Body-------
    PROCEDURE GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID, TestPubs OUT Test.refcurPubs) as
    BEGIN
    Open TestQID for
    select id from cfq where name in (p_user_name);
    Open TestPubs for
    SELECT qid FROM queues WHERE qid in(
    select id from cfq where name in (p_user_name));
    END GetAllPersonalQueue;
    ------Package Body-------
    Thanks in advance
    Aditya

    Hi,
    I modified the query as per the solution provided by isotope, after which the logic changed and I am passing username instead of userID in comma separated string.
    Following is the changes SP, which does not throw any error, but no data is returned.
    PROCEDURE GetAllPersonalQueue (p_user_name in nvarchar2, TestQID OUT Test.refcurQID, TestPubs OUT Test.refcurPubs
    ) is
    --local variable
    strFilter varchar2(100);
    BEGIN
    Open TestQID for
    select id, name from cfq where name in
    select regexp_substr(p_user_name||',','[a-z]+[0-9]+',1,level)
    from dual
    connect by level <= (select max(length(p_user_name)-length(replace(p_user_name,',')))+1
    from dual)
    Open TestPubs for
    SELECT qid FROM queues WHERE qid in(
    select id from cfq where name in
    select regexp_substr(p_user_name||',','[a-z]+[0-9]+',1,level)
    from dual
    connect by level <= (select max(length(p_user_name)-length(replace(p_user_name,',')))+1
    from dual)
    END GetAllPersonalQueue;
    Edited by: adityapawar on Feb 27, 2009 8:38 AM

  • TimesTen doesn't commit/rollback executed DMLs in procedure, so tables were locked.

    Hello, when PLSQL_TIMEOUT occured, TimesTen doesn't commit/rollback executed DMLs in procedure, so tables were locked.
    Please help. How can I solve this problem?

    Looks like I've a mistake, not PLSQL_TIMOUT, after ODBC connection timeot it seems doesn't commit/rollback.
    java.sql.SQLException: [TimesTen][TimesTen 11.2.1.8.0 CLIENT]Communication link failure. System call select() failed with OS error 110. This operation has Timed Out. Try increasing your ODBC timeout attribute or check to make sure the target TimesTen Server is running
    Also I couldn't find why locked and what locked. My procedure waiting for lock or something I dont know, so timout occured

  • Passing Comma separated input to stored procedure in IN clause

    Hi All,
    I have a query below in a stored procedure as like this
    Create PROCEDURE insertinfo
    @userids varchar(MAX)
    AS
    BEGIN
    INSERT INTO records
    (id
    ,name
    ,address1
    ,address2
    ,pincode
    SELECT
    id,
    name,
    addr1,
    addr2,
    pin,
    FROM userinfo
    WHERE userinfo.id in(@userids)
    END
    I am not using any dynamic sql. Its a simple insert into select query with multiple parameters supplied via thd @userids parameter. When i  run the query nothing is inserting in the "records" table. I have gone throught the web search have
    tried with few options but no result yet. The query works fine when i pass only a single value, but it does not work when is pass multiple values.
    Please guide on this.
    Your help is appreciated.
    Thanks,
    mds2907

    mds2907,
    CHeck this:
    --Method 1
    --Usage of TVP
    --Method 2
    --Usage of SPLIT fn()
    Create PROCEDURE insertinfo(@userids varchar(MAX))
    AS
    BEGIN
    INSERT INTO records
    (id,name,address1,address2,pincode)
    SELECT id, name,addr1,addr2, pin
    FROM userinfo
    WHERE userinfo.id in(select * from sample_split(@userids,','))
    END
    --Method3
    --Usage of Dynamic SQL
    Applicable only when the values in csv are integers
    like '1,2,3'
    Create PROCEDURE insertinfo(@userids varchar(MAX))
    AS
    BEGIN
    DECLARE @sql nvarchar(max)
    SET @sql='
    INSERT INTO records
    (id,name,address1,address2,pincode)
    SELECT id, name,addr1,addr2, pin
    FROM userinfo
    WHERE userinfo.id in('+@userids')'
    EXEC sp_executesql @sql
    END
    Sample_Split():
    CREATE FUNCTION dbo.sample_Split
    @RowData nvarchar(2000),
    @SplitOn nvarchar(5)
    RETURNS @RtnValue table
    Id int identity(1,1),
    Data nvarchar(100)
    AS
    BEGIN
    Declare @Cnt int
    Set @Cnt = 1
    While (Charindex(@SplitOn,@RowData)>0)
    Begin
    Insert Into @RtnValue (data)
    Select
    Data = ltrim(rtrim(Substring(@RowData,1,Charindex(@SplitOn,@RowData)-1)))
    Set @RowData = Substring(@RowData,Charindex(@SplitOn,@RowData)+1,len(@RowData))
    Set @Cnt = @Cnt + 1
    End
    Insert Into @RtnValue (data)
    Select Data = ltrim(rtrim(@RowData))
    Return
    END
    Usage of TVP for a scenario similar to yours is explained herE:
    http://blog.sqlauthority.com/2008/08/31/sql-server-table-valued-parameters-in-sql-server-2008/
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/0ead7ceb-3fdd-4625-aa82-1d4195f984b1/passing-multivalue-parameter-in-stored-procedure-ssrs
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

Maybe you are looking for

  • FIX: IPad turns on and off in a loop during charging, boots to home screen and reboots

    Ok, after having my ipad 2 3rd Generation for about a year, its bombed out on me,playing on it until battery drained. Didn’t think anything of it, plugged into charge thinking it would be charged by the morning. This didn’t happen. It was stuck on th

  • How do I get a refund for money taken out of my Pa...

    Last year I signed on for a Skype number, Within an hour I found out I didn't need it and tried to cancel it. Of course there is no phone number to call and no email to communicate with these people. Plus, at that time  the site said the numnber coul

  • Adobe Reader 8.0 plug ins and RAM-Heigth

    Hello, we use Adobe Acrobat Reader 8.0 to fill out Interactive Forms. Now we have the problem, that the Reader needs until a minute to start and load the interacive Form. We have two Quetstions: 1. we want to reduce the plugins of the Reader 8.0, whi

  • Thai language support on Safari 3 beta

    I just try Safari 3 beta for Windows. Its speed is impressed so far but big problem with Thai language. - Thai word break is OK. - Thai Tonal Marks and Vowels which display on the top of normal Thai character are still incorrect. They float improperl

  • Changing JList cell renderer on selection

    Hi, In our application we need to change the renderer of the selected cell of JList to JTextArea while maintaining default cell renderer for unselected cells. I tried by providing custom cell renderer (code is given below) but it does not work..:-(.