Locking rows in a Procedure NOWAIT?

I'm trying to create a procedure with a NOWAIT statement in it, but everytime I add my NOWAIT statement it gives me Warning: Procedure created with compilation errors. When I take the statement out it works fine? Can anyone help me with this?
SET SERVEROUTPUT ON
SET VERIFY OFF
CREATE OR REPLACE PROCEDURE upd_sal
(p_jobid IN jobs.job_id%TYPE,
p_minsal IN jobs.min_salary%TYPE,
p_maxsal IN jobs.max_salary%TYPE)
IS
e_invalid_maxsal EXCEPTION;
e_rowlocked EXCEPTION;
PRAGMA EXCEPTION_INIT
(e_rowlocked, -0054);
BEGIN
UPDATE jobs
SET job_id = p_jobid, min_salary = p_minsal, max_salary = p_maxsal
WHERE job_id = p_jobid
FOR UPDATE NOWAIT;
IF SQL%ROWCOUNT = 0 THEN RAISE NO_DATA_FOUND;
ELSIF p_maxsal < p_minsal THEN
RAISE e_invalid_maxsal;
END IF;
EXCEPTION
WHEN e_invalid_maxsal THEN
DBMS_OUTPUT.PUT_LINE ('MAX SAL SHOULD BE > MIN SAL');
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE ('NO_DATA_FOUND');
WHEN e_rowlocked THEN
DBMS_OUTPUT.PUT_LINE ('Job information is currently locked, try later.');
END upd_sal;

Enter statements:
SET SERVEROUTPUT ON
CREATE OR REPLACE PROCEDURE upd_sal
(p_jobid IN jobs.job_id%TYPE,
p_minsal IN jobs.min_salary%TYPE,
p_maxsal IN jobs.max_salary%TYPE)
IS
e_invalid_maxsal EXCEPTION;
e_rowlocked EXCEPTION;
PRAGMA EXCEPTION_INIT
(e_rowlocked, -0054);
BEGIN
SELECT *
FROM jobs
WHERE job_id = p_jobid
FOR UPDATE NOWAIT;
UPDATE jobs
SET job_id = p_jobid, min_salary = p_minsal, max_salary = p_maxsal
WHERE job_id = p_jobid;
IF SQL%ROWCOUNT = 0 THEN RAISE NO_DATA_FOUND;
ELSIF p_maxsal < p_minsal THEN
RAISE e_invalid_maxsal;
END IF;
EXCEPTION
WHEN e_invalid_maxsal THEN
DBMS_OUTPUT.PUT_LINE ('MAX SAL SHOULD BE > MIN SAL');
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE ('NO_DATA_FOUND');
WHEN e_rowlocked THEN
DBMS_OUTPUT.PUT_LINE ('Job information is currently locked, try later.');
END upd_sal;
Warning: Procedure created with compilation errors.
Enter statements:
SHOW ERRORS
Errors for PROCEDURE UPD_SAL:
LINE/COL ERROR
16/1 PLS-00428: an INTO clause is expected in this SELECT statement

Similar Messages

  • Re: Transactions and Locking Rows for Update

    Dale,
    Sounds like you either need an "optimistic locking" scheme, usually
    implemented with timestamps at the database level, or a concurrency manager.
    A concurrency manager registers objects that may be of interest to multiple
    users in a central location. It takes care of notifying interested parties
    (i.e., clients,) of changes made to those objects, using a "notifier" pattern.
    The optimistic locking scheme is relatively easy to implement at the
    database level, but introduces several problems. One problem is that the
    first person to save their changes "wins" - every one else has to discard
    their changes. Also, you now have business policy effectively embedded in
    the database.
    The concurrency manager is much more flexible, and keeps the policy where
    it probably belongs. However, it is more complex, and there are some
    implications to performance when you get to the multiple-thousand-user
    range because of its event-based nature.
    Another pattern of lock management that has been implemented is a
    "key-based" lock manager that does not use events, and may be more
    effective at managing this type of concurrency for large numbers of users.
    There are too many details to go into here, but I may be able to give you
    more ideas in a separate note, if you want.
    Don
    At 04:48 PM 6/5/97 PDT, Dale "V." Georg wrote:
    I have a problem in the application I am currently working on, which it
    seems to me should be easily solvable via appropriate use of transactions
    and database locking, but I'm having trouble figuring out exactly how to
    do it. The database we are using is Oracle 7.2.
    The scenario is as follows: We have a window where the user picks an
    object from a dropdown list. Some of the object's attributes are then
    displayed in that window, and the user then has the option of editing
    those attributes, and at some point hitting the equivalent of a 'save'button
    to write the changes back to the database. So far, so good. Now
    introduce a second user. If user #1 and user #2 both happen to pull up
    the same object and start making changes to it, user #1 could write back
    to the database and then 15 seconds later user #2 could write back to the
    database, completely overlaying user #1's changes without ever knowing
    they had happened. This is not good, particularly for our application
    where editing the object causes it to progress from one state to the next,
    and multiple users trying to edit it at the same time spells disaster.
    The first thing that came to mind was to do a select with intent to update,
    i.e. 'select * from table where key = 'somevalue' with update'. This way
    the next user to try to select from the table using the same key would not
    be able to get it. This would prevent multiple users from being able to
    pull the same object up on their screens at the same time. Unfortunately,
    I can think of a number of problems with this approach.
    For one thing, the lock is only held for the duration of the transaction, so
    I would have to open a Forte transaction, do the select with intent to
    update, let the user modify the object, then when they saved it back again
    end the transaction. Since a window is driven by the event loop I can't
    think of any way to start a transaction, let the user interact with the
    window, then end the transaction, short of closing and re-opening the
    window. This would imply having a separate window specifically for
    updating the object, and then wrapping the whole of that window's event
    loop in a transaction. This would be a different interface than we wanted
    to present to the users, but it might still work if not for the next issue.
    The second problem is that we are using a pooled DBSession approach
    to connecting to the database. There is a single Oracle login account
    which none of the users know the password to, and thus the users
    simply share DBSession resources. If one user starts a transaction
    and does a select with intent to update on one DBSession, then another
    user starts a transaction and tries to do the same thing on the same
    DBSession, then the second user will get an error out of Oracle because
    there's already an open transaction on that DBSession.
    At this point, I am still tossing ideas around in my head, but after
    speaking with our Oracle/Forte admin here, we came to the conclusion
    that somebody must have had to address these issues before, so I
    thought I'd toss it out and see what came back.
    Thanks in advance for any ideas!
    Dale V. Georg
    Indus Consultancy Services [email protected]
    Mack Trucks, Inc. [email protected]
    >
    >
    >
    >
    ====================================
    Don Nelson
    Senior Consultant
    Forte Software, Inc.
    Denver, CO
    Corporate voice mail: 510-986-3810
    aka: [email protected]
    ====================================
    "I think nighttime is dark so you can imagine your fears with less
    distraction." - Calvin

    We have taken an optimistic data locking approach. Retrieved values are
    stored as initial values; changes are stored seperately. During update, key
    value(s) or the entire retieved set is used in a where criteria to validate
    that the data set is still in the initial state. This allows good decoupling
    of the data access layer. However, optimistic locking allows multiple users
    to access the same data set at the same time, but then only one can save
    changes, the rest would get an error message that the data had changed. We
    haven't had any need to use a pessimistic lock.
    Pessimistic locking usually involves some form of open session or DBMS level
    lock, which we haven't implemented for performance reasons. If we do find the
    need for a pessimistic lock, we will probably use cached data sets that are
    checked first, and returned as read-only if already in the cache.
    -DFR
    Dale V. Georg <[email protected]> on 06/05/97 03:25:02 PM
    To: Forte User Group <[email protected]> @ INTERNET
    cc: Richards* Debbie <[email protected]> @ INTERNET, Gardner*
    Steve <[email protected]> @ INTERNET
    Subject: Transactions and Locking Rows for Update
    I have a problem in the application I am currently working on, which it
    seems to me should be easily solvable via appropriate use of transactions
    and database locking, but I'm having trouble figuring out exactly how to
    do it. The database we are using is Oracle 7.2.
    The scenario is as follows: We have a window where the user picks an
    object from a dropdown list. Some of the object's attributes are then
    displayed in that window, and the user then has the option of editing
    those attributes, and at some point hitting the equivalent of a 'save' button
    to write the changes back to the database. So far, so good. Now
    introduce a second user. If user #1 and user #2 both happen to pull up
    the same object and start making changes to it, user #1 could write back
    to the database and then 15 seconds later user #2 could write back to the
    database, completely overlaying user #1's changes without ever knowing
    they had happened. This is not good, particularly for our application
    where editing the object causes it to progress from one state to the next,
    and multiple users trying to edit it at the same time spells disaster.
    The first thing that came to mind was to do a select with intent to update,
    i.e. 'select * from table where key = 'somevalue' with update'. This way
    the next user to try to select from the table using the same key would not
    be able to get it. This would prevent multiple users from being able to
    pull the same object up on their screens at the same time. Unfortunately,
    I can think of a number of problems with this approach.
    For one thing, the lock is only held for the duration of the transaction, so
    I would have to open a Forte transaction, do the select with intent to
    update, let the user modify the object, then when they saved it back again
    end the transaction. Since a window is driven by the event loop I can't
    think of any way to start a transaction, let the user interact with the
    window, then end the transaction, short of closing and re-opening the
    window. This would imply having a separate window specifically for
    updating the object, and then wrapping the whole of that window's event
    loop in a transaction. This would be a different interface than we wanted
    to present to the users, but it might still work if not for the next issue.
    The second problem is that we are using a pooled DBSession approach
    to connecting to the database. There is a single Oracle login account
    which none of the users know the password to, and thus the users
    simply share DBSession resources. If one user starts a transaction
    and does a select with intent to update on one DBSession, then another
    user starts a transaction and tries to do the same thing on the same
    DBSession, then the second user will get an error out of Oracle because
    there's already an open transaction on that DBSession.
    At this point, I am still tossing ideas around in my head, but after
    speaking with our Oracle/Forte admin here, we came to the conclusion
    that somebody must have had to address these issues before, so I
    thought I'd toss it out and see what came back.
    Thanks in advance for
    any
    ideas!
    Dale V. Georg
    Indus Consultancy Services [email protected]
    Mack Trucks, Inc. [email protected]
    ------ Message Header Follows ------
    Received: from pebble.Sagesoln.com by notes.bsginc.com
    (PostalUnion/SMTP(tm) v2.1.9c for Windows NT(tm))
    id AA-1997Jun05.162418.1771.334203; Thu, 05 Jun 1997 16:24:19 -0500
    Received: (from sync@localhost) by pebble.Sagesoln.com (8.6.10/8.6.9) id
    NAA11825 for forte-users-outgoing; Thu, 5 Jun 1997 13:47:58 -0700
    Received: (from uucp@localhost) by pebble.Sagesoln.com (8.6.10/8.6.9) id
    NAA11819 for <[email protected]>; Thu, 5 Jun 1997 13:47:56 -0700
    Received: from unknown(207.159.84.4) by pebble.sagesoln.com via smap (V1.3)
    id sma011817; Thu Jun 5 13:47:43 1997
    Received: from tes0001.macktrucks.com by relay.macktrucks.com
    via smtpd (for pebble.sagesoln.com [206.80.24.108]) with SMTP; 5 Jun
    1997 19:35:31 UT
    Received: from dale by tes0001.macktrucks.com (SMI-8.6/SMI-SVR4)
    id QAA04637; Thu, 5 Jun 1997 16:45:51 -0400
    Message-ID: <[email protected]>
    Priority: Normal
    To: Forte User Group <[email protected]>
    Cc: "Richards," Debbie <[email protected]>,
    "Gardner," Steve <[email protected]>
    MIME-Version: 1.0
    From: Dale "V." Georg <[email protected]>
    Subject: Transactions and Locking Rows for Update
    Date: Thu, 05 Jun 97 16:48:37 PDT
    Content-Type: text/plain; charset=US-ASCII; X-MAPIextension=".TXT"
    Content-Transfer-Encoding: quoted-printable
    Sender: [email protected]
    Precedence: bulk
    Reply-To: Dale "V." Georg <[email protected]>

  • Identifying locked rows

    I have an uncommited session in one window and I'm attempting to locate the locked row for Oracle 10.2.0.4. I'm unable to locate the row successfully.
    I issue the following to retrieve the information on the session locking the row. I could clearly see the session holding a DML lock.
    SQLPLUS> select dbms_rowid.rowid_create (1, ROW_WAIT_OBJ#, ROW_WAIT_FILE#, ROW_WAIT_BLOCK#, ROW_WAIT_ROW#)
    from v$session where sid=1324;
    USERNAME START_TIME STATUS SID SERIAL# SECONDS_IN_WAIT SQL_ID SQL_FULLTEXT TY
    ALEX 08/25/11 20:36:30 INACTIVE 1199 30613 49 update test set CUSTOMER_ID=1235 where CUSTOMER_ID=11111 TM
    I select the detailed information of the location of the locked row to retrieve the RowID, but I'm not getting back the expected result. I'm getting back values -1,0,0,0 for columns ROW_WAIT_OBJ#, ROW_WAIT_FILE#, ROW_WAIT_BLOCK#, and ROW_WAIT_ROW# respectively. I can't locate the row with the following:
    select row_wait_obj#, row_wait_file#, row_wait_block#, row_wait_row#
    from v$session where sid=1199;
    SQLPLUS> 2
    ROW_WAIT_OBJ# ROW_WAIT_FILE# ROW_WAIT_BLOCK# ROW_WAIT_ROW#
    -1 0 0 0
    How do I identify the locked updated row? I'm not able to in my test.
    Any help would be appreciated.
    Thanks

    user12006502,
    I am struggling to see EXACTLY what you are doing. You are showing output without showing the SQL statements that produce the output. Additionally, there may be foreign key or other constraints involved - as it stands, the best that I can do is guess, and I would prefer not to do that. For example, assume that your table name is T1 rather than TEST. What if, someone created an index like this:
    CREATE UNIQUE INDEX T1_CUSTOMER ON T1(DECODE(CUSTOMER,'KEITH','0','JOHN','0',CUSTOMER));
    {pre}
    Then, in that same session executed the following without a commit:
    INSERT INTO T1 VALUES ('JOHN',0);Now, in another session you enter the following:
    UPDATE T1 SET CUSTOMER='KEITH' WHERE CUSTOMER='RON';Your session then hangs for seemingly no reason.
    The person with the other session issues the following:
    SELECT
      SID,
      TYPE,
      ID1,
      ID2,
      LMODE,
      REQUEST,
      BLOCK
    FROM
      V$LOCK
    WHERE
      SID=(SELECT SID FROM V$MYSTAT WHERE ROWNUM=1);
    SID TY        ID1        ID2      LMODE    REQUEST      BLOCK
    222 AE        100          0          4          0          0
    222 TM      70568          0          3          0          0
    222 TX      65554       1424          6          0          1It seems that the first session has a TX lock that is blocking another session, a TM lock that is NOT blocking another session, and an AE lock that is not blocking another session.  Now, in that session, the following is executed:
    SELECT /*+ ORDERED */
      S.SID,
      S.STATUS,
      SW.EVENT,
      SW.WAIT_TIME WT,
      SW.STATE,
      SW.SECONDS_IN_WAIT S_I_W,
      S.SQL_ID,
      S.SQL_CHILD_NUMBER,
      S.ROW_WAIT_OBJ# OBJ#,
      S.ROW_WAIT_FILE# FILE#,
      S.ROW_WAIT_BLOCK# BLOCK#,
      S.ROW_WAIT_ROW# ROW#,
      SW.P1,
      SW.P2,
      SW.P3
    FROM
      V$SESSION_WAIT SW,
      V$SESSION S
    WHERE
      S.USERNAME IS NOT NULL
      AND SW.SID=S.SID
      AND SW.EVENT NOT LIKE '%SQL*Net%'
      AND SW.EVENT NOT IN ('Streams AQ: waiting for messages in the queue',
      'wait for unread message on broadcast channel');
    SID STATUS   EVENT                                 WT STATE                    S_I_W SQL_ID        SQL_CHILD_NUMBER       OBJ#      FILE#     BLOCK#       ROW#         P1         P2         P3
    223 ACTIVE   enq: TX - row lock contention          0 WAITING                    146 9gag614u0kvyx                0         -1          0          0          0 1415053316      65554       1424Notice in the above the -1 for the OBJ#.  You must provide the DDL and the DML for people to help you, otherwise you are forcing people to guess what you have done to set up the test case.
    At the minimum, provide the DDL to recreate the table (and any indexes).  If you do not have the DML, you can use the following technique to retrieve it:
    SET PAGESIZE 0
    SET LONG 90000
    SET LINESIZE 200
    COLUMN OBJECT_DEF FORMAT A200
    SPOOL 'GETMETA.SQL'
    SELECT
      DBMS_METADATA.GET_DDL('TABLE',TABLE_NAME,OWNER) OBJECT_DEF
    FROM
      DBA_TABLES
    WHERE
      TABLE_NAME IN ('T1');When I executed the above for my test table T1, I saw the following:
      CREATE TABLE "TESTUSER"."T1"
       (    "CUSTOMER" VARCHAR2(6),
            "CUSTOMER_ID" NUMBER
       ) SEGMENT CREATION IMMEDIATE
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "USER_DATA"That said, you could also have a trigger on the table that performs some action on an UPDATE, which could also cause problems.
    Here is an example of what a full test case would look like:
    DROP TABLE T1 PURGE;
    CREATE TABLE T1 (
      CUSTOMER VARCHAR2(6),
      CUSTOMER_ID NUMBER);
    INSERT INTO T1 VALUES('BETTY',1235);
    INSERT INTO T1 VALUES('RON',0);
    INSERT INTO T1 VALUES('BLAKE',0);
    COMMIT;In session 1 you execute the following and receive confirmation that the update was successful:
    UPDATE T1 SET CUSTOMER='KEITH' WHERE CUSTOMER='RON';
    1 row updated.You check V$LOCK for this session and notice that the session has 3 locks, none of which are blocking:
    SELECT
      SID,
      TYPE,
      ID1,
      ID2,
      LMODE,
      REQUEST,
      BLOCK
    FROM
      V$LOCK
    WHERE
      SID=(SELECT SID FROM V$MYSTAT WHERE ROWNUM=1);
    SID TY        ID1        ID2      LMODE    REQUEST      BLOCK
    223 AE        100          0          4          0          0
    223 TM      70568          0          3          0          0
    223 TX     262153       1493          6          0          0In another session, you attempt to drop the table and are greeted with an error:
    DROP TABLE T1 PURGE;
    DROP TABLE T1 PURGE
    ERROR at line 1:
    ORA-00054: resource busy and acquire with NOWAIT specified or timeout expiredSo, you try the update statement - the same one performed in the first session:
    UPDATE T1 SET CUSTOMER='KEITH' WHERE CUSTOMER='RON';The session hangs.
    Back in the first session, you check the locks for the first session:
    SELECT
      SID,
      TYPE,
      ID1,
      ID2,
      LMODE,
      REQUEST,
      BLOCK
    FROM
      V$LOCK
    WHERE
      SID=(SELECT SID FROM V$MYSTAT WHERE ROWNUM=1);
    SID TY        ID1        ID2      LMODE    REQUEST      BLOCK
    223 AE        100          0          4          0          0
    223 TM      70568          0          3          0          0
    223 TX     262153       1493          6          0          1Note the blocking lock.
    Let's check the waits:
    SELECT /*+ ORDERED */
      S.SID,
      S.STATUS,
      SW.EVENT,
      SW.WAIT_TIME WT,
      SW.STATE,
      SW.SECONDS_IN_WAIT S_I_W,
      S.SQL_ID,
      S.SQL_CHILD_NUMBER,
      S.ROW_WAIT_OBJ# OBJ#,
      S.ROW_WAIT_FILE# FILE#,
      S.ROW_WAIT_BLOCK# BLOCK#,
      S.ROW_WAIT_ROW# ROW#,
      SW.P1,
      SW.P2,
      SW.P3
    FROM
      V$SESSION_WAIT SW,
      V$SESSION S
    WHERE
      S.USERNAME IS NOT NULL
      AND SW.SID=S.SID
      AND SW.EVENT NOT LIKE '%SQL*Net%'
      AND SW.EVENT NOT IN ('Streams AQ: waiting for messages in the queue',
      'wait for unread message on broadcast channel');
    SID STATUS   EVENT                                 WT STATE                    S_I_W SQL_ID        SQL_CHILD_NUMBER       OBJ#      FILE#     BLOCK#       ROW#         P1         P2         P3
    222 ACTIVE   enq: TX - row lock contention          0 WAITING                    333 9gag614u0kvyx                1      70568          4      42601          1 1415053318     262153       1493Notice that the second session is waiting in an enqueue, the STATE is WAITING and the OBJ#, FILE#, BLOCK#, and ROW# all contain values.
    Please provide a full test case, otherwise people may provide to you an answer that has nothing to do with the question that you are asking.
    Notice in the above that the spaces were retained in my posted output from the SQL statements.  To do the same, place the following tag before and after your code sections (do not include the space before and after the brackets):
    { code }
    Charles Hooper
    Co-author of "Expert Oracle Practices: Oracle Database Administration from the Oak Table"
    http://hoopercharles.wordpress.com/
    IT Manager/Oracle DBA
    K&M Machine-Fabricating, Inc.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How skip on locked rows

    hello
    please guide me
    sqlserver select as READPAST hint that cause skip on locked rows that another transaction locked it
    For example, assume table T1 contains a single integer column with the values of 1, 2, 3, 4, 5. If transaction A changes the value of 3 to 8 but has not yet committed, a SELECT * FROM T1 (READPAST) yields values 1, 2, 4, 5
    when i use oracle. how i can skip rows that another transaction locked it when i use "for update" in select statement?
    thanks

    There is some undocumented syntax "FOR UPDATE SKIP LOCKED" that does exactly this. Problem is that it is not supported and Oracle is free to remove or change the functionality.
    The other option is to program it like this:
    (pseudocode, not tested)
    declare
      l_pk_array is table of t1.<pk column>%type index by pls_integer;
      cursor c is select <pk column> from t1;
    begin
      open c;
      loop
        fetch c bulk collect into l_pk_array limit 100
        for i in 1..l_pk_array.count
        loop
          declare
            e_row_locked exception;
            pragma exception_init (e_row_locked,-54);
            <other arrays>
          begin
            select <other columns>
              into <other arrays>
              from t1
             where t1.pk_column = l_pk_array(i)
                   for update nowait
            <your code>
          exception
          when no_data_found then
            null;
          when e_row_locked then
            null;
          end;
        end loop
        <maybe a forall statement here>
      end loop
      close c;
    end;Regards,
    Rob.

  • How can I retain updates made in multiple locked rows and override scope rollback defined for row locking purposes ?

    I have a set of stored procedures in SQL
    One of which is called to build a list of entries to submit to a web service
    Those queries are called by identical processes running on different machines, so to prevent duplicate processing we lock rows that are presently being processed.
    BEGIN
    TRAN TRAN1
    SELECT t.[TransactionId],t.[ContentIdentifier]
    FROM [dbo].[Transactions]
    t WITH(READPAST,
    UPDLOCK,
    ROWLOCK)where
    (t.Quarantined
    <> 1)
    COMMIT
    A Second stored procedure simply updates the Quarantined flag.
    My C# code
    TransactionOptions transactionOptions
    =
    new
    TransactionOptions();
    transactionOptions.IsolationLevel
    =
    IsolationLevel.ReadCommitted;
    transactionOptions.Timeout
    =
    new
    TimeSpan(0,
    10,
    0);
    using (TransactionScope
    scopeMain =
    new
    TransactionScope(TransactionScopeOption.Required,
    transactionOptions))
    TransactionsReady = DAL.GetFilesForProcessingByServiceType(i);
    using (TransactionScope
    scopeSuppress =
    new
    TransactionScope(TransactionScopeOption.Suppress,
    transactionOptions))
    foreach (var
    Transaction in TransactionsReady)
    { try
    returnData = proxy.Submit(stuffToProcess);
    using (var
    scopeInner =
    new System.Transactions.TransactionScope())
    DAL.QuarantineTransaction(Transaction.TransactionId);
    scopeInner.Complete();
    scopeSuppress.Complete();
    scopeMain.Complete();
    The problem I experience is that if I have the Transaction Scope scopeSuppress uncommented, then the QuarantineTransaction stored procedure deadlocks.
    However if I comment out the ScopeSuppress, while the process then works, if it is interrupted mid-way, then all of the Quarantine flags get reset, meaning the entire batch of items will get re-submitted next
    pass (this is not desirable).
    What I actually want to occur, is for the Quarantine flag to be retained on all processed records so that even if the program terminates unexpectedly, processed items remain processed but all the row locks are
    released.
    Does anyone know of a way to achieve this ?

    The hour is late where I sit, so I don't have the time to dive into this in detail.
    However, if memory serves, TransactionScopes defaults to Serializable isolation level, which may explain the deadlocks you are getting.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • I want to unlock my iphone 4s which is locked with orange france , and now i'm in Algeria and we dont have orange here so what can i do???? help please and thank u

    i want to unlock my iphone 4s which is locked with orange france , and now i'm in Algeria and we dont have orange here so what can i do???? and also , my mic doesnt work with siri and dictaphone, it just work with the camera, help me plz and thank u.

    You will have to contact orange to get your phone unlock.  ONly the carrier that the phone is locked to can unlock the phone.

  • Deleting a row from a Procedure

    Hi All
    Can one of you tell me how to delete a row from a Procedure
    It is created with
    CREATE OR REPLACE PROCEDURE report.NAMEOFTABLE
    (nPutId IN Report.ID%TYPE,
    cArea IN Report.Area%TYPE,
    cSubject IN Report.Subject%TYPE,
    nUserId IN Report.EngineerID%TYPE,
    cDesc IN Report.Description%TYPE,
    cSide IN Report.SideEffects%TYPE,
    cImpact IN Report.Impact%TYPE,
    cNotes IN Report.Notes%TYPE,
    nValid IN Report.Valid%TYPE) AS
    -- Add or update Report
    -- If nId < 1 then a record is added, otherwise updated.
    BEGIN
    IF nId < 1 THEN
    INSERT INTO Report
    (Area, Subject, EngineerID,
    Description, SideEffects, Impact,
    ReportNotes, Valid)
    VALUES
    (cArea, cSubject, nUserId, cDesc, cSide, cImpact, cNotes, nValid);
    ELSE
    UPDATE Report
    SET ReportArea = cArea,
    ReportSubject = cSubject,
    ReportDescription = cDesc,
    ReportSideEffects = cSide,
    ReportImpact = cImpact,
    ReportNotes = cNotes,
    ReportValid = nValid
    WHERE ReportID = nPutId;
    END IF;
    COMMIT;
    END;
    CREATE SYNONYM Admin.NAMEOFTABLE
    Report.NAMEOFTABLE;
    But I need to make 1 field of the impact and the sideEffect called the ImpactEffect
    So how do i delete the field of Side effect and change the name of the Impact field.
    Sould I make a new Procedure?

    If you want to delete a row, you'd need a DELETE statement. It is not obvious to me, though, that you really want to delete a row. It sounds like you're trying to update a row, and there is an UPDATE statement in the procedure. Unfortunately, I'm very unsure exactly what you're trying to accomplish and how this procedure relates to that goal. Perhaps if you could post the starting state of the row, the procedure call you're trying to make, and the end state of that row, things might be much clearer.
    As an aside, do you really have a schema and a table named REPORT? That seems rather confusing.
    Justin

  • How to find rowid of locked rows?

    Hello All,
    I have the "before update trigger" I want to know the rowid of all the locked row before update so that I dont try to update the same row which is locked by some other user. In Ask Tom forum I have seen how to know the rowid of locked row, but it will work only when Some body got hanged in that Perticular row while trying to update it. I dont want the User to get hanged, for that I want to user before update trigger. Help me.

    I believe this is a duplicate of another question in this forum
    How to find out rowid of locked row
    which I answered.
    Justin

  • I have an ipod touch 8gb that is disabled. on the screen it reads ipod disabled connect to itunes. But when i connect it to itunes, it says that it cant work with the ipod because it is locked with a passcode. what now?

    I have an ipod touch 8gb that is disabled. on the screen it reads ipod disabled connect to itunes. But when i connect it to itunes, it says that it cant work with the ipod because it is locked with a passcode. what now?

    Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen
    If recovery mode does not work try DFU mode.
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    The previous responses did not say how to place in recovery mode or DFU mode

  • How to find the LOCKED ROWS in a table?

    Not locked objects, but for a table the locked rows.

    Check below links :
    http://www.jlcomp.demon.co.uk/faq/locked_rows.html
    How to find the locked row.
    who are waiting for same record?
    HTH
    Girish Sharma

  • JBO-28004: Could not lock row in control table for table null

    hello.
    we have deployed two application on a server.
    both have code like this:
         select = "SELECT * from tab";
    vo = e.getDBTransaction().createViewObjectFromQueryStmt(select);
                        vo.executeQuery();
                        RowSet rs = vo.getRowSet();
                        if(rs != null)
                             Row lastRow = vo.getRowSet().last();
    the last line throws sometimes an exception (.last()).
    JBO-28004: Could not lock row in control table for table null
    at oracle.jbo.PCollException.throwException(PCollException.java:34)
    at oracle.jbo.pcoll.OraclePersistManager.commit(OraclePersistManager.java:229)
    at oracle.jbo.pcoll.OraclePersistManager.dropTable(OraclePersistManager.java:499)
    at oracle.jbo.pcoll.OraclePersistManager.createTable(OraclePersistManager.java:692)
    at oracle.jbo.pcoll.OraclePersistManager.insert(OraclePersistManager.java:1492)
    at oracle.jbo.pcoll.PCollNode.passivateElem(PCollNode.java:542)
    at oracle.jbo.pcoll.PCollNode.passivate(PCollNode.java:657)
    at oracle.jbo.pcoll.PCollection.passivateLRULeafNode(PCollection.java:351)
    at oracle.jbo.pcoll.PCollection.checkActiveLeafLimit(PCollection.java:404)
    at oracle.jbo.pcoll.PCollection.nodeRecentlyUsed(PCollection.java:252)
    at oracle.jbo.pcoll.PCollNode.<init>(PCollNode.java:73)
    at oracle.jbo.pcoll.PCollNode.checkForSplit(PCollNode.java:1553)
    at oracle.jbo.pcoll.PCollNode.addObject(PCollNode.java:1622)
    at oracle.jbo.pcoll.PCollNode.addObject(PCollNode.java:1610)
    at oracle.jbo.pcoll.PCollection.addElement(PCollection.java:753)
    at oracle.jbo.server.QueryCollection.fetch(QueryCollection.java:1247)
    at oracle.jbo.server.QueryCollection.getRowCount(QueryCollection.java:1065)
    at oracle.jbo.server.ViewRowSetImpl.getRowCount(ViewRowSetImpl.java:1444)
    at oracle.jbo.server.ViewRowSetIteratorImpl.last(ViewRowSetIteratorImpl.java:1183)
    at oracle.jbo.server.ViewRowSetImpl.last(ViewRowSetImpl.java:2246)
    at oracle.jbo.server.ViewObjectImpl.last(ViewObjectImpl.java:4352)
    at com.omv.emis.extemis.bc.EmsFreigabeImpl.checkFullMonth(EmsFreigabeImpl.java:327)
    at com.omv.emis.extemis.bc.EmsFreigabeImpl.doDML(EmsFreigabeImpl.java:293)
    at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:3410)
    at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:2274)
    at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:2216)
    at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:1511)
    at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:1677)
    at EmsFreigabeView1_BrowseEdit._jspService(_EmsFreigabeView1__BrowseEdit.java:134)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
    at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:283)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:563)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:309)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
    this exception does not occur every time just sometimes.
    (no other user/application uses the specific table, so there is no other lock)
    maybe someone knows an error source.
    thx in advance.

    Gina:
    Could you run you app with diagnostic turned on?
    If you're launching your middle tier from command prompt, you should invoke java as
    java -Djbo.debugoutput=console ...
    If you're launching your middle tier from w/i JDev..
    1. Select the project.
    2. Do right mouse click and select "Project Settings..."
    3. On the Settings dialog, select Configurations/Runner.
    4. In the righthand side pane, you should see a textbox for "Java
    Options". Please add the following JVM switch:
    -Djbo.debugoutput=console
    Then, rerun. The run command should include
    -Djbo.debugoutput=console as in
    "D:\JDev9i\jdk\bin\javaw.exe" -Djbo.debugoutput=console -classpath ...
    Then, you should see a lot of diagnostic messages. It will also give you complete stack trace including that of the detail exception.
    When you get the exception diagnostic output, please post that to this thread.
    Thanks.
    Sung

  • HT201441 I bought an iphone 4*at*t from a craigslist ad. The seller did not restore the phone and when I tried to do it manually it locked the phone and is now asking for the login info. I contacted the seller and he is not responding. What do i do?

    The seller did not restore the phone and when I tried to do it manually it locked the phone and is now asking for the login info in order to do anything with the phone. I contacted the seller and he is not responding. What do i do?

    he knows his ID , if he did all whats in the link he can get his password back ?
    how can i make him call applecare ? is there a way to speak to them from jordan ??
    i have been trying to reach any1 in apple so they can communicate and help my friend (us) to make him remember it .
    am not asking for the password or trying to get into the phone without using it , and i can take my money back though i need to help my friend as well since now he cant use it as well.
    thanks kil

  • I probably misclicked when I activated the security lock on the iPhone and now I can not figure out what password I entered. Moreover, I have patches and funky looking phone so I can not restore iphine pres itunes. Please advice.

    I probably misclicked when I activated the security lock on the iPhone and now I can not figure out what password I entered. Moreover, I have patches and funky looking phone so I can not restore iphine pres itunes. Please advice.

    Your only recourse is to force it into DFU mode:
    Turn your phone off and connect your cable to the computer, but not the device just yet. Start up iTunes. Now, hold down the home button on your phone and plug it in to the cable - don't let go of the button until iTunes tells you it's detected a phone in recovery mode. Now you can restore to factory settings.

  • Who locks row in IOT?

    Hi,
    I have an index organized table (IOT) where I need to find the locking session for as certain row.
    I found usefull information on this website: http://www.orafaq.com/node/854
    But for some reason I annot use <tt>DBMS_ROWID.rowid_create</tt> to calculate rowid's in the IOT:    SQL> SELECT sid
          2    FROM v$lock
          3        JOIN dba_objects dbob
          4          ON (object_id = id1)
          5        JOIN v$session vds
          6          USING (sid)
          7          WHERE DBOB.OBJECT_NAME = 'PAC_ZUO_PARA_HEAD_TOP_IOT';
               SID
              2058
        SQL> SELECT to_char(DBMS_ROWID.rowid_create (1
          2                                ,  vds.row_wait_obj#
          3                                ,  vds.row_wait_file#
          4                                ,  vds.row_wait_block#
          5                                ,  vds.row_wait_row#
          6                                 ))
          7    FROM v$session vds
          8   WHERE     sid = 2058;
        SELECT to_char(DBMS_ROWID.rowid_create (1
        ERROR at line 1:
        ORA-01410: invalid ROWID
        ORA-06512: at "SYS.DBMS_ROWID", line 38
        SQL> SELECT 'rid '||rowid , zpht.*
          2    FROM  pac_zuo_para_head_top_iot zpht
          3   WHERE ZPHT.PARA_ID =   1845828150001; -- row locked by the other session
        'RID'||ROWID                                     PARA_ID TOP_PARA_ID
        rid *BAOSoyoIxwJVOx0QAQL+                     1.8458E+12  2.0797E+12
        SQL>How do I match the locked rows with the one I'm locking for?
    DB is 10.2.0.5 soon upgrading to 11.2.*
    *[edit]* waiting for a blocking lock and looking from a third session is not an option.
    bye
    TPD
    Edited by: T.PD on 01.03.2012 14:44

    I'm not sure how to answer your question, but IOTs don't use "regular" ROWIDs. They use "Logical" or "Universal" ROWIDs which DBMS_ROWID does not support.
    DBMS_ROWID is not to be used with universal ROWIDs (UROWIDs).Source: http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/d_rowid.htm#CIHJBJHG

  • How To find rowid of Locked row.

    Hello,
    can somebody tell me the "select statement", how to find the rowid of a locked row, which is locked by "select for update" and also the rowid of a row which is going to be updated by "update statement".

    check out v$session and the following columns.
    It is documented here
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/ch3171.htm#1122127
    ROW_WAIT_OBJ#
    NUMBER
    Object ID for the table containing the ROWID specified in ROW_WAIT_ROW#
    ROW_WAIT_FILE#
    NUMBER
    Identifier for the datafile containing the ROWID specified in ROW_WAIT_ROW#. This column is valid only if the session is currently waiting for another transaction to commit and the value of ROW_WAIT_OBJ# is not -1.
    ROW_WAIT_BLOCK#
    NUMBER
    Identifier for the block containing the ROWID specified in ROW_WAIT_ROW#. This column is valid only if the session is currently waiting for another transaction to commit and the value of ROW_WAIT_OBJ# is not -1.
    ROW_WAIT_ROW#
    NUMBER
    The current ROWID being locked. This column is valid only if the session is currently waiting for another transaction to commit and the value of ROW_WAIT_OBJ# is not -1.

Maybe you are looking for

  • Wait Events "log file parallel write" / "log file sync" during CREATE INDEX

    Hello guys, at my current project i am performing some performance tests for oracle data guard. The question is "How does a LGWR SYNC transfer influences the system performance?" To get some performance values, that i can compare i just built up a no

  • Migrating from SJSAS/Glassfish to JDeveloper 10.1.3/AS 10.1.3

    Hi, I have recently completed release 2 of a web application developed using Netbeans, Maven, JDK 1.5, SJSAS 9.1 Ur 2, JPA 1.0, some EJB 3.0, JSF 1.2 (Trinidad) and JAXB 2.x. I have been made a part of another team in our organisation that makes use

  • All-in-one C6180 printer

    Printer does not see inks in the unit; always asking to change three inks cartridges otherwise to check to use only black ink or it does not print.  This happens even when all 6 cartridges are newly installed.  Please HELP! Nelda J.

  • Location device- Ipad offline ?

    I have used the locate my device successfully for my ipad and iphone up until IOS5 . It works perfectly for the iphone but it now states the IPAD is offline when its not . I have looked at settings and tried over the last few days thinking it was a g

  • Items in project report(query) are listed under the "not assigned" (column)

    Hi All, Items in project reports (query) are listed under the "not assigned" (column name) Why it is so ? Start query : project reports & ask for period April 2008 (Period from/to). . You will see items listed under  Not assigned WBS Element (column