通过perl舞者在oracle上更新时间戳

时间:2014-04-29 10:02:22

标签: sql oracle perl dancer

尝试使用每个舞者更新oracle数据库上的时间戳时,我收到以下错误。

ORA-01858: a non-numeric character was found where a numeric was expected.

代码:

   my $fmt = 'YYYY-MM-DD HH24:MI:SS:FF3';
   database->do("alter session set nls_timestamp_format = '$fmt'");


    my $time_start =params->{'start1'};#2014-04-29 10:21:42:037

    my $time_stop = params->{'stop1'};  #2014-04-29 10:42:08:355
    my $id = params->{'id'};

    my $timestart ="TO_TIMESTAMP('$time_start','YYYY-MM-DD HH24:MI:SS:FF3')";
    my $timestop ="TO_TIMESTAMP('$time_stop','YYYY-MM-DD HH24:MI:SS:FF3')";
    database->quick_update($table, {ID => $id}, {SBYS_START_TIME => $timestart, SBYS_STOP_TIME =>$timestop});

1 个答案:

答案 0 :(得分:0)

我在这里看到了两种可能性:

  • 您的输入值与您评论的内容不匹配(例如,该停止时间缺少0,可能是秒数)

要检查这一点,请添加一个快速调试行:

my $time_start = params->{'start1'};
debug $time_start;
my $time_stop = params->{'stop1'};
debug $time_stop;
  • 您的代码将$ time_start作为文字sting传递给数据库。

尝试上旧学校。:

my $timestart ="TO_TIMESTAMP('" . $time_start . "','YYYY-MM-DD HH24:MI:SS:FF3')";
my $timestop ="TO_TIMESTAMP('" . $time_stop . "','YYYY-MM-DD HH24:MI:SS:FF3')";

这将消除这种可能性。