Skip to Main Content
  • Questions
  • Inserting without a full list for field names

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Chuy.

Asked: September 24, 2019 - 3:28 pm UTC

Last updated: September 25, 2019 - 10:31 am UTC

Version: 12.c

Viewed 1000+ times

You Asked

We have an issue when we perform an insert like this
INSERT INTO STS_RESP_LOG(STS_REQ_LOG_SYSTEM_ID,HSTRY_FLG, SNGL_STS, FRQNCY, CRT_DATE )
                 VALUES (                    ?,        ?,        ?,      ?, sysdate);


? is the corresponding bind variable.

We also have a nullable/numeric column called msg_id that is not listed on the insert query, therefore it should be inserted with null values.

We have a few cases (about 10 cases out of 10 million records) where the record has a 0 instead of a null and we wonder if someone has encountered a glitch on Oracle when it is inserting zero's instead of nulls.
Thanks


and Connor said...

I've never heard of such an instance where we insert a ZERO (or any other non-null value) into a column that is not specified in the SQL statement.

Things to look for:

- an erroneous triggers on the table (don't forget, triggers can be in a different schema to the table)
- erroneous DEFAULT clause

If all fails, you could explicity ADD a trigger to the table temporarily at AFTER ROW level, with something like:

if :new.msg_id is not null then
  raise_application_error(-20000,'WE FOUND ONE!');
end if;


and use things like UTL_CALL_STACK and the like to capture everything to see where that particular insert was different to the others.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Non null value inserted the NULL column

A reader, September 25, 2019 - 6:22 am UTC

But won't that flag it when they actually insert a value in "msg_id"?

Maybe enable column level auditing for that specific column and see if it helps?

Chris Saxon
September 25, 2019 - 10:31 am UTC

Yes... but that's what the OP said they wanted!

More to Explore

Design

New to good database design? Check out Chris Saxon's full fundamentals class.