#!/usr/bin/perl
@in=<DATA>;
for $id ("Customer","IP","Host","URL","Browser","MimeType","BrowserClass"){
	@out = @in;
  for (@out) {
		s/Browser/$id/g;
		print;
  }
}

__DATA__

drop function getBrowserID(text);
create function getBrowserID(text) returns int4 as '
  declare
    p_Text alias for $1;
    p_ID  int4;
  begin
    select BrowserID into p_ID from Browser where (BrowserText = p_Text);
    if not found then
      insert into Browser (BrowserText) values(p_Text);
      select last_value into p_ID from Browser_BrowserID_seq;
    end if;
    return p_ID;
  end;
' language 'PLpgSQL';

