Data Blocks [message #130095] |
Thu, 28 July 2005 02:56 |
swchen
Messages: 15 Registered: July 2005 Location: malaysia
|
Junior Member |
|
|
Dear, Mr.David
Hi to all, I need some idea or suggestion to my program. Now I have one master and detail relation. In the detail block I have 1 data item called amount. Data type of amount are number and have positive and negative number. I now i need fetch the number to another 2 column call debit(+ve value) and credit(-ve value). So, how I can assign the data value to column?
|
|
|
|
|
Re: Data Blocks [message #130121 is a reply to message #130095] |
Thu, 28 July 2005 05:13 |
manjuvasu
Messages: 22 Registered: May 2005
|
Junior Member |
|
|
hi,
do u want u'r o/p as like this
amt-----debit-----credit
1000--- 1000
2000--- 2000
-1500------------ -1500
and the coding is
declare
a number;
cursor c1 is select sign(amt) from amt;
begin
go_block('blkname');
first_record;
open c1;
loop
fetch c1 into a;
exit when c1% notfound;
if a = 1 then
:blkname.debit := :blkname.amt;
else
:blkname.credit := :blkname.amt;
end if;
next_record;
end loop;
first_record;
close c1;
end;
bye.
|
|
|
Re: Data Blocks [message #130232 is a reply to message #130121] |
Thu, 28 July 2005 20:53 |
swchen
Messages: 15 Registered: July 2005 Location: malaysia
|
Junior Member |
|
|
Thanks ur coding, manjuvasu. Actually, my problem not in the the coding side. I just dunno where i shall put in the coding, i need put the coding at where ?? i need create trigger or new prodecure or function for put in the coding?
manjuvasu wrote on Thu, 28 July 2005 18:13 | hi,
do u want u'r o/p as like this
amt-----debit-----credit
1000--- 1000
2000--- 2000
-1500------------ -1500
and the coding is
declare
a number;
cursor c1 is select sign(amt) from amt;
begin
go_block('blkname');
first_record;
open c1;
loop
fetch c1 into a;
exit when c1% notfound;
if a = 1 then
:blkname.debit := :blkname.amt;
else
:blkname.credit := :blkname.amt;
end if;
next_record;
end loop;
first_record;
close c1;
end;
bye.
|
|
|
|
|
Re: Data Blocks [message #130242 is a reply to message #130095] |
Thu, 28 July 2005 23:39 |
yogeshwar_cool
Messages: 32 Registered: July 2005 Location: india
|
Member |
|
|
hi,
you can try this
select decode(sign(:amount),1,abs(:amount),0) debit
,decode(sign(:amount),-1,abs(:amount),0) credit
INTO :block_name.debit,:block_name.credit
from dual
put this code in post query of the detailed block as well as
the when validate item of the amount.
regards
yogeshwar.
|
|
|
|
|
|