Expand|Select|Wrap|Line Numbers
- my $sql = "SELECT District_ID,
- ClientName,
- Status,
- Region,
- ClientCode,
- OriginalName,
- JPA_ID FROM tblImportedDistricts";
- my $sth = $dbh->prepare($sql)
- or die "Can't prepare statement: $DBI::errstr";
- $sth->execute();
- warn "starting loops..";
- while ( @region = $sth->fetchrow_array)
- {
- warn $region[1];
- $dist_id = &guid;
- $schema->resultset('customerDistrict')->create(
- {
- version_id =>$version_guid,
- region_id =>$dist_id,
- district_id =>"$region[0]",
- clientname =>"$region[1]",
- jpa_id =>"$region[6]"
- });
- my $sql_building = "SELECT building_ID, Name FROM tblImportedbuildings WHERE districts_ID = ".$region[0];
- my $sth_building = $dbh->prepare($sql_building)
- or die "Can't prepare statement: $DBI::errstr";
- $sth_building->execute();
- while ( @customer_building = $sth_building->fetchrow_array)
- {
- warn $customer_building[1];
- $building_id = &guid;
- $schema->resultset('customerbuilding')->create(
- {
- customer_building_id =>$building_id,
- building_id =>"$customer_building[0]",
- name =>"$customer_building[1]",
- region_id =>$dist_id
- });
- my $sql_loc = "SELECT room_ID, Description FROM tblrooms WHERE building_ID = ".$customer_building[0];
- my $sth_loc = $dbh->prepare($sql_loc)
- or die "Can't prepare statement: $DBI::errstr";
- $sth_loc->execute();
- while ( @customer_room = $sth_loc->fetchrow_array)
- {
- warn $customer_room[1];
- $loc_id = &guid;
- $schema->resultset('customerroom')->create(
- {
- customer_room_id =>$loc_id,
- room_id =>"$customer_room[0]",
- customer_building_id =>$building_id,
- name =>"$customer_room[1]"
- });
- }
- warn "done with this one";
- }
- warn "starting next";
- }
- print "Done with: $datasource\n";
- $dbh->disconnect || die;
- }