Home » SQL & PL/SQL » SQL & PL/SQL » PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL (Oracle 11g, 11.2.0.2.0, Windows 7.)
PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL [message #617597] Wed, 02 July 2014 03:24 Go to next message
ho2512
Messages: 7
Registered: August 2013
Junior Member
Create or Replace PROCEDURE BUILD_BALANCE_DATA
AS
TYPE Bal_Days_Type IS TABLE OF Avg_Balance_Det%ROWTYPE; -- Avg_Balance_Det is a DB table, with 15 columns
bal_days_tab Bal_Days_Type := Bal_Days_Type ();
v_bal_cntr NUMBER := 0;

BEGIN
For i in ( Select acc_no, ldgr_bal, avlbl_bal from daily_bal_det )
loop
/*
Some Calculation
some queries to fetch details
*/

bal_days_tab.EXTEND;
v_bal_cntr := v_bal_cntr + 1;

bal_days_tab(v_bal_cntr).acc_no := i.acc_no;
bal_days_tab(v_bal_cntr).ldgr_bal := i.ldgr_bal;

/*
Populating other columns of record type from calculated values and other table queries
*/

IF v_bal_cntr = 3000
THEN
FORALL i IN 1 .. v_bal_cntr
--INDICES OF bal_days_tab
INSERT INTO Avg_Balance_Det
( acc_no, ldgr_bal
/*
other table columns
*/
)
VALUES ( bal_days_tab(v_bal_cntr).acc_no, bal_days_tab(v_bal_cntr).ldgr_bal
/*
other record type columns
*/
);

COMMIT;

bal_days_tab.DELETE;
v_bal_cntr := 0;

END IF;
END LOOP;
END BUILD_BALANCE_DATA;
/

Please check the above procedure.
When i am compiling the above procedure it is giving an error - PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL .

This procedure will be inserting around 60000 to 90000 records and i don't want it to perform those many context swithces.
So inserting records in chunks of 3000 (or may be more).

I tries using FORALL in below two ways

FORALL i IN 1 .. v_bal_cntr

and

FORALL i IN INDICES OF bal_days_tab

but both are giving the same error.

Could you please help me to resolve the error or guide me to another way of achieving this.

Many Thanks in advance.
Re: PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL [message #617598 is a reply to message #617597] Wed, 02 July 2014 03:38 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
Since you have not mentioned what sort of calculation you do before the insert, I guess you could do it in plain SQL as :

INSERT INTO Avg_Balance_Det(column_list) SELECT column_list FROM daily_bal_det WHERE ...


And having COMMIT inside procedure is never a good idea.
Re: PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL [message #617600 is a reply to message #617598] Wed, 02 July 2014 04:10 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Please read and follow How to use [code] tags and make your code easier to read?

FORALL i IN 1 .. v_bal_cntr
 --INDICES OF bal_days_tab
 INSERT INTO Avg_Balance_Det
 ( acc_no, ldgr_bal
 /*
 other table columns 
 */ 
 )
 VALUES ( bal_days_tab(v_bal_cntr).acc_no, bal_days_tab(v_bal_cntr).ldgr_bal
 /*
 other record type columns 
 */
 );

In that bit of code v_bal_cntr is static, you need to use i for the index variable in the values clause.
Re: PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL [message #617604 is a reply to message #617598] Wed, 02 July 2014 04:18 Go to previous messageGo to next message
ho2512
Messages: 7
Registered: August 2013
Junior Member
Hi Lalit,

The thing which i am trying to do cannot be done using a plain sql.

The daily_bal_det table holds balance details of multiple accounts, wherein each account will have multiple records.
calculation part will calculate positive and negative balance days, if for any date there is no balance available
then previous day balance will be considered.

Other queries part includes some sql queries to fetch details from other DB tables and more of such code.

i have checked the code using simple for loop and it is working fine, was going through a book where i came to know about FORALL.

so thought of using it.
Re: PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL [message #617607 is a reply to message #617604] Wed, 02 July 2014 04:22 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
You can do amazingly complex things with SQL.
Re: PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL [message #617608 is a reply to message #617600] Wed, 02 July 2014 04:22 Go to previous messageGo to next message
ho2512
Messages: 7
Registered: August 2013
Junior Member
Oh Yes. Thanks Cookiemonster.
My bad..i hope thats not the cause of this error. Will change it and check again.
Re: PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL [message #617612 is a reply to message #617608] Wed, 02 July 2014 04:44 Go to previous messageGo to next message
ho2512
Messages: 7
Registered: August 2013
Junior Member
Thanks Cookiemonster.

Well, i dont know what to say. wasted my half day for this copy-paste error.
changed v_bal_cntr to index variable i, and the procedure compiled.

Sometimes we look for a larger view, and miss the smaller one's.

Will execute and check whether it works as expected.

Thanks to all for your time.

Lalit commented that having commit inside procedure is not a good idea.
i would like to know more details/reasons on this.

One reason i am aware of is any exception occurs and is not handled properly
then records which were processed will be committed.
Re: PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL [message #617613 is a reply to message #617612] Wed, 02 July 2014 04:48 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
It's a bad idea generally because any given procedure may be included in a larger transaction. Only the client that initiated the transaction can know when everything that's a part of the transaction has been executed, it can then issue commit/rollback as appropriate.
Re: PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL [message #617616 is a reply to message #617613] Wed, 02 July 2014 04:53 Go to previous message
ho2512
Messages: 7
Registered: August 2013
Junior Member
Thanks, will keep that in mind.
Previous Topic: Grouped data on detail record
Next Topic: Killing job after sometime is not working.
Goto Forum:
  


Current Time: Fri Apr 19 15:06:05 CDT 2024