Error code: 1366 Incorrect integer value: ' Zhangsan ' for column ' Depart_teacher ' at row 1

Source: Internet
Author: User

1. Error description

1 queries executed, 0 success, 1 errors, 0 warnings

query: INSERT INTO EMP values (6, ' Woody ', 20, ' Male ')

error code: 1366
Incorr  ECT integer value: ' Zhangsan ' for column ' Depart_teacher ' at row 1

execution   Time: 0 sec
Delivery:   0 SEC
Total time-consuming      : 0 sec

2. Error reason

DELIMITER $$

CREATE
    /*[definer = {User | Current_User}]*/
    TRIGGER ' test '. ' Insert_data ' before insert on
    ' test '. ' emp ' for each
    ROW BEGIN
	INSERT into T_depart_info (id,depart_name,depart_teacher) VALUES (3, ' You ', ' Zhangsan ');
    end$$

DELIMITER;

INSERT into EMP VALUES (6, ' Woody ', 20, ' male ');

The data type of the third record inserted in the trigger is int, but the varchar type is inserted, resulting in an error


3. Solutions

(1) Change the Depart_teacher data type in the T_depart_info table from int to varchar

(2) Insert Depart_teacher in trigger by string to Integer

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.