SQLState 23502

915 views
Skip to first unread message

Gili

unread,
May 20, 2013, 6:51:19 PM5/20/13
to h2-da...@googlegroups.com
Hi,

I believe H2 should throw SQLState 2201C instead of 23502 when users attempt to insert NULL into a column that disallows it.

SQLState 2201C is defined as "null row not permitted in table" by the SQL 2008 standard as found in 5CD-02-Foundation-2006-01.pdf in: http://en.wikipedia.org/wiki/SQL#cite_note-39

Gili

Thomas Mueller

unread,
May 21, 2013, 1:22:03 PM5/21/13
to H2 Google Group
Hi,

I have tested this with a few databases, and I think 23502 is the most standard SQLState. Test case: create table test(id int, data varchar(255) not null); insert into test values(1, null). Result:

jdbc:h2:mem:
  SQLState: 23502
  ErrorCode: 23502
  Message: NULL not allowed for column "DATA"

jdbc:hsqldb:/tmp/db/test
  SQLState: 23502
  ErrorCode: -10
  Message: integrity constraint violation: NOT NULL check constraint; SYS_CT_10028 table: TEST column: DATA

jdbc:derby:/tmp/db/test2;create=true
  SQLState: 23502
  ErrorCode: 30000
  Message: Column 'DATA'  cannot accept a NULL value.

jdbc:mysql://localhost:3306/test
  SQLState: 23000
  ErrorCode: 1048
  Message: Column 'data' cannot be null

jdbc:postgresql:test
  SQLState: 23502
  ErrorCode: 0
  Message: ERROR: null value in column "data" violates not-null constraint

Regards,
Thomas
> --
> You received this message because you are subscribed to the Google Groups "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
> To post to this group, send email to h2-da...@googlegroups.com.
> Visit this group at http://groups.google.com/group/h2-database?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

cowwoc

unread,
May 21, 2013, 3:26:03 PM5/21/13
to h2-da...@googlegroups.com

    Makes sense given this data. Thanks for the research.

Gili
You received this message because you are subscribed to a topic in the Google Groups "H2 Database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/h2-database/JFH-hix5D-A/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to h2-database...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages