Home » Developer & Programmer » Forms » Counting the number of rows in a group
Counting the number of rows in a group [message #170987] Sun, 07 May 2006 05:08 Go to next message
Grazien
Messages: 7
Registered: April 2006
Junior Member
I know this is probably silly really, but as Ive said before im still pretty new to this.

Ive created a two tables which state details of a business region and an agent details, the two tables are linked by the region ID

I want to be able to make a text box that shows the amount of agents in a region, Ive been given some basic code but it seems to not work for me

these are the region and agent classes, each has a block in the form.

----------------

CREATE TABLE region
(r_id NUMBER(4),
name VARCHAR2(20) NOT NULL,
location VARCHAR2(20) NOT NULL,
address VARCHAR2(25) NOT NULL,
contact_phone VARCHAR2(15) NOT NULL,
division_name VARCHAR2(10) NOT NULL,
CONSTRAINT region_id_pk PRIMARY KEY (r_id));

----------------

CREATE TABLE agent
(a_id VARCHAR2(3),
last_name VARCHAR2(25) NOT NULL,
first_name VARCHAR2(25) NOT NULL,
userid VARCHAR2(8 ) NOT NULL, ------> there is no space here in actual code
comm NUMBER(11,2) NOT NULL,
start_date DATE NOT NULL,
region_id NUMBER(4) NOT NULL,
CONSTRAINT agent_id_pk PRIMARY KEY (a_id,region_id));

----------------

and this is the procedure code i used in form builder

----------------

PROCEDURE count_agents is

begin

select count(*)
into :REGION.TOTAL_AGENTS
from AGENT
where region_id = :AGENT.region_id
end;

----------------

REGION.TOTAL_AGENTS is the name of teh text box in the region canvas that i want the number to go into.

can any one tell me where im going wrong? especially regarding how to initialise the procedure, where should it go?


Thanks for any help you can give me,
Paul

[Updated on: Sun, 07 May 2006 05:22]

Report message to a moderator

Re: Counting the number of rows in a group [message #171044 is a reply to message #170987] Mon, 08 May 2006 01:45 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Okay, from where do you currently call 'count_agents'?

Put the call 'count_agents' into a Post-Query trigger on your 'Region' block.

David
Re: Counting the number of rows in a group [message #171107 is a reply to message #171044] Mon, 08 May 2006 07:47 Go to previous messageGo to next message
Grazien
Messages: 7
Registered: April 2006
Junior Member
i tried that, however although a count function did show, for soem reason it showed the amount for the region before, and im not sure why.
thanks for teh first bit though
Re: Counting the number of rows in a group [message #171136 is a reply to message #171107] Mon, 08 May 2006 11:37 Go to previous messageGo to next message
Grazien
Messages: 7
Registered: April 2006
Junior Member
That's great!
thank you so much! I've been stuck on little things like that all week.
I've finished my coursework now so thank you to everyone who helped me on the forums. I'm probably taking it as a major next year for my computing degree, so no doubt i'll show up again Razz

later all,
Paul
Re: Counting the number of rows in a group [message #171174 is a reply to message #171136] Mon, 08 May 2006 18:38 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
We'll be here.

David
Previous Topic: Running Sum in Form
Next Topic: Capturing Forms Message Input
Goto Forum:
  


Current Time: Fri Sep 20 09:27:10 CDT 2024