CREATE TABLE "update".witness_temp (
	party_role text,
	prefix_name text ,
	prefix_other text,
	given_name text,
	middle_name text,
	family_name text,
	suffix_name text,
	suffix_other text,
	gender text,
	civil_status text,
	age text,
	birthdate date,
	year_of_birth text,
	age_range text,
	nationality text,
	other_nationality text,
	party_availability text,
	passport_photo text,
	id_availability text,
	id_type text,
	nrc_number text,
	passport_number text,
	driving_licence_number text,
	formal_id text,
	formal_id_number text,
	id_photo_front text,
	id_photo_back text,
	address_type text,
	province text,
	chiefdom text,
	other_chiefdom text,
	pjp_vag text,
	pjp_vag_other text,
	address_searchtext text,
	address_village_id text,
	address_other_village text,
	address_line_1 text,
	address_line_2 text,
	address_town_or_city text,
	address_urban_province text,
	telephone_location_t1 text,
	telephone_main_za decimal,
	telephone_main_za_02 decimal,
	email text,
	witness_relation text,
	add_witness text,
	PARENT_KEY text,
	KEY text
);

copy "update".witness_temp from '/home/ubuntu/fzs/form_e1_demarcation/Demarcation-witness_details.csv'
DELIMITER ','
CSV HEADER;

UPDATE update.witness_temp
SET province = 'Eastern'
where province = 'ZM30';

UPDATE update.witness_temp
SET chiefdom = 'Chifunda'
where chiefdom = 'CHF';

UPDATE update.witness_temp
SET chiefdom = 'Chikwa'
where chiefdom = 'CHI';

--drop temp table
DROP TABLE "update".witness_temp;