SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Getting Error 1064 when trying to insert a row with 0 value

    I'm getting Error #1064 when i try to insert a record with 0 in a decimal field (the field name is "estimation") into my table.

    This is my query:
    Code:
    insert into needs(id_org,date_created,date_required,place_required,description,contact,phone,email, remarks, cur_id,estimation,user_id)
    values(2,'2011-01-31','2011-02-07','Place','test','Tom Jones','111-1234','','test',,0,2)
    This query works if the 'estimation' field has any other value except 0.

    Note that 'estimation' is set to DECIMAL(10,2)

    Can anyone assist??

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you aren't entering a value for cur_id, does it have a default value for the column?

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,215
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    you can't have two commas in a row like that
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Member
    Join Date
    Feb 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guelphdad View Post
    you aren't entering a value for cur_id, does it have a default value for the column?
    The default value for cur_id is NULL. The datatype is Integer.

  5. #5
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Then you either need to leave it out entirely or use NULL.

    Left out:
    Code:
    insert into needs(
    id_org, 
    date_created,
    date_required,
    place_required,
    description,
    contact,
    phone,
    email, 
    remarks, 
    estimation,
    user_id)
    values
    (2,'2011-01-31','2011-02-07','Place','test','Tom Jones','111-1234','test',0,2)
    OR WITH NULL

    Code:
    insert into needs(
    id_org, 
    date_created,
    date_required,
    place_required,
    description,
    contact,
    phone,
    email, 
    remarks, 
    cur_id,
    estimation,
    user_id)
    values
    (2,'2011-01-31','2011-02-07','Place','test','Tom Jones','111-1234','test',NULL,0,2)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •