Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Can anyone show me how the following Perl script can be converted to T-SQL code.
my @columns = qw/Male_00_04 Female_00_04 Male_05_09 Female_05_09 M +ale_10_14 Female_10_14 Male_15_19 Female_15_19 Male_20_24 Female_20_2 +4 Male_25_29 Female_25_29 Male_30_34 Female_30_34 Male_35_39 Female_3 +5_39 Male_40_44 Female_40_44 Male_45_49 Female_45_49 Male_50_54 Femal +e_50_54 Male_55_59 Female_55_59 Male_60_64 Female_60_64 Male_65_69 Fe +male_65_69 Male_70_74 Female_70_74 Male_75_79 Female_75_79 Male_80_84 + Female_80_84 Male_85_115 Female_85_115/; my @columns_B = @columns; my $start = 0; my $end = 4; my $sex = 1; foreach (@columns){ my $sthB_A = $dbh->prepare(" INSERT INTO Adjusted_census_data_normalised (GeographicCode, Sex, Age +_start, Age_end, Person_count) ( SELECT A.GeographicCode, ".$sex.", ".$start.", ".$end.", A.".$_. +" FROM Adjusted_census_data A WHERE " . $_ . " >= 0) ") or die "Couldn't prepare query: ".$dbh->errstr; $sthB_A->execute() or die "Couldn't execute query: ".$sthB_A->er +rstr; if ($sex == 1){ $sex = 2 } else { $sex = 1 } if ($sex == 1){ $start = $start +5; if ($start > 84){ $end = 115; } else { $end = $end+5; } } else{ #do nothing } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Conversion to T-SQL
by Aragorn (Curate) on Jan 26, 2004 at 11:58 UTC | |
by Anonymous Monk on Jan 26, 2004 at 14:32 UTC | |
by Aragorn (Curate) on Jan 26, 2004 at 15:04 UTC | |
by Anonymous Monk on Jan 26, 2004 at 21:56 UTC | |
by Anonymous Monk on Jan 26, 2004 at 14:10 UTC | |
by Aragorn (Curate) on Jan 26, 2004 at 14:40 UTC | |
|
Re: Conversion to T-SQL
by mpeppler (Vicar) on Jan 26, 2004 at 18:19 UTC |