I tried this. It is working now!
Thanks!


On Wed, 8 Aug 2001, Erick Nelson wrote:

>
> You cannot bind 'code' into a select, only data. TO_DATE is a sql
> function.
> What you probably wanted was...
>
> $insert = <<EOT;
> INSERT INTO test_db
> (START_DT, AA, BB)
> VALUES
> (TO_DATE(?,'YYYY/MM/DD-HH24:MI:SS'), ?, ?)
> EOT
>
> $START_DT = '2001/07/24-19:18:26';
>
> $sth=$dbh->prepare($insert);
> $sth->execute($START_DT,$AA,$BB);
>
> --OR--
>
> If you are using Oracle (I'm not sure if this works in any other
> database) you can alter
> the default date mask by doing the following at the beginning of your
> program...
>
> $alter = "ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY/MM/DD-HH24:MI:SS'";
> $dbh->do($alter);
>
> Then you can put our $insert statement back to....
>
> $insert = <<EOT;
> INSERT INTO test_db
> (START_DT, AA, BB)
> VALUES
> (TO_DATE(?, ?, ?)
> EOT
>
> "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?
> >
> > For testing, I did:
> > $insert = "
> > INSERT INTO test_db
> > (START_DT,AA,BB)
> > VALUES
> > (TO_DATE('2001/07/24-19:18:26','YYYY/MM/DD-HH24:MI:SS'),
> > 'aa', 'bb')
> > ";
> > $dbh->do($insert);
> >
> > This worked fine.
> >
> > Thanks for the help!
> >
> > Qing
>

Reply via email to