MySQL Forums
Forum List  »  Stored Procedures

LOAD DATA INFILE issue with TRUE string
Posted by: Crazy Tasty
Date: November 18, 2010 09:07PM

Forgive me if I've posted this in the wrong area. I wasn't sure which area to use.

I have the code below in a stored procedure that will eventually accept the filename and an arg/param.

LOAD DATA INFILE 'C:/operators.csv' 
INTO TABLE fld.tbloperatorlist 
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\r\n' IGNORE 1 LINES
(PermitId,FirstName,LastName,MiddleInitial,DisplayFlag);

The problem is with the DisplayFlag field, which is defined in the DB as a TINYINT. As a bool it's obviously represented as a 1 in the DB.
In the file snippet (below the insert), the DisplayFlag field is represented as TRUE. Which is fine but it tries to insert it as a string "TRUE" instead of just TRUE when using the Bulk Load.
I proved this by testing with the following:
insert into tbloperatorlist
    (
        PermitId,
        LastName,
        FirstName,
        MiddleInitial,
        DisplayFlag
    )
    values
    (
        "10072297",
        "lastName",
        "firstName",
        "I",
        TRUE   
 );

But "TRUE" fails.

All I really need is for the load to think it's either TRUE or 1 instead of "TRUE".

Here is a snip of the .csv file:

PermitId,FirstName,LastName,MiddleInitial,DisplayFlag
10020079,EDWARD,HAMMEL,R,TRUE
10016212,DAVID,A P ANAYA,,TRUE
10002204,MAGNUS,AADLAND,,TRUE

I'm sure this is something really simple, but I've never used a Bulk Load in MySql where I can't dictate what the actual type is I'm trying to load/insert/update, etc, and I struggled with this for about 6 hours already.

Any help is appreciated...thanks to all.

ct

- Happiness is a belt fed weapon...

Options: ReplyQuote


Subject
Views
Written By
Posted
LOAD DATA INFILE issue with TRUE string
8033
November 18, 2010 09:07PM
2763
November 18, 2010 10:31PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.