Home » Developer & Programmer » Forms » Data Blocks
Data Blocks [message #130095] Thu, 28 July 2005 02:56 Go to next message
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 #130097 is a reply to message #130095] Thu, 28 July 2005 03:02 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Use a post-query trigger to populate the new fields on retrieval, and in the when-validate-item, populate the field when the data is changed.

Search for 'calculate' in this forum. For example http://www.orafaq.com/forum/m/120861/67467/?srch=calculate#msg_120861.
David

[Updated on: Thu, 28 July 2005 03:07]

Report message to a moderator

Re: Data Blocks [message #130099 is a reply to message #130097] Thu, 28 July 2005 03:09 Go to previous messageGo to next message
swchen
Messages: 15
Registered: July 2005
Location: malaysia
Junior Member
Thanks I try it now. Nod

[Updated on: Thu, 28 July 2005 03:10]

Report message to a moderator

Re: Data Blocks [message #130121 is a reply to message #130095] Thu, 28 July 2005 05:13 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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 #130236 is a reply to message #130232] Thu, 28 July 2005 22:07 Go to previous messageGo to next message
manjuvasu
Messages: 22
Registered: May 2005
Junior Member
hi,
u can create a procedure writing this coding and call in when-new-block-instance trigger.
try it and reply.
Re: Data Blocks [message #130242 is a reply to message #130095] Thu, 28 July 2005 23:39 Go to previous messageGo to next message
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.
Re: Data Blocks [message #130313 is a reply to message #130236] Fri, 29 July 2005 05:09 Go to previous messageGo to next message
swchen
Messages: 15
Registered: July 2005
Location: malaysia
Junior Member
I try already, but the the data just will go to debit column only. Sad
Re: Data Blocks [message #130512 is a reply to message #130313] Sun, 31 July 2005 18:50 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Try the following in your Post-Query trigger:

IF nvl(:amount,0) < 0 then
:block_name.debit = :amount;
ELSE
:block_name.credit = nvl(:amount,0);
END IF;

David
Re: Data Blocks [message #130543 is a reply to message #130512] Sun, 31 July 2005 23:17 Go to previous message
swchen
Messages: 15
Registered: July 2005
Location: malaysia
Junior Member
Thanks all, I get it already..Smile
Previous Topic: how to Search by Monthly ?
Next Topic: Forms Applications and LDAP
Goto Forum:
  


Current Time: Thu Sep 19 23:22:58 CDT 2024