Вставить значение по умолчанию при вставке null

У меня есть база данных Oracle и таблица с несколькими ненулевыми столбцами, все со значениями по умолчанию.

Я хотел бы использовать один оператор вставки для любых данных, которые я хочу вставить, и не утруждаюсь проверять, являются ли вставленные значения нулевыми или нет. Of course I have multiple nullable columns, so the code create insert statement is very unreadable, ugly, and I just don't like it that way.

I would like to have one statement, something similar to:

INSERT INTO schema.my_table
    ( pk_column, other_column, not_null_column_with_default_value)
VALUES
    (:pk_column,:other_column, NVL(:not_null_column_with_default_value, DEFAULT) );

That of course is a hypothetical query. Do you know any way I would achieve that goal with Oracle DBMS?

EDIT:

Thank you all for your answers. It seams that there is no "standard" way to achieve what I wanted to, so I accepted the IMO best answer: That I should stop being to smart and stick to just omitting the null values via automatically built statements.

Not exactly what I would like to see, but no better choice.

11
задан marc_s 25 January 2017 в 17:20
поделиться