Not null constraint in postgre

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Not null constraint in postgre

Chamath Sajeewa
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!
Reply | Threaded
Open this post in threaded view
|

Re: Not null constraint in postgre

Amit S.

On Mon, Jul 27, 2020 at 11:15 AM Chamath Sajeewa <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Not null constraint in postgre

Chamath Sajeewa
Hi,
column data type is int4. 
Thanks!

On Mon, 27 Jul 2020, 11:19 Amit S., <[hidden email]> wrote:

On Mon, Jul 27, 2020 at 11:15 AM Chamath Sajeewa <[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Not null constraint in postgre

Didier Gasser-Morlay-2
In reply to this post by Chamath Sajeewa
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 <[hidden email]> 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!
Reply | Threaded
Open this post in threaded view
|

Re: Not null constraint in postgre

Chamath Sajeewa
Yes Thank You!!

On Mon, 27 Jul 2020, 11:31 Didier Gasser-Morlay, <[hidden email]> 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 <[hidden email]> 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!