Bind variables and default values

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jdorlon
Posts: 202
Joined: Fri 05 Jan 2007 22:07

Bind variables and default values

Post by jdorlon » Wed 05 Aug 2015 14:06

Hello,

I have a TOraQuery that is an insert statement with a SQL like this:

Insert into Table
(Column1, Column2, Column3)
values
(:Column1, :Column2, :Column3)

If there are default values for these columns, and I set NULL for one of the binds, then NULL is inserted instead of the default value. Is there a property on TOraParam that I can set so that the default value will be used instead of NULL?

I have discovered that a statement like this will work
Insert into Table
(Column1, Column2, Column3)
values
(DEFAULT, :Column2, :Column3)

but I don't want to have to change the statement for every row that I am inserting - I just want to change bind variable values and/or properties. Thanks,

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Bind variables and default values

Post by AlexP » Thu 06 Aug 2015 08:39

Hello,

No, if you set the field value explicitly (even NULL), then this value will be inserted, not depending on whether the field has a default value or not. In order to insert default values, this field mustn't be specified in the query.

Post Reply