49 users online (1 members and 48 guests)  


  Results 1 to 2 of 2

Related

  1. Replies: 3
  2. inserting css into php pages?    Forum: CSS Forum
    Replies: 10
  3. Inserting system calculator    Forum: HTML Forum
    Replies: 0
  4. Error inserting javascript into php    Forum: PHP Forum
    Replies: 14
  5. Inserting Html    Forum: HTML Forum
    Replies: 3
  1. #1
    amateur2005's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    2

    Load data infile and inserting timestamps automatically

    Hello all...

    I'm a TOTAL newbie to mysql.. have been trying to make my way through it.. I have a table "registered_tags" with 2 columns..

    1. reg_tags Varchar(16)
    2. time_reg integer

    Both are primary keys.. now i need to load the table with tags info (16 char string) and have the date and time of insertion of that tag info to be inserted into the time_reg column automatically when the tag info is inserted..

    My text file looks like this for now (made in windows) (space between fields is tab and lines are ending with '\r\n' <---- windows does that)

    0580000d76d112d9 1
    0580000d2c184c6a 2
    0580000decb3cf9c 3
    0580000d0897174b 4
    0580000d2552fbd5 5
    0580000d70ee065b 6
    0580000d0ad09ada 7


    I'm using the following query:

    load data infile 'expected.txt' into table registered_tags lines terminated by '\r\n'

    After execution of this query only the first row has data.. the rest of the rows dont get loaded !!

    Also right now i'm just using the time_reg column as an integer.. but i have to record the time in 'time_reg' when that row is inserted into the table for each row inserted.. how can i go about this ??


    Your help is much appreciated.. Thank you

    Aditi

  2. #2
    amateur2005's Avatar
    New User

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    2

    Re: Load data infile and inserting timestamps automatically

    I managed to sort out the load data file.. I get all 7 rows now.. One thing i'm wondering about..

    When I view the table contents, this is what i get :

    +------------------+----------------------+
    | Tags_Registered | Timestamp_Registered |
    +------------------+----------------------+
    | 0580000d0897174b | 4 |
    | 0580000d0ad09ada | 7 |
    | 0580000d2552fbd5 | 5 |
    | 0580000d2c184c6a | 2 |
    | 0580000d70ee065b | 6 |
    | 0580000d76d112d9 | 1 |
    | 0580000decb3cf9c | 3 |
    +------------------+----------------------+

    How come the 4th row in the text file got inserted into the table 1st although in the text file its 4th ?? and same for the rest of the rows like row 1 in text file is row 6 in the table ??

    Can someone pls guide how to go about inserting timestamps automatically into the timestamp_registered column whenever a new row is added ??



Tags for this Thread