| From: | Thomas Kellerer <spam_eater(at)gmx(dot)net> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Junk date getting uploaded into date field |
| Date: | 2013-11-05 09:42:03 |
| Message-ID: | l5aeh1$9fl$1@ger.gmane.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
bsreejithin, 05.11.2013 10:04:
> We have a csv file which we upload into postgres DB. If there are some
> errors, like a data mismatch with the database table columns, postgres
> should raise and error and upload should fail.
>
> What is happening now is that, in case we get some junk date in the upload
> file, postgres does auto-correction and does not raise an error!
>
> A wrong date like ,say, 33-Oct-2013 gets converted as 2-Nov-2013 when the
> data is loaded into a date field. No error raised.Data gets uploaded!
>
> How can I prevent this ? I don't want this junk data to get loaded.
>
I'm pretty sure Postgres will not allow that.
If I had to guess: you are using a Java program which uses SimpleDateFormat and the "lenient" parsing was not disabled.
Because that's exactly what happens with a SimpleDateFormat in it's default configuration.
http://docs.oracle.com/javase/6/docs/api/java/text/DateFormat.html#setLenient%28boolean%29
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Scott Marlowe | 2013-11-05 09:56:59 | Re: Keepalive doubt. |
| Previous Message | Francisco Olarte | 2013-11-05 09:29:42 | Keepalive doubt. |