raja.b4u has asked for the wisdom of the Perl Monks concerning the following question:
Thanks Suriya#!/usr/bin/perl</br> 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); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help me ! I am stuck ! PERL DBI
by kyle (Abbot) on Oct 13, 2007 at 02:04 UTC | |
by Anonymous Monk on Oct 13, 2007 at 03:35 UTC | |
by spectre9 (Beadle) on Oct 13, 2007 at 03:56 UTC | |
|
Re: Help me ! I am stuck ! PERL DBI
by runrig (Abbot) on Oct 13, 2007 at 16:09 UTC |