On Wed, Aug 08, 2001 at 09:15:49AM -0600, HUA, Qing wrote:
> 
> $START_DT=TO_DATE('2001/07/24-19:18:26','YYYY/MM/DD-HH24:MI:SS');
> 
> To insert this and other data into database I did:
> 
> $insert="
> INSERT INTO test_db
> (START_DT, AA, BB)
> VALUES
> (?,?,?)
> ";
> 
> $sth=$dbh->prepare($insert);
> $sth->execute($START_DT,$AA,$BB);
> 
> The error message I got is:
> DBD::Oracle::st execute failed: ORA-01843: not a valid
> month (DBD ERROR: OCIStmtExecute)
> 
> What did I do wrong?

You cannot bind an SQL expression to a placeholder.  You can only bind a
simple value.

Try this instead:

$start_date = '2001/07/24-19:18:26';

$insert = <<"EndOfSQL";
  INSERT INTO test_db
    (START_DT, AA, BB)
  VALUES
    (TO_DATE(?, 'YYYY/MM/DD-HH24:MI:SS'), ?, ?)
EndOfSQL

$sth = $dbh->prepare($insert);

$sth->execute($start_date, $aa, $bb);


Ronald

Reply via email to