Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting error Lock exception: ORA-20104: Document is already locked for this session

3611866Mar 12 2018 — edited Mar 12 2018

Hi,

I am getting the below error during tht execution of procedure in package.

Lock exception: ORA-20104: Document is already locked for this session. DocumentId = 9135476466313766885, SessionId = ORA-06512: at "MNIL_PROD.PKGRECONCILIATION", line 5720 ORA-06512: at line 1 SQL: begin pkgreconciliation.checkLockForDocument(:1 ,:2 ); end; ^-- error at this line -- ORA-20104: Document is already locked for this session. DocumentId = 9135476466313766885, SessionId = Binds: (9135476466313766885,null)

When i checked separately for this object then its showing no document lock.

Please let me know if anybody come across this type of issue and what will be possible solution.

Regards,

Rajiv

This is below the procedure :-

procedure checkLockForDocument(doc_id number, session_id varchar2)

is

  v varchar2(500);

  vs arrayofstrings;

  modif_session_id varchar2(500);

begin

   --1. Check if (document_id, session_id) record exists

   if (isFeatureSupported(doc_id, PARALLEL_FEATURE) = 0) then

--parallel feature is not supported:

modif_session_id := null;

   else

        modif_session_id := session_id;

   end if;

   begin

    select locked_object bulk collect into vs from nc_rec_locks

      where object_id = doc_id

        and (locked_object is null and modif_session_id is not null

        or locked_object is not null and modif_session_id is null)

        and lock_type = LOCK_TYPE_DOC_SESSION

      for update nowait;

    exception

     when NO_DATA_FOUND then null;

     when resource_busy then

           raise_application_error(-20104, 'Document is already locked for this session. DocumentId = '||to_char(doc_id)||', SessionId = '||session_id);

   end;

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 9 2018
Added on Mar 12 2018
11 comments
1,077 views