Home » Developer & Programmer » Forms » How To Apply Group by Command in Forms 6i
How To Apply Group by Command in Forms 6i [message #555234] Tue, 22 May 2012 10:06 Go to next message
qanita786
Messages: 229
Registered: May 2007
Location: PAKISTAN
Senior Member
How To Apply Group by Command in Forms 6i at block level for example in data block a field name is code,quantity and code replicate many times it is not working with out commit but i want to calculate sum of quantity in data block by code group before commit

if we apply this command at sql level then command is

select code,sum(nvl(quantity,0)) from sal_detail group by code and its work very well

Regards

Faheem


Re: How To Apply Group by Command in Forms 6i [message #555270 is a reply to message #555234] Tue, 22 May 2012 15:45 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
There are many records in that block. For example:
Code Quantity
---- --------
A     100
A     200
B    1000
C     500
C     300

A SELECT statement you mentioned results with
Code Quantity
---- --------
A     300
B    1000
C     800

My question is: where do you plan to display the result? In another block? In a report? Elsewhere?

You said:Quote:
it is not working with out commit
which means that it IS working as you wish when/if you commit? If that's so, and regarding the fact that you do NOT want to commit, how about POST instead? So: post first, calculate the result next.
Re: How To Apply Group by Command in Forms 6i [message #555299 is a reply to message #555270] Wed, 23 May 2012 01:37 Go to previous messageGo to next message
qanita786
Messages: 229
Registered: May 2007
Location: PAKISTAN
Senior Member
dear sir as you describe i want to insert data in table in only three rows like

A 300
B 1000
C 800

not like this 5 rows

A 100
A 200
B 1000
C 500
C 300
Re: How To Apply Group by Command in Forms 6i [message #555301 is a reply to message #555299] Wed, 23 May 2012 02:11 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If that's the case, maybe you shouldn't base your data block on a table that is supposed to store these values. Create another, possibly a global temporary table, and base data block on it. Store values in there, and then - after the job is done - do something like
insert into your_real_table (code, quantity)
  select code, sum(quantity)
  from newly_created_table
  group by code;

A simple way to do that would be, for example, a push button in a form. Or a database trigger. Or any other option you find appropriate.
Re: How To Apply Group by Command in Forms 6i [message #555314 is a reply to message #555301] Wed, 23 May 2012 03:26 Go to previous messageGo to next message
qanita786
Messages: 229
Registered: May 2007
Location: PAKISTAN
Senior Member
dear i am working on data block not on table data block replicate as

A 100
A 200
B 1000
C 500
C 300

Re: How To Apply Group by Command in Forms 6i [message #555330 is a reply to message #555314] Wed, 23 May 2012 04:10 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I'm afraid I don't understand what you are saying. Could you explain it, please?
Re: How To Apply Group by Command in Forms 6i [message #555338 is a reply to message #555330] Wed, 23 May 2012 05:05 Go to previous messageGo to next message
qanita786
Messages: 229
Registered: May 2007
Location: PAKISTAN
Senior Member
dear Sir its simple when we input in data block records are like

A 100
A 200
B 1000
C 500
C 300

but when i commit these records they will save as

A 300
B 1000
C 800
Re: How To Apply Group by Command in Forms 6i [message #555339 is a reply to message #555338] Wed, 23 May 2012 05:07 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I understood that, but I did not understand this:Quote:
i am working on data block not on table data block replicate
What does it mean?
Re: How To Apply Group by Command in Forms 6i [message #555341 is a reply to message #555339] Wed, 23 May 2012 05:24 Go to previous messageGo to next message
qanita786
Messages: 229
Registered: May 2007
Location: PAKISTAN
Senior Member
Sir simple is that i want to insert record in table with group function
Re: How To Apply Group by Command in Forms 6i [message #555347 is a reply to message #555341] Wed, 23 May 2012 05:45 Go to previous messageGo to next message
Littlefoot
Messages: 21813
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
- In a message #555301, I told you what would I do
- Then you said "i am working on data block not on table data block replicate"
- I asked what that means
- You said that you "want to insert record in table with group function"

All I can say is to point you back to the message #555301.

For my puny brain, it is too complex to base a block on a table, insert certain values into it, commit changes and then, somehow, recalculate values (which would mean that some records should be updated and some records deleted). Therefore, I suggested a workaround.

It appears that you aren't happy with it - which is fine; that's why I said (in the same message #555301) that you can choose any other option you find appropriate.

Perhaps you should wait for another opinion - other forum members might have better and more acceptable ideas.
Re: How To Apply Group by Command in Forms 6i [message #555365 is a reply to message #555347] Wed, 23 May 2012 08:42 Go to previous messageGo to next message
ranamirfan
Messages: 535
Registered: January 2006
Location: Pakistan / Saudi Arabia
Senior Member

Quote:

Code Quantity
---- --------
A 100
A 200
B 1000
C 500
C 300

Result

Code Quantity
---- --------
A 300
B 1000
C 800


As my opinion.

First - Not Possible you 'll not get this result in your current Canarios.
Second - Possible with one option as said Mr.Littlefoot.

Quote:

If that's the case, maybe you shouldn't base your data block on a table that is supposed to store these values. Create another, possibly a global temporary table, and base data block on it. Store values in there, and then - after the job is done - do something like

insert into your_real_table (code, quantity)
select code, sum(quantity)
from newly_created_table
group by code;

A simple way to do that would be, for example, a push button in a form. Or a database trigger. Or any other option you find appropriate.


Third - If you want to see detail of Code A with Quantity 300 then where you'll get it.As my opinion this not good idea in entry level.

Forth - Show your summarized Data in a Report not a form.


Regards,
Irfan

Re: How To Apply Group by Command in Forms 6i [message #555501 is a reply to message #555365] Thu, 24 May 2012 11:50 Go to previous message
nnigam
Messages: 12
Registered: May 2012
Location: Washington, DC
Junior Member
I think what littlefoot is trying to say is that your block is based on a table. So there is a one to one correspondence between the fields in your form and records in your table. Each field in your form corresponds to a field in the table. What you should do is to de-link the form field from a table field and save it to a cumulative variable. When you are ready to save your records, update the table from the variable. You will have then have your desired result.

By the way, have you ever thought about upgrading your forms to 11g. Even 10g is now out of support.

Neeraj Nigam
Pitss America
http://wwww.pitss.com/us

[Updated on: Tue, 29 May 2012 01:54] by Moderator

Report message to a moderator

Previous Topic: FRM-41213
Next Topic: ORA-01031
Goto Forum:
  


Current Time: Fri Jul 05 22:27:00 CDT 2024