siddheshsawant has asked for the wisdom of the Perl Monks concerning the following question:
Hello friends .....I am stuck at one question in perl....I have wrote a subroutine which is called by someother subroutine.....The task of this subroutine is to insert value in database.The sub routine is as follows:
sub _get_user_scenario { my ($self, $schema, $user_scenario) = @_; my $user_scenario_rs = undef; eval { #get the number of user scenarios in the database table my $count = $schema->resultset("UserScenario")->count(); #insert user scenario, or if already in database, update the descripti +on $user_scenario_rs = $schema->resultset("UserScenario")->update_or_create( { name => $user_scenario->{name}, description => $user_scenario->{description}, }, { key => "u_user_scenario_name" }, ) || die "Unable to update/insert data to table UserScenar +io: $!\n"; }; if($@) { #warn(); $self->log_writer()->write_error_row("Unable to get/insert dat +a to table UserScenario: $@"); return undef; } else { return $user_scenario_rs; } }
If $user_scenario->{description} is empty then I don't want to replace the description for the existing sceanrio.And I wanna keep the value which is already there in the database for that scenario.How to achieve it?Any suggestions? Thanks in advance!!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how to get out of subroutine without returning anything
by ikegami (Patriarch) on Mar 30, 2010 at 15:45 UTC | |
by shmem (Chancellor) on Mar 30, 2010 at 16:13 UTC | |
|
Re: how to get out of subroutine without returning anything
by ikegami (Patriarch) on Mar 30, 2010 at 15:33 UTC | |
|
Re: how to get out of subroutine without returning anything
by jacaril (Beadle) on Mar 30, 2010 at 16:57 UTC |