"HUA, Qing" wrote:

> I am trying to insert using the following statements. Somehow,
> VARCHAR NULL can be inserted, but the NUMBER NULL keeps giving me
> ORA-01722: invalid number (DBD ERROR: OCIStmtExecute).
>
> What did I do wrong? Thanks!
>
> $insert = "INSERT INTO test_database (TEST_PRIOR, TESTER_IP_ADDR,
> TEST_DURATION, TEST_RESULT)
> VALUES
> (?,?,?,?)";
> $sth=$dbh->prepare($insert);
> $sth->execute('HIGH', '10.1.9.124',NULL,'NULL');
>
> For testing purpose, I did the following in the database and it worked.
>
> INSERT INTO test_database (TEST_PRIOR, TESTER_IP_ADDR,

> TEST_DURATION, TEST_RESULT) VALUES ('HIGH', '10.1.9.124',NULL,'NULL');

undef is null in perl
Change .........

$sth->execute('HIGH', '10.1.9.124', undef, undef);

if you want a null in both columns or....

$sth->execute('HIGH', '10.1.9.124', undef, 'NULL');

if all you wanted was a null in the number column, I couldn't tell exactly
what you were trying to do.

Reply via email to