sub new { my $class = shift; my $self = bless {}, $class; my $dbh = shift || return (undef); $self->{dbh} = $dbh; # store the dbh for future use return $self; } sub getDDL { my $self = shift; my ($dbase,$tableName,$tableDtls) = @_; return (undef) if (!$dbase or !$tableName); my $tabDtlSql = qq/ ##some sql query /; my $tabDtlSth = $self->{dbh}->prepare($tabDtlSql); $tabDtlSth->execute or $self->{ERROR_STR} = "Can't execute SQL statement: $DBI::errstr\n"; if ($self->{ERROR_STR}) { return (undef); } else { ## do some stuff... }