Counting the number of rows in a group [message #170987] |
Sun, 07 May 2006 05:08 |
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
|
|
|
|
|
|
|