Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7983109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:51:49+00:00 2026-06-04T10:51:49+00:00

This procedure updates a table where I keep track of a (very-basic) historical work

  • 0

This procedure updates a table where I keep track of a (very-basic) historical work done. The problem is that I can’t modify it or compile it anymore. I don’t know if I’m making a mistake in the procedure and an infinite-loop is going on. My DBA has checked the procedure and everything’s seems right, but I still can’t change it, use it.

My bet is that when I’m trying to catch the exception and I use the EXCEPTION WHEN OTHERS THEN NULL the loop gets stuck.

Any advise?

Cheers

create or replace
PROCEDURE DOACTUALIZARHISTORIALEM 
(
  QUSUARIO IN VARCHAR2  
, QARCHIVO IN VARCHAR2  
, QANIOFISCAL IN VARCHAR2
, QFECHAPROCESAMIENTO IN DATE
) AS 

  cursorEstatus SYS_REFCURSOR;

  sqlQueryA VARCHAR2(200);
  sqlQueryB VARCHAR2(200);
  idArchivo INTEGER;

  idPrograma VARCHAR2(10);
  idComponente VARCHAR2(10);

  sumaSolicitado DECIMAL;
  sumaAprobado DECIMAL;
  sumaPagado DECIMAL;

BEGIN

  idArchivo := getidarchivo(qarchivo,getidusuario(qusuario),qaniofiscal);

  sqlQueryA := 'SELECT programa, componente'||
                ' FROM '||qusuario||
              ' WHERE id_archivo = :1';

  OPEN cursorEstatus FOR sqlQueryA USING idArchivo;
  LOOP
    FETCH cursorEstatus INTO idPrograma, idComponente;
    EXIT WHEN cursorEstatus%NOTFOUND;

    BEGIN  
      sqlQueryB := 'SELECT sum(monto_federal) '||
                    ' FROM '||qusuario||
                   ' WHERE programa = :1'||
                    ' AND componente = :2'||
                    ' AND estatus_monto = 1'||
                    ' AND status = 1';
      EXECUTE IMMEDIATE sqlQueryB
        INTO sumaSolicitado
        USING idPrograma, idComponente;

        INSERT INTO src_historialem VALUES (idArchivo,
                                            qfechaprocesamiento,
                                            idPrograma,
                                            idComponente,
                                            1,
                                            sumaSolicitado);
        COMMIT;
        EXCEPTION
          WHEN OTHERS THEN NULL;
      END;

    BEGIN
      sqlQueryB := 'SELECT sum(monto_federal) '||
                    ' FROM '||qusuario||
                   ' WHERE programa = :1'||
                    ' AND componente = :2'||
                    ' AND estatus_monto = 2'||
                    ' AND status = 1';
      EXECUTE IMMEDIATE sqlQueryB
        INTO sumaAprobado
        USING idPrograma, idComponente;


        INSERT INTO src_historialem VALUES (idArchivo,
                                            qfechaprocesamiento,
                                            idPrograma,
                                            idComponente,
                                            2,
                                            sumaSolicitado);
        COMMIT;
        EXCEPTION
          WHEN OTHERS THEN NULL;
      END;

    BEGIN
      sqlQueryB := 'SELECT sum(monto_federal) '||
                    ' FROM '||qusuario||
                   ' WHERE programa = :1'||
                    ' AND componente = :2'||
                    ' AND estatus_monto = 3'||
                    ' AND status = 1';
      EXECUTE IMMEDIATE sqlQueryB
        INTO sumaPagado
        USING idPrograma, idComponente;


        INSERT INTO src_historialem VALUES (idArchivo,
                                            qfechaprocesamiento,
                                            idPrograma,
                                            idComponente,
                                            3,
                                            sumaSolicitado);
        COMMIT;
        EXCEPTION
          WHEN OTHERS THEN NULL;
      END;
  END LOOP;

  CLOSE cursorEstatus;
END DOACTUALIZARHISTORIALEM;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:51:51+00:00Added an answer on June 4, 2026 at 10:51 am

    1) Open a SQL*Plus session (session A). Get that session’s SID and SERIAL#. Write those numbers down.

    SELECT sid, serial#
      FROM v$session
     WHERE sid = (select distinct sid from v$mystat);
    

    2) Open a second SQL*Plus session (session B) connecting to the same database as A.

    3) In session A, try to compile the code

    4) While that is running, in session B, run the query

    SELECT blocking_session_status,
           blocking_instance,
           blocking_session
      FROM v$session
     WHERE sid     = <<sid from step 1>>
       AND serial# = <<serial# from step 1>>
    

    That will show you the SID of the session that holds the lock on the procedure. Alternately, dba_waiters should have similar information.

    SELECT waiting_session,
           holding_session,
           lock_type,
           mode_held,
           mode_requested
      FROM dba_waiters
     WHERE waiting_session = <<sid from step 1>>
    

    5) Once you’ve determined what session holds the lock, you can ask the DBA to kill the session.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure that updates a table using linq, eg: (this is
I want to call this procedure that sends one value that can be NULL
I have a stored procedure that updates data in a table for a specific
I have this procedure that executes another procedure passed by a parameter and its
I'm writing a stored procedure that should sync a table from our production environment
I'm using entity framework 4. I have a stored procedure that just updates one
I have this sql update statement which updates a remote table. Is there any
I want to create a stored procedure that takes the name of a table
Does this procedure accurately show the space used in a db? I'm doubting the
I am doing this : procedure TForm1.Button1Click(Sender: TObject); var dtStart: TDateTime; I: Integer; begin

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.