Home » Developer & Programmer » Forms » re: Trouble in Total
re: Trouble in Total [message #78385] Mon, 18 February 2002 21:20 Go to next message
annu
Messages: 34
Registered: February 2002
Member
Dear Expeet Pratap ,

First of all i would like to thanks to u for you valuable suggestions. But still some conclusions have to disscuss. Which are as follows .

Sample Data
----------------

Record # Amount_DR Amount_CR Balance
1.............1000...........0..............1000
2.............500............0..............1500
3.............0..............350............1150
4.............0..............190............960
5.............900............0..............1860

1. When_new_form_instance

It works .. but it stuck on the last record before total last record balance. u can see that it doesnt total the amount of 1860 (From Sample data)
because we use " exit when :system.last_record='TRUE';" in our procedure Calculate_total.

2. When_validate_item

it doest work. Because u know Validate_item is a restricted triggure .. and it doest not allow to navegate any where from validated item . and we are using First_record command and go_block command in out procedure Calculate_total. It cause an error when it fires "frm-40737 illigal restricted procedure First_record in When-validate_item triggure.

So kindly suggest what should do next.

Annu
-----
PROCEDURE calculate_balance IS
balance number;
BEGIN
balance:=0;
go_block('acc_trans');
first_record;
loop
:acc_trans.balance:=balance+nvl(:acc_trans.amountdr,0)-nvl(:acc_trans.amountcr,0);
balance :=:acc_trans.balance;
down;
exit when :system.last_record='TRUE';
end loop;
END;
Re: re: Trouble in Total [message #78387 is a reply to message #78385] Tue, 19 February 2002 00:05 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
hi annu,

please change your procedure to

PROCEDURE calculate_balance IS
balance number;
cur_rec number;
BEGIN
balance:=0;
cur_rec:=:system.cursor_record;
first_record;
loop
:acc_trans.balance:=balance+nvl(:acc_trans.amountdr,0)-nvl(:acc_trans.amountcr,0);
balance :=:acc_trans.balance;
exit when :system.last_record='TRUE';
down;
end loop;
go_record(cur_rec);
END;

and instead of calling the calculate_balance in when_validate_item , call it in when_new_record_instance of acc_trans block.

i have tested it and it is working fine.

cheers
pratap
Re: re: Trouble in Total [message #78407 is a reply to message #78385] Wed, 20 February 2002 20:46 Go to previous messageGo to next message
annu
Messages: 34
Registered: February 2002
Member
Dear Pratap

i had done all what u code me but still some problems i m facing in this form .. actually the procedure u told me . its always
fire at every record because we are using it in when_new_record instance.. Understand.. and it always stands on the last
record because we need the last trasaction balance .. but if we want to move upwords in the transaction .. we cant do this ..
because our procedure forcly down us and place to the last record.. so if we want to make any changes in any existing
tranaction .. we cant do .. .. i hope u understand clearly .. Now i make some changes in your given code. Exatly i just edit the Exit when statment.. U can see in givin coding. .. Now it work and moves towards upword direction and i can make changes in every existing records but now a problem occer is i cant enter a new record .. because i forcly disable to do that by procedure calling .. by exit When statment. Hope u understand it clearly now.

tell me what should i do for the next.

Annu.

*** Some changes i had made in it .. but its all what u told me. I m calling this function in When_new_record_instance

PROCEDURE calculate_balance IS
r_bal number;
cur_rec number;
BEGIN
r_bal:=0;
--last_record;
cur_rec:=:system.cursor_record;
first_record;
:acc_trans.balance:=r_bal+nvl(:acc_trans.amountdr,0)-nvl(:acc_trans.amountcr,0);
loop
r_bal :=:acc_trans.balance;
exit when :system.last_record='TRUE' or :system.cursor_record=cur_rec;
down;
:acc_trans.balance:=r_bal+nvl(:acc_trans.amountdr,0)-nvl(:acc_trans.amountcr,0);
-- message('cal_bal fire');
end loop;
-- go_record(cur_rec);
END;
Re: re: Trouble in Total [message #78409 is a reply to message #78407] Thu, 21 February 2002 00:05 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
do not change the procedure.revert the changes, keep as i sent u last time
just change in
when_new_record_instance
-------------------------
if :system.record_status='NEW' then
null;
else
calculate_balance;
end if;

here is the procedure for ur ready reference

PROCEDURE calculate_balance IS
balance number;
cur_rec number;
BEGIN
balance:=0;
cur_rec:=:system.cursor_record;
first_record;
loop
:acc_trans.balance:=balance+nvl(:acc_trans.amountdr,0)-nvl(:acc_trans.amountcr,0);
balance :=:acc_trans.balance;
exit when :system.last_record='TRUE';
down;
end loop;
go_record(cur_rec);
END;
Previous Topic: Invoking Command Line from Form Builder
Next Topic: Re: FREE TRAINING ON ORACLE AND DEVELOPER200 CONTACT BY MAIL STEP BY STEP TAINING
Goto Forum:
  


Current Time: Mon Mar 18 21:36:51 CDT 2024