Created
October 6, 2009 20:26
-
-
Save rbuels/203375 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### before | |
| sub set_modified_person_id_by_username { | |
| my $self = shift; | |
| my $data = shift || croak("FUNCTION PARAMETER ERROR: The username was not supplied for set_modified_person_id_by_username function"); | |
| my $query = "SELECT sp_person_id FROM sgn_people.sp_person WHERE username=?"; | |
| my $sth = $self->get_schema()->storage()->dbh()->prepare($query); | |
| $sth->execute($data); | |
| my ($modified_person_id) = $sth->fetchrow_array(); | |
| ## Only need be reported if the username that it is being set is not in the sgn_people.sp_person table | |
| if (defined $modified_person_id) { | |
| my $metadata_rso = $self->get_mdmetadata_row(); | |
| $metadata_rso->set_column( modified_person_id => $modified_person_id); | |
| $self->set_mdmetadata_row($metadata_rso); | |
| } else { | |
| croak("DATA INTEGRATION ERROR: The username=$data do not exists in the sgn_people.sp_person table.\n"); | |
| } | |
| } | |
| #### after | |
| sub set_modified_person_id_by_username { | |
| my ($self, $username) = @_; | |
| $username or croak 'must specify a username'; #< croak will give the function name | |
| my ($person_id) = $self->get_schema | |
| ->storage | |
| ->dbh | |
| ->selectrow_array(<<EOQ, undef , $username); | |
| SELECT sp_person_id | |
| FROM sp_person | |
| WHERE username = ? | |
| EOQ | |
| ## croak if the username is not in the sgn_people.sp_person table | |
| $modified_person_id | |
| or croak "username '$username' does not exist in the sgn_people.sp_person table"; | |
| $self->get_mdmetadata_row | |
| ->modified_person_id( $modified_person_id ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment