insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'TTSYD', 'ADMIN AT SYDNEY',      site_id, 1, 0 FROM site_info WHERE airport_code = 'SYD';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'TTMEL', 'ADMIN AT MELBOURNE',   site_id, 1, 0 FROM site_info WHERE airport_code = 'MEL';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'TTLHR', 'ADMIN AT HEATHROW',    site_id, 1, 0 FROM site_info WHERE airport_code = 'LHR';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'TTDRW', 'ADMIN AT DARWIN',      site_id, 1, 0 FROM site_info WHERE airport_code = 'DRW';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'TTOOL', 'ADMIN AT GOLD COAST',  site_id, 1, 0 FROM site_info WHERE airport_code = 'OOL';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'TTADL', 'ADMIN AT ADELAIDE',    site_id, 1, 0 FROM site_info WHERE airport_code = 'ADL';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'TTBNE', 'ADMIN AT BRISBANE',    site_id, 1, 0 FROM site_info WHERE airport_code = 'BNE';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'TTPER', 'ADMIN AT PERTH',       site_id, 1, 0 FROM site_info WHERE airport_code = 'PER';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'TTCNS', 'ADMIN AT CAIRNS',      site_id, 1, 0 FROM site_info WHERE airport_code = 'CNS';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'TTDXB', 'ADMIN AT DUBAI',       site_id, 1, 0 FROM site_info WHERE airport_code = 'DXB';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'QFSYD', 'Qantas at SYDNEY',     site_id, 1, 0 FROM site_info WHERE airport_code = 'SYD';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'QFMEL', 'Qantas at MELBOURNE',  site_id, 1, 0 FROM site_info WHERE airport_code = 'MEL';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'QFBNE', 'Qantas at BRISBANE',   site_id, 1, 0 FROM site_info WHERE airport_code = 'BNE';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'QFCNS', 'Qantas at CAIRN',      site_id, 1, 0 FROM site_info WHERE airport_code = 'CNS';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'QFADL', 'Qantas at ADELAIDE',   site_id, 1, 0 FROM site_info WHERE airport_code = 'ADL';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'QFPER', 'Qantas at PERTH',      site_id, 1, 0 FROM site_info WHERE airport_code = 'PER';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'QFDRW', 'Qantas at DARWIN',     site_id, 1, 0 FROM site_info WHERE airport_code = 'DRW';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'QFOOL', 'Qantas at GOLD COAST', site_id, 1, 0 FROM site_info WHERE airport_code = 'OOL';
insert into agents (agent_code, description, site_id, last_user, archive_flag) 
SELECT 'EKDXB', 'DUBAI',                site_id, 1, 0 FROM site_info WHERE airport_code = 'DXB';

insert into user_group(group_name,priv1,priv2,last_user,agent_code,airport_code) 
VALUES('ADM_SYD', 'm','q', 1,'TTSYD','SYD');
insert into user_group(group_name,priv1,priv2,last_user,agent_code,airport_code) 
VALUES('ADM_MEL', 'm','q', 1,'TTMEL','MEL');
insert into user_group(group_name,priv1,priv2,last_user,agent_code,airport_code) 
VALUES('ADM_LHR', 'm','q', 1,'TTLHR','LHR');
insert into user_group(group_name,priv1,priv2,last_user,agent_code,airport_code) 
VALUES('ADM_DRW', 'm','q', 1,'TTDRW','DRW');
insert into user_group(group_name,priv1,priv2,last_user,agent_code,airport_code) 
VALUES('ADM_OOL', 'm','q', 1,'TTOOL','OOL');
insert into user_group(group_name,priv1,priv2,last_user,agent_code,airport_code) 
VALUES('ADM_ADL', 'm','q', 1,'TTADL','ADL');
insert into user_group(group_name,priv1,priv2,last_user,agent_code,airport_code) 
VALUES('ADM_BNE', 'm','q', 1,'TTBNE','BNE');
insert into user_group(group_name,priv1,priv2,last_user,agent_code,airport_code) 
VALUES('ADM_PER', 'm','q', 1,'TTPER','PER');
insert into user_group(group_name,priv1,priv2,last_user,agent_code,airport_code) 
VALUES('ADM_CNS', 'm','q', 1,'TTCNS','CNS');
insert into user_group(group_name,priv1,priv2,last_user,agent_code,airport_code) 
VALUES('ADM_DXB', 'm','q', 1,'TTDXB','DXB');

INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_SYD','GenAdm1','Adm1','TTADMINSYD',NULL,SYSDATE,'QQQQQQ',1,'TTSYD',SYSDATE);
INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_SYD','Auto','Auto','AUTOSYD',NULL,SYSDATE,'QQQQQQ',1,'TTSYD',SYSDATE);

INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_MEL','GenAdm2','Adm2','TTADMINMEL',NULL,SYSDATE,'QQQQQQ',1,'TTMEL',SYSDATE);
INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_MEL','Auto','Auto','AUTOMEL',NULL,SYSDATE,'QQQQQQ',1,'TTMEL',SYSDATE);

INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_LHR','GenAdm3','Adm3','TTADMINLHR',NULL,SYSDATE,'QQQQQQ',1,'TTLHR',SYSDATE);
INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_LHR','Auto','Auto','AUTOLHR',NULL,SYSDATE,'QQQQQQ',1,'TTLHR',SYSDATE);

INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_DRW','GenAdm4','Adm4','TTADMINDRW',NULL,SYSDATE,'QQQQQQ',1,'TTDRW',SYSDATE);
INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_DRW','Auto','Auto','AUTODRW',NULL,SYSDATE,'QQQQQQ',1,'TTDRW',SYSDATE);

INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_OOL','GenAdm5','Adm5','TTADMINOOL',NULL,SYSDATE,'QQQQQQ',1,'TTOOL',SYSDATE);
INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_OOL','Auto','Auto','AUTOOOL',NULL,SYSDATE,'QQQQQQ',1,'TTOOL',SYSDATE);

INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_ADL','GenAdm6','Adm6','TTADMINADL',NULL,SYSDATE,'QQQQQQ',1,'TTADL',SYSDATE);
INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_ADL','Auto','Auto','AUTOADL',NULL,SYSDATE,'QQQQQQ',1,'TTADL',SYSDATE);

INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_BNE','GenAdm7','Adm7','TTADMINBNE',NULL,SYSDATE,'QQQQQQ',1,'TTBNE',SYSDATE);
INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_BNE','Auto','Auto','AUTOBNE',NULL,SYSDATE,'QQQQQQ',1,'TTBNE',SYSDATE);

INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_PER','GenAdm8','Adm8','TTADMINPER',NULL,SYSDATE,'QQQQQQ',1,'TTPER',SYSDATE);
INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_PER','Auto','Auto','AUTOPER',NULL,SYSDATE,'QQQQQQ',1,'TTPER',SYSDATE);

INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_CNS','GenAdm9','Adm9','TTADMINCNS',NULL,SYSDATE,'QQQQQQ',1,'TTCNS',SYSDATE);
INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_CNS','Auto','Auto','AUTOCNS',NULL,SYSDATE,'QQQQQQ',1,'TTCNS',SYSDATE);

INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_DXB','GenAdm1','Adm1','TTADMINDXB',NULL,SYSDATE,'QQQQQQ',1,'TTDXB',SYSDATE);
INSERT INTO tagtrak_users(group_name,surname,firstname,loginname,retire_date,create_date,tagtrak_password,last_user,agent_code,pwd_set_date)
VALUES('ADM_DXB','Auto','Auto','AUTODXB',NULL,SYSDATE,'QQQQQQ',1,'TTDXB',SYSDATE);

insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('QFMEL', (select site_id FROM site_info WHERE airport_code = 'MEL'), 'MELBOURNE', null, 1, 0);
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('AUMEL', (select site_id FROM site_info WHERE airport_code = 'MEL'), 'MELBOURNE', null, 1, 0);
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('QFSYD', (select site_id FROM site_info WHERE airport_code = 'SYD'), 'SYDNEY',    null, 1, 0);
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('AUSYD', (select site_id FROM site_info WHERE airport_code = 'SYD'), 'SYDNEY',    null, 1, 0 );
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('QFBNE', (select site_id FROM site_info WHERE airport_code = 'BNE'), 'BRISBANE',  null, 1, 0 );
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('AUBNE', (select site_id FROM site_info WHERE airport_code = 'BNE'), 'BRISBANE',  null, 1, 0 );
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('QFCNS', (select site_id FROM site_info WHERE airport_code = 'CNS'), 'CAIRNS',    null, 1, 0 );
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('AUCNS', (select site_id FROM site_info WHERE airport_code = 'CNS'), 'CAIRNS',    null, 1, 0 );
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('QFADL', (select site_id FROM site_info WHERE airport_code = 'ADL'), 'ADELAIDE',  null, 1, 0 );
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('AUADL', (select site_id FROM site_info WHERE airport_code = 'ADL'), 'ADELAIDE',  null, 1, 0 );
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('MBLHR', (select site_id FROM site_info WHERE airport_code = 'LHR'), 'HEATHROW',  null, 1, 0 );
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('AULHR', (select site_id FROM site_info WHERE airport_code = 'LHR'), 'HEATHROW',  null, 1, 0 );
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('AUPER', (select site_id FROM site_info WHERE airport_code = 'PER'), 'PERTH',     null, 1, 0);
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('QFPER', (select site_id FROM site_info WHERE airport_code = 'PER'), 'PERTH',     null, 1, 0 );
insert into location (location_code, site_id, location_description, group_name, last_user, archive_flag) values ('AUDXB', (select site_id FROM site_info WHERE airport_code = 'DXB'), 'DUBAI',     null, 1, 0 );

insert into contracted_agents (airline_alpha_code, agent_code, last_user, archive_flag, min_flight_no, max_flight_no, flight_type) VALUES('QF', 'QFSYD', 1, 1, 0, 9999, 'B');
insert into contracted_agents (airline_alpha_code, agent_code, last_user, archive_flag, min_flight_no, max_flight_no, flight_type) VALUES('QF', 'QFMEL', 1, 1, 0, 9999, 'B');
insert into contracted_agents (airline_alpha_code, agent_code, last_user, archive_flag, min_flight_no, max_flight_no, flight_type) VALUES('QF', 'QFCNS', 1, 1, 0, 9999, 'B');
insert into contracted_agents (airline_alpha_code, agent_code, last_user, archive_flag, min_flight_no, max_flight_no, flight_type) VALUES('QF', 'QFBNE', 1, 1, 0, 9999, 'B');
insert into contracted_agents (airline_alpha_code, agent_code, last_user, archive_flag, min_flight_no, max_flight_no, flight_type) VALUES('QF', 'QFOOL', 1, 1, 0, 9999, 'B');
insert into contracted_agents (airline_alpha_code, agent_code, last_user, archive_flag, min_flight_no, max_flight_no, flight_type) VALUES('QF', 'QFPER', 1, 1, 0, 9999, 'B');
insert into contracted_agents (airline_alpha_code, agent_code, last_user, archive_flag, min_flight_no, max_flight_no, flight_type) VALUES('QF', 'QFDRW', 1, 1, 0, 9999, 'B');
insert into contracted_agents (airline_alpha_code, agent_code, last_user, archive_flag, min_flight_no, max_flight_no, flight_type) VALUES('QF', 'QFADL', 1, 1, 0, 9999, 'B');
insert into contracted_agents (airline_alpha_code, agent_code, last_user, archive_flag, min_flight_no, max_flight_no, flight_type) VALUES('EK', 'EKDXB', 1, 1, 0, 9999, 'B');
insert into contracted_agents (airline_alpha_code, agent_code, last_user, archive_flag, min_flight_no, max_flight_no, flight_type) VALUES('BA', 'EKDXB', 1, 1, 0, 9999, 'B');

update db_config set db_value = (SELECT site_id FROM site_info WHERE airport_code = 'SYD')
   where db_item = 'DEFAULT_AIRPORT';
