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 8972229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:10:03+00:00 2026-06-15T18:10:03+00:00

I have problem with mu procedure which insert duplicate last record in table example

  • 0

I have problem with mu procedure which insert duplicate last record in table

example when I put INSERT….. ‘AAA’ I got to rows in table ‘AAA’ and ‘AAA’

In place when I put DBMS()… in code I got tow records
I use trigger and sequence for column ID in HistoriaDismissDate but they are in good condition. I check if I dropped trigger and sequence and its the same situation

I also use viewDate but this view get mi ONE record not two

my code

CREATE OR REPLACE PROCEDURE ChangeDismissDate
IS

          v_id VARCHAR2(11);
          v_dateBhd DATE := TO_DATE('20491231','yyyymmdd');
          v_dateDismiss DATE := TO_DATE('20491231','yyyymmdd');
          v_login VARCHAR2(50);
          last_id NUMBER :=0;

        CURSOR cur IS
                select EMP_NO, LOGIN, ODEJSCIE_BHD, ODEJSCIE_OLD FROM viewDate;

        BEGIN
                       OPEN cur;
                           LOOP
                                FETCH cur INTO v_id,v_login,v_dateBhd,v_dateDismiss;
                                  DBMS_OUTPUT.put_line(v_id || ' ' || v_login || ' ' || v_dateBhd || ' ' || v_dateDismiss);
                                 UPDATE employee_tab SET DISMISS_DATE = v_dateBhd WHERE EMP_NO = v_id;
                                 COMMIT;

                                 INSERT INTO HistoriaDismissDate(CUSTOMER_ID,LOGIN, DATE_CHANGE, DATE_BHD, DATE_DISMISS)
                                 VALUES(v_id,v_login, sysdate, v_dateBhd, v_dateDismiss);
                                 COMMIT;

                           EXIT WHEN cur%NOTFOUND;
                           END LOOP;
                           CLOSE cur;


    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
        DBMS_OUTPUT.put_line (DBMS_UTILITY.format_error_stack);
    WHEN OTHERS
    THEN
        DBMS_OUTPUT.put_line (DBMS_UTILITY.format_error_stack);
    END;
/
  • 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-15T18:10:05+00:00Added an answer on June 15, 2026 at 6:10 pm

    2 tips on your original code:

    1) cursor is a very old programming technic on PL/SQL. Prefer to use FOR … LOOP construction. It’s cleaner and less error-prone! See how it works:

    CREATE OR REPLACE PROCEDURE ChangeDismissDate IS
    BEGIN
      for cur in (select EMP_NO, LOGIN, ODEJSCIE_BHD, ODEJSCIE_OLD FROM viewDate) loop
    
         DBMS_OUTPUT.put_line(cur.EMP_NO || ' ' || cur.login || ' ' || cur.ODEJSCIE_BHD || ' ' || cur.ODEJSCIE_OLD);
         UPDATE employee_tab 
            SET DISMISS_DATE = cur.ODEJSCIE_BHD
          WHERE EMP_NO = cur.EMP_NO;
    
         INSERT INTO HistoriaDismissDate
           ( CUSTOMER_ID,LOGIN, DATE_CHANGE, DATE_BHD, DATE_DISMISS )
         VALUES
           ( cur.EMP_NO, cur.LOGIN, sysdate, cur.ODEJSCIE_BHD, cur.ODEJSCIE_OLD, );
      end loop;
    end;
    /
    

    2) Never, I mean never put a commit inside your procedure. The commit should be done on the caller block or on your client-side app. When you put a commit inside your procedure, you miss the chance to rollback after running it and other procedures could not call it if they want to control the transaction flow.

    • 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 in SQL Server 2008 that will insert a record
I have a stored Procedure (Generate_Insert)which will output an Insert statement as output given
I have created a procedure which will output the INSERT script for a given
I have a stored procedure that loops through a table and it may insert
I faced an interesting problem as... I have MSSQL (2005) table A which contains
I have a trigger which executes after a record is inserted into a table.
I have a problem when debugging stored procedure using SQL server Management Studio 2008.
I have this stored procedure for Oracle: create or replace procedure bns_saa_message_get() <--- PROBLEM
I have problems filling a temporary table with the resultset from a procedure call
I'm using devexpress and i have two problems. My insert stored procedure work fine.

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.