[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-admin
Subject:    Re: How to manage null value while copy data from csv
From:       "Gavan Schneider" <list.pg.gavan () pendari ! org>
Date:       2020-12-31 7:59:33
Message-ID: 95624F2E-5D82-4B3B-BC0A-B20F3DCC5150 () pendari ! org
[Download RAW message or body]

On 31 Dec 2020, at 17:25, Sachin Kumar wrote:

> when I am uploading data (CSV File) using the COPY command. I am 
> getting
> below mention error.
>
> ERROR:  null value in column "adj_type" violates not-null constraint.
>
This indicates the relevant column in the database table has been 
defined to **never** allow a NULL value.

> When I define null it gives no error message, but how to manage null 
> value
> n data without defining it, because there is many more columns. when 
> it
> defines null it gives an error if null value comes you are violating 
> null.
>
What is meant by "define null"? Is this where you put a real value 
in the CSV, or a dummy text value such as "null"?
You could massage the csv so all the gaps get a dummy value, then handle 
this in the SQL table.

Otherwise
> Please suggest how to manage null value in postgresql?
>
Basic options
1. Fix the raw csv data so there are no gaps — the person who defined 
the database wasn't expecting any
2. Fix the database so it will accept NULL values — assuming this is 
ok with the business model
3. Accept the csv data into a temporary table which tolerates NULL, 
massage the data then insert into the real database

Regards
Gavan Schneider

[Attachment #3 (text/html)]

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal">
<p dir="auto">On 31 Dec 2020, at 17:25, Sachin Kumar wrote:</p>
</div><div style="white-space:normal"><blockquote style="border-left:2px solid #777; \
color:#777; margin:0 0 5px; padding-left:5px"><p dir="auto">when I am uploading data \
(CSV File) using the COPY command. I am getting <br>
below mention error.
<br>
ERROR:  null value in column "adj_type" violates not-null constraint.
</p>
</blockquote></div>
<div style="white-space:normal">
<p dir="auto">This indicates the relevant column in the database table has been \
defined to <strong>never</strong> allow a NULL value.</p> </div><div \
style="white-space:normal"><blockquote style="border-left:2px solid #777; color:#777; \
margin:0 0 5px; padding-left:5px"><p dir="auto">When I define null it gives no error \
message, but how to manage null value <br>
n data without defining it, because there is many more columns. when it
<br>
defines null it gives an error if null value comes you are violating null.
</p>
</blockquote></div>
<div style="white-space:normal">
<p dir="auto">What is meant by "define null"? Is this where you put a real value in \
the CSV, or a dummy text value such as "null"?<br> You could massage the csv so all \
the gaps get a dummy value, then handle this in the SQL table.</p> <p \
dir="auto">Otherwise</p> </div><div style="white-space:normal"><blockquote \
style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><p \
dir="auto">Please suggest how to manage null value in postgresql? </p>
</blockquote></div>
<div style="white-space:normal">
<p dir="auto">Basic options</p>
<ol>
<li>Fix the raw csv data so there are no gaps — the person who defined the database \
wasn't expecting any</li> <li>Fix the database so it will accept NULL values — \
assuming this is ok with the business model</li> <li>Accept the csv data into a \
temporary table which tolerates NULL, massage the data then insert into the real \
database</li> </ol>
<p dir="auto">Regards<br>
Gavan Schneider</p>

</div></div>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic