Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7617773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:13:53+00:00 2026-05-31T03:13:53+00:00

I have a pipe delimited file with some NULL date fields. I load this

  • 0

I have a pipe delimited file with some NULL date fields. I load this data into a temp table with default values for NULL dates. In my case, I wish to default to 1950-01-01. However, these defaults are seemingly being overwritten and 0000-00-00 is being inserted. Here is a quick bash script I wrote to test:

#!/bin/bash

CMD="CREATE TEMPORARY TABLE IF NOT EXISTS ar_tmp LIKE ar; LOAD DATA INFILE '/some/path/ar.txt' INTO TABLE ar_tmp FIELDS TERMINATED BY '|'; SELECT * FROM ar_tmp;"

mysql -uuser -ppassword db -e "$CMD" > /opt/rxdb/tmp.log

I have grepped my source file and confirmed the expected NULL dates have \N and no where in the file is the pattern 0000-00-00.

Here is the structure of ar_tmp:

Field                   Type            Null    Key     Default Extra
customer_code           int(11)         NO      PRI     0
activity_date           date            NO      PRI     1950-01-01
delivery_date           date            NO      PRI     1950-01-01
sequence                int(11)         NO      PRI     0
type                    varchar(10)     YES             NULL
due_date                date            YES             1950-01-01
original_charge         float           YES             NULL
prior_alloc             float           YES             NULL
current_alloc           float           YES             NULL
future_alloc            float           YES             NULL
open_balance            float           YES             NULL
shipto_customer         int(11)         NO      MUL     0
reference               varchar(10)     YES             NULL
journal_ref_number      int(11)         YES             NULL
next_month_flag         int(11)         YES             NULL
journal_type            varchar(15)     YES             NULL
activity_num            int(11)         YES             NULL
document_path           varchar(100)    YES             NULL
conditional_eft_approved char(1)        NO              N
customer_name           varchar(30)     YES             NULL
allow_web_payment       char(1)         YES             NULL
modify_date             datetime        NO              1950-01-01 12:00:00

The defaults being over road are activity_date, delivery_date and due_date. Can someone explain what is going on?

EDIT:

Three lines from the source file:

5830|2012-02-21|\N|29543|PAYMENT|\N|-600.5|0|0|0|-600.5|5830|505700|4807|0|Cash|0||N|TIME WARNE|N|2012-03-09 07:07:11
8057|2012-03-08|\N|32523|PAYMENT|\N|-1348.74|0|-1348.74|0|0|8057|1486|22|0|Cash|0||N|PACIFIC HA|N|2012-03-09 07:07:11
8103|2012-03-07|\N|32138|PAYMENT|\N|-1382.29|0|-1382.29|0|0|8103|3719|4|0|Cash|0||N|NORTH COUN|N|2012-03-09 07:07:11

Corresponding resultant records:

5830    2012-02-21      0000-00-00      29543   PAYMENT NULL    -600.5  0       0       0       -600.5  5830    505700  4807    0       Cash    0               N       TIME WARNE      N       2012-03-09 07:07:11
8057    2012-03-08      0000-00-00      32523   PAYMENT NULL    -1348.74        0       -1348.74        0       0       8057    1486    22      0       Cash    0               N       PACIFIC HA      N       2012-03-09 07:07:11
8103    2012-03-07      0000-00-00      32138   PAYMENT NULL    -1382.29        0       -1382.29        0       0       8103    3719    4       0       Cash    0               N       NORTH COUN      N       2012-03-09 07:07:11
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:13:54+00:00Added an answer on May 31, 2026 at 3:13 am

    If \N is being transformed into an empty string, then the INSERT command will use it, and the DEFAULT value will be ignored.

    I mean with this:

    INSERT INTO table(customer, date) VALUES ("123", "")
    

    then date will contain 0000-00-00. For the default value to be used, nothing should be passed for the date at all:

    INSERT INTO table(customer) VALUES ("123")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Perl script inserting data into Postgres according to a pipe delimited
I have a pipe delimited feed file which has several fields. Since I only
I have a flat file that is pipe delimited and an database table. I
I'm creating a BCP IN process to load a pipe delimited file into a
hi guys i have two pipe delimited files,first file contains 1000 records and second
If I have 2 pipe delimited files containing bookmark data, for example. How can
I have a file with fields separated by pipe characters and I want to
I have the need to parse through a large pipe-delimited file to count the
I am trying to save a pipe delimited text file into an excel worksheet
I am using VS2005 c#. I have this function for converting pipe delimited text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.