Try something like this:

[EMAIL PROTECTED] {1100} devel: more d.pl
#!/usr/bin/perl


# Environmental Vars for DBI $ENV{'LD_LIBRARY_PATH'} = '/oracle/app/oracle/product/8.0.5/lib'; $ENV{'ORACLE_HOME'} = '/oracle/app/oracle/product/8.0.5/';

#Variables, solicit the ip address from the browser
$database = 'dbi:Oracle:pas';
$uid = 'pas2';
$pwd = '****************';

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);

use DBI;
use Time::Local;


my $dbh = DBI->connect($database,$uid,$pwd);



#alter session set NLS_DATE_FORMAT='DY MON DD HH:MI:SS YYYY';


$select = "alter session set NLS_DATE_FORMAT=\'MM DD YYYY HH MI SS'";
$sth = $dbh->prepare($select) || die("Can't prepare statement $DBI::errstr");
$sth->execute || die("Can't execute statement $DBI::errstr");
$sth="";


$select = "select SYSDATE from dual";
my $sth = $dbh->prepare($select) || die("Can't prepare statement $DBI::errstr");
$sth->execute || die("Can't execute statement $DBI::errstr");
$oracletime=$sth->fetchrow;
$sth="";


($qmonth,$qday,$qyear,$qhour,$qminute,$qsec)=split(/ /,$oracletime);
#Correct for perl
$qmonth=$qmonth-1;
$qyear=$qyear-1900;
$epochoracletime = timelocal($qsec,$qminute,$qhour,$qday,$qmonth,$qyear);

$oracletime=("$qmonth $qday $qyear $qhour $qminute $qsec");

#end of getting time from oracle db and converting to epoch




#get localtime and convert to epoch ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); $localnormaltime=("$mon $mday $year $hour $min $sec"); $localepochtime=timelocal($sec,$min,$hour,$mday,$mon,$year);




#print "Oracle Time: \t\t$oracletime\n"; print "Oracle epoch time:\t$epochoracletime\n"; #print "Local normal time: $localnormaltime\n"; print "Local epoch time:\t$localepochtime\n";






$dbh->disconnect || warn "error disconnecting: $DBI::errstr\n";


At 07:17 AM 2/24/2003, you wrote:
Thanks for the info.

I am actually trying to get
the time on our oracle data base
and compare it to the local time on
each machine. Then if there's
a difference + or - say 10 minutes.
Put it into a report showing
that the machine needs to be reset.

Is there a way to convert the
HH24:MI:SS to total seconds?
I need to compare it to the time
in seconds on each machine.

regards,

John

-----Original Message-----
From: Fay Jason-W13246 [mailto:[EMAIL PROTECTED]
Sent: Friday, February 21, 2003 6:11 PM
To: Perl-Win32-Admin-Request \(E-mail\)
Subject: RE: sql statements


>Hi cliff, > >I plugged that statement into my >code and it's still having a problem. >Could you take a look at my code to >see what the problem could be: > >$dbh = DBI->connect("dbi:Oracle:",'username','password'); > >my $sth = $dbh->prepare(qq{select sysdate into :mydate from dual}); > >if ( $sth ) { > $sth->execute; > } >$dbh->disconnect; > >regards, > >John

When using the DBI / DBH modules, you don't need to bind an Oracle variable
(ie 'into :mydate') as you are in this example.  Change your query from
'select sysdate into :mydate from dual' to 'select sysdate from dual' and
then put the query result from your sth handle into a scalar variable.

Now if you want to change the default format that Oracle uses for date
datatypes, (ie YYYY-MM-DD) you would need to further modify your query.
'select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') from dual'.

Regards,

Jason Fay
Software Engineer - Motorola PCS

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

-- Rick Coloccia Network Analyst SUNY Geneseo 119 South Hall 1 College Circle Geneseo, NY 14454 Voice: (585) 245-5577 Fax:(585) 245-5579

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to