Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculate a text box on a 6i form 1

Status
Not open for further replies.

bookouri

IS-IT--Management
Feb 23, 2000
1,464
US
I have a table of transactions with a debit col and a credit col. I have a text box on my form. Can I assign a value to my text box with something like :text_box := select sum(debit)from trans? Or do i have to do a cursor of some kind to do my calculations?

thanks for any suggestions

 
What did you try?

[sup]Beware of false knowledge; it is more dangerous than ignorance.[/sup][sup] ~George Bernard Shaw[/sup]
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
My website: Emu Products Plus
 
I tried using a summary column, but get several different errors related to the column not being a "summary column"

Ive been trying different variations on:

declare
temp number;
begin
temp := 'select sum(debit) from gc_check_trans' ;
:gc_check_trans.balance := temp;
end;

 
You can use a summary column if "debit" is a column in your detail block. The important thing is the placement. Make sure you follow the guidelines in form's help to insure the summary is in the correct block.

If you are just displaying the total, you can simply use:
Code:
select sum(debit) into :debit_total from trans
but... if the total is affected by data entry in your form, I recommend you try lewisp's suggestion.

[sup]Beware of false knowledge; it is more dangerous than ignorance.[/sup][sup] ~George Bernard Shaw[/sup]
Consultant Developer/Analyst Oracle, Forms, Reports & PL/SQL (Windows)
My website: Emu Products Plus
 
thanks, i did get the summary column thing working so ill probably go with that, but i know ive had times in the past when i needed to do a select sum or count or something and i dont remember how i finally got it to work.
 
thanks, i also got the sql sum to work, I had the syntax wrong.. once i switched it around to the select into :x from trans instead of select from trans into :x..

thanks again..
 
-- place a text box to enter numbers say "t1" multiline
-- row varchar2
-- place a push button to write code in the trigger
-- place a text box to display the sum value say "t2"
-- logic = checking the enter key to divide the numbers

-- type numbers in a text box and press enter after each
-- different number
-- and click the push button to get the result into the
-- text box t2.

declare
l number;
i number;
c varchar2(100);
n number;
begin
i := 1;
l := length:)t1);

c := '';
n := 0;
while i<=l loop
-- 10 is linefeed character
if ascii(substr:)t1,i,1)) != 10 then
c := c ||substr:)t1,i,1);
else
n := n + to_number(c);
c := '';
end if;
i := i + 1;
end loop;
:t2 := n;
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top