Hi monks here is my question
I am writing query to update the table in my DB it is like thid
my $SQL = "UPDATE kcrei_batch_job_history SET
rows_added = $_[1],
status = 'C',
stop_datetime = getdate(),
stop_tran_seq_nbr = $hdr_tran_seq_nbr,
elapsed_time_hh = datediff(hh, convert(dat
+etime,$loader_start_time), getdate())
elapsed_time_mm = datediff(mi, convert(date
+time,$loader_start_time), getdate()),
elapsed_time_ss = datediff(ss, convert(dat
+etime,$loader_start_time), getdate())
WHERE
master_job_no = $master_job_no AND
master_job_sub_no = $_[0]";
when i prepare this statement it is giving error like this
DBD::ODBC does not yet support binding a named parameter more than once
So to overcome this i wrote another query like as following, which is written by somebody else and i followed the same thing then its working fine
my @f = (localtime)[0..5];
my $stop_time = sprintf "%d-%02d-%02d %02d:%02d:%02d", $f[5]+1900
+, $f[4]+1, $f[3], $f[2], $f[1], $f[0];
Compute the elapsed time in hours, minutes and seconds.
my $elapsed_time_ss = sprintf "%02d", timeDiff($loader_start_time
+, $stop_time);
my $elapsed_time_mm = sprintf "%02d", $elapsed_time_ss / 60;
my $elapsed_time_hh = sprintf "%02d", $elapsed_time_ss / 3600;
$stop_time .= ".000";
my $SQL = "UPDATE kcrei_batch_job_history SET
rows_added = $_[1],
status = 'C',
stop_datetime = getdate(),
stop_tran_seq_nbr = $hdr_tran_seq_nbr,
elapsed_time_hh = $elapsed_time_hh,
elapsed_time_mm = $elapsed_time_mm,
elapsed_time_ss = $elapsed_time_ss
WHERE
master_job_no = $master_job_no AND
master_job_sub_no = $_[0]";
here i am using timediff() function which is like this
############################################
# Function: TimeDiff
############################################
# param1 is the 'from' DateTime as 'YYYY-MM-DD HH:MM:SS' 24-hour clock
# param2 is the 'to' Date as 'YYYY-MM-DD HH:MM:SS' 24 hour-clock
# returns time difference in seconds
sub timeDiff {
my (@fromDT, @toDT);
my (@fromT, @toT);
my ($fromTM, $toTM);
if(!defined($_[0]) || !defined($_[1])){
return(1);
}
@fromDT = split(/ /,$_[0]);
@toDT = split(/ /,$_[1]);
@fromT = split(/:/,$fromDT[1]);
@toT = split(/:/,$toDT[1]);
$fromTM = ($fromT[0] * 3600) + ($fromT[1] * 60) + $fromT[2];
$toTM = ($toT[0] * 3600) + ($toT[1] * 60) + $toT[2];
# If fromDT is different than toDT we make the assumption that eit
+her the data is corrupt or the transaction ran over midnight
if($fromDT[0] ne $toDT[0]){
my @fromDate = split(/-/,$fromDT[0]);
my @toDate = split(/-/,$toDT[0]);
if( ($fromDate[0] eq $toDate[0]) && ($fromDate[1] eq $toDate[1
+]) && ( ($toDate[2] - $fromDate[2]) == 1) ) {
$toTM += (24 * 3600);
} else {
return;
}
}
if(($toTM - $fromTM) == 0){
return(1);
}
return($toTM - $fromTM);
}
can anybody tell me what was the problem and how it is resolved
because i am not getting anything
thanks
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.