 declare
 	_domain_id integer;
 begin
+	perform delete_txt(_domain,_host,_txt);
 	select into _domain_id id from domains where name = _domain;
 	insert into records(id,domain_id,name,type,content,ttl) values (nextval('record_id_seq'), _domain_id, _host || '.' || _domain, 'TXT', _txt, 3600);
 	return found;

declare
	_domain_id integer;
begin
	select into _domain_id id from domains where name = _domain;
	insert into records(id,domain_id,name,type,content,ttl) values (nextval('record_id_seq'), _domain_id, _host || '.' || _domain , 'CNAME', _alias, 3600);
	return found;

declare
	_domain_id integer;
begin
	perform delete_a(_domain,_host,_ipaddr);
	select into _domain_id id from domains where name = _domain;
	insert into records(id,domain_id, name,type, content, ttl) values (nextval('record_id_seq'), _domain_id, _host || '.' ||  _domain, 'A', _ipaddr, 3600);
	return found;
