Home » SQL & PL/SQL » SQL & PL/SQL » Stored Proc not inserting all records
Stored Proc not inserting all records [message #644715] Sun, 15 November 2015 23:30 Go to next message
kr1347
Messages: 16
Registered: September 2014
Junior Member
Hi Below is the stored procedure i have written .The Cursor c_src query has about 437 records .. I wanted for each record in cursor c_src it has to loop through cursor r_dsp and insert into table

But it is actually inserting only one record Sad

Please help me out

Code is here



[EDITED by LF: applied [spoiler] tags]

[Updated on: Tue, 17 November 2015 01:27] by Moderator

Report message to a moderator

Re: Stored Proc not inserting all records [message #644716 is a reply to message #644715] Mon, 16 November 2015 00:03 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

1/ The first error is there
Quote:
WHEN OTHERS THEN
p_sqlcode := SQLCODE;
p_sqlerrm := SQLERRM;
p_error := o_SecurityID||o_CouponDate


2/ The second error is there
Quote:
COMMIT;
...
END LOOP;


3/ The third error iq to do in PL/SQL something you can do in SQL

Re: Stored Proc not inserting all records [message #644728 is a reply to message #644716] Mon, 16 November 2015 05:12 Go to previous messageGo to next message
kr1347
Messages: 16
Registered: September 2014
Junior Member
Hi Michel,

Thanks for your reply . Can you please correct me the stored proc .. Not sure what changes needs to be done
Re: Stored Proc not inserting all records [message #644743 is a reply to message #644728] Mon, 16 November 2015 08:18 Go to previous messageGo to next message
kr1347
Messages: 16
Registered: September 2014
Junior Member
Can some one please help me
Re: Stored Proc not inserting all records [message #644745 is a reply to message #644743] Mon, 16 November 2015 08:27 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

You have to do my point 3.

Re: Stored Proc not inserting all records [message #644747 is a reply to message #644745] Mon, 16 November 2015 08:50 Go to previous messageGo to next message
kr1347
Messages: 16
Registered: September 2014
Junior Member
How is it possible to do in sql as each record it has too loop and generate multiple records based on condition
Re: Stored Proc not inserting all records [message #644748 is a reply to message #644745] Mon, 16 November 2015 08:51 Go to previous messageGo to next message
sss111ind
Messages: 634
Registered: April 2012
Location: India
Senior Member

Please print it using DBMS_OUPUT whether the inner loop is opening as many times as the outer loop is looping.Exactly 437 times both cursor should open.
If it is successful the check the while and if-else part.
Re: Stored Proc not inserting all records [message #644754 is a reply to message #644747] Mon, 16 November 2015 10:18 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
kr1347 wrote on Mon, 16 November 2015 15:50
How is it possible to do in sql as each record it has too loop and generate multiple records based on condition


It is possible.
Not e that "loop" is not SQL, SQL works on sets. Your issue has been wrongly analyze and so the code is bad.

Re: Stored Proc not inserting all records [message #644755 is a reply to message #644754] Mon, 16 November 2015 11:08 Go to previous messageGo to next message
kr1347
Messages: 16
Registered: September 2014
Junior Member
I am new to this stored proc ..trying to fix it
Re: Stored Proc not inserting all records [message #644756 is a reply to message #644755] Mon, 16 November 2015 11:22 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Forget the proc, back to the specifications and fulfill them without the proc.

Re: Stored Proc not inserting all records [message #644757 is a reply to message #644755] Mon, 16 November 2015 15:08 Go to previous message
flyboy
Messages: 1903
Registered: November 2006
Senior Member
kr1347 wrote on Mon, 16 November 2015 18:08
I am new to this stored proc ..trying to fix it

The first step is in Michel's first point: get rid of (remove) the exception clause (stated there, entirely). It is just hiding the errors which are happening. After removing it from the procedure body, what will be the result of its running?
Previous Topic: arraysize and PL/SQL
Next Topic: Results Set based on Dynamic Date stored in variable
Goto Forum:
  


Current Time: Wed Apr 17 22:34:31 CDT 2024