I wrote:

Whoa. Be careful what you say about Oracle.

Oracle does have default values for table columns, defined
by the DEFAULT clause in CREATE/ALTER TABLE.

However, the _only_ way to get a column set to the default value
is to leave the column out of the INSERT statement altogether.
There is nothing you can put in a VALUES(..) list which
will do the trick, nor is there anything that can be bound to
a placeholder which will result in the default being set.

and Greg Sabino Mullane replied:

You sure about that? You might want to check your docs, or
update to a newer version of Oracle. If I recall correctly,
this ability was added in 9i.

Doh. You are right. Oracle 9i does support the DEFAULT
keywords in VALUES(...) lists. I apologise for my mistake.

My feeble excuse is that this new use of the word DEFAULT
is not indexed in either the 9i or the 10g SQL Reference Manual.

However, this does not help as much as you might think.
DBD::Oracle does not implement placeholder binding by
re-writing statements itself. Instead it uses Oracle's
internal implementation of placeholders.

The second half of my statement above still appears to be
true. If a statement like the following has been prepared

  INSERT ... VALUES ( ....   ?     .... )

there is no way of binding anything to the placeholder which
make the statement act like

  INSERT ... VALUES ( .... DEFAULT .... )

The only possibilities are to bind a value or to bind a
NULL.

I would be very happy to be proved wrong on this point,
but I have checked the 9i and 10g OCI manuals, and I
am depressingly sure that I am right.

So - my point remains. DBD::Oracle, as designed, cannot
implement the suggested feature.

--
Charles Jardine - Computing Service, University of Cambridge
[EMAIL PROTECTED]    Tel: +44 1223 334506, Fax: +44 1223 334679

Reply via email to