> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Friday, 27 August 2004 8:51 a.m.
> To: Robert
> Cc: [EMAIL PROTECTED]
> Subject: Re: DBI insert records
> 
> You could either set the NLS date format, or wrap a to_date around you 
> placeholder, something like (untested)
> 
> to_date(?, 'DD/Mon/YYYY:24HH:MI:SS') for 16/Aug/2004:15:06:54

  '24HH' isn't valid.  'HH24' should be used in it's place.

So instead of:

$dbh2->do("INSERT INTO webtest (hostname,datetime,url,username,company) 
VALUES ( ?,?,?,?,? )", undef, $hostname, $datetime, $url, $username, 
$company );


You want something like (also untested):

$dbh2->do("INSERT INTO webtest (hostname,datetime,url,username,company) 
VALUES ( ?,to_date(?,'DD/Mon/YYYY:HH24:MI:SS'),?,?,? )", undef,
$hostname, $datetime, $url, $username, $company );

  Although to me, that looks messy.  Personally, I'd write it like this:

$sql = q{
  INSERT INTO webtest (hostname, datetime, url, username, company)
  VALUES ( NULL, TO_DATE(?,'DD/Mon/YYYY:HH24:MI:SS'), ?, ?, ? )
};
$dbh2->do($sql, $hostname, $datetime, $url, $username, $company )
  or <<insert-error-handler-here>>;



> This may need a leading space, or you may need to trim your field as
> there seems to be a blank in front

  Trim the leading blank.



Reply via email to