#!/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); }