I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2007-10-13 01:20:54-07 by yuvasuriya
Please Help I am stuck PERL DBI
Hi All, I am new to perl ,I am stuck with below issues.... I am querying to database to fetch a field for a user through a subroutine. Check the below code.. +.. 1. if user is found in Database then subroutine returns the result. The print statement after the s +oubroutine call print the result. (expected) 2. but if user is not found or the the column vlaue is empty for that user , then my program is ge +tting terminated before return the result to the subroutine ....so the print statement after the +subroutine call is not being exceuted... Please help me... Here is the code #!/usr/bin/perl use DBI; $database = "idm"; $username = "idm"; $password = "idm"; $hostname = "localhost"; $output = &connectCBMS(900010); --> calling a subroutine print $output; -- printing the result sub connectCBMS { $db = DBI->connect("DBI:Oracle:host=$hostname;sid=$database",$username,$password); unless($db) { #LogResult("(ERROR) Failed to connect to $DIRHOST."); #ReportFailure("(ERROR) Failed to connect to $DIRHOST."); print "(ERROR) Failed to connect to $hostname."; return 0; } my ($staffcode) = @_; # Execute a Query my $sql = qq{ SELECT REGISTRATIONDAY FROM CBMS WHERE STAFFCODE = ? }; my $sth = $db->prepare( $sql ); $sth->bind_param( 1, $staffcode ); $sth->execute(); my $row; while ( $row = $sth->fetchrow_array( ) ) { return $row; } $sth->finish(); $db->disconnect(); exit(0); } Thanks Suriya
Direct Responses: 6405 | Write a response