public inbox for [email protected]help / color / mirror / Atom feed
Not null constraint in postgre 5+ messages / 3 participants [nested] [flat]
* Not null constraint in postgre @ 2020-07-27 05:44 Chamath Sajeewa <[email protected]> 2020-07-27 05:49 ` Re: Not null constraint in postgre Amit S. <[email protected]> 2020-07-27 06:01 ` Re: Not null constraint in postgre Didier Gasser-Morlay <[email protected]> 0 siblings, 2 replies; 5+ messages in thread From: Chamath Sajeewa @ 2020-07-27 05:44 UTC (permalink / raw) To: [email protected] Hi, There is a column in my table with not null constraint. Default value is set to 0 for that column. In my query, column value is set to null. When i try to execute that query in pgsql, it is getting failed due to constraint violation. Any idea? This is working in oracle. Thank You! ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Not null constraint in postgre 2020-07-27 05:44 Not null constraint in postgre Chamath Sajeewa <[email protected]> @ 2020-07-27 05:49 ` Amit S. <[email protected]> 2020-07-27 06:00 ` Re: Not null constraint in postgre Chamath Sajeewa <[email protected]> 1 sibling, 1 reply; 5+ messages in thread From: Amit S. @ 2020-07-27 05:49 UTC (permalink / raw) To: Chamath Sajeewa <[email protected]>; +Cc: [email protected] Hi Chamath, Here is an article explaining the same::: https://www.enterprisedb.com/postgres-tutorials/how-null-and-empty-strings-are-treated-postgresql-vs... Thanks, Amit On Mon, Jul 27, 2020 at 11:15 AM Chamath Sajeewa <[email protected]> wrote: > Hi, > There is a column in my table with not null constraint. Default value is > set to 0 for that column. In my query, column value is set to null. When i > try to execute that query in pgsql, it is getting failed due to constraint > violation. Any idea? This is working in oracle. > Thank You! > -- Amit Sharma ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Not null constraint in postgre 2020-07-27 05:44 Not null constraint in postgre Chamath Sajeewa <[email protected]> 2020-07-27 05:49 ` Re: Not null constraint in postgre Amit S. <[email protected]> @ 2020-07-27 06:00 ` Chamath Sajeewa <[email protected]> 0 siblings, 0 replies; 5+ messages in thread From: Chamath Sajeewa @ 2020-07-27 06:00 UTC (permalink / raw) To: Amit S. <[email protected]>; +Cc: [email protected] Hi, column data type is int4. Thanks! On Mon, 27 Jul 2020, 11:19 Amit S., <[email protected]> wrote: > Hi Chamath, > > Here is an article explaining the same::: > > > https://www.enterprisedb.com/postgres-tutorials/how-null-and-empty-strings-are-treated-postgresql-vs... > > Thanks, Amit > > On Mon, Jul 27, 2020 at 11:15 AM Chamath Sajeewa <[email protected]> > wrote: > >> Hi, >> There is a column in my table with not null constraint. Default value is >> set to 0 for that column. In my query, column value is set to null. When i >> try to execute that query in pgsql, it is getting failed due to constraint >> violation. Any idea? This is working in oracle. >> Thank You! >> > > > -- > > Amit Sharma > ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Not null constraint in postgre 2020-07-27 05:44 Not null constraint in postgre Chamath Sajeewa <[email protected]> @ 2020-07-27 06:01 ` Didier Gasser-Morlay <[email protected]> 2020-07-27 06:55 ` Re: Not null constraint in postgre Chamath Sajeewa <[email protected]> 1 sibling, 1 reply; 5+ messages in thread From: Didier Gasser-Morlay @ 2020-07-27 06:01 UTC (permalink / raw) To: Chamath Sajeewa <[email protected]>; +Cc: [email protected] In order to get the default value to kick in in an insert statement (which I assume you're trying to do), you can either omit that column name from the insert list or set that column value to DEFAULT (no quotes) Didier On Mon, 27 Jul 2020 at 07:45, Chamath Sajeewa <[email protected]> wrote: > Hi, > There is a column in my table with not null constraint. Default value is > set to 0 for that column. In my query, column value is set to null. When i > try to execute that query in pgsql, it is getting failed due to constraint > violation. Any idea? This is working in oracle. > Thank You! > ^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Not null constraint in postgre 2020-07-27 05:44 Not null constraint in postgre Chamath Sajeewa <[email protected]> 2020-07-27 06:01 ` Re: Not null constraint in postgre Didier Gasser-Morlay <[email protected]> @ 2020-07-27 06:55 ` Chamath Sajeewa <[email protected]> 0 siblings, 0 replies; 5+ messages in thread From: Chamath Sajeewa @ 2020-07-27 06:55 UTC (permalink / raw) To: Didier Gasser-Morlay <[email protected]>; +Cc: [email protected] Yes Thank You!! On Mon, 27 Jul 2020, 11:31 Didier Gasser-Morlay, <[email protected]> wrote: > In order to get the default value to kick in in an insert statement (which > I assume you're trying to do), you can either omit that column name from > the insert list or set that column value to DEFAULT (no quotes) > > Didier > > On Mon, 27 Jul 2020 at 07:45, Chamath Sajeewa <[email protected]> > wrote: > >> Hi, >> There is a column in my table with not null constraint. Default value is >> set to 0 for that column. In my query, column value is set to null. When i >> try to execute that query in pgsql, it is getting failed due to constraint >> violation. Any idea? This is working in oracle. >> Thank You! >> > ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2020-07-27 06:55 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-07-27 05:44 Not null constraint in postgre Chamath Sajeewa <[email protected]> 2020-07-27 05:49 ` Amit S. <[email protected]> 2020-07-27 06:00 ` Chamath Sajeewa <[email protected]> 2020-07-27 06:01 ` Didier Gasser-Morlay <[email protected]> 2020-07-27 06:55 ` Chamath Sajeewa <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox