1

我在 MySQL 中不断收到此警告,但不知道为什么。下面提供的功能。

Warning | 1329 | No data - zero rows fetched, selected, or processed

功能:

CREATE FUNCTION CONTACT_INFO_EXISTS(
    hp VARCHAR(64),
    wp VARCHAR(32),
    mp VARCHAR(32),
    f VARCHAR(32),
    pe VARCHAR(64),
    se VARCHAR(64),
    c TIMESTAMP
)
RETURNS VARCHAR(36)
READS SQL DATA
BEGIN
    DECLARE c_id CHAR(36);

    SET c_id = NULL;

    SELECT contact_infouuid INTO c_id FROM contact_info
        WHERE (home_phone = hp OR hp IS NULL)
            AND (work_phone = wp OR wp IS NULL)
            AND (mobile_phone = mp OR mp IS NULL)
            AND (fax = f OR f IS NULL)
            AND (primary_email = pe OR pe IS NULL)
            AND (secondary_email = se OR se IS NULL)
            AND (last_updated = c OR c IS NULL)
        LIMIT 1;

    RETURN IF(c_id IS NOT NULL, c_id, '0');
END$$
4

1 回答 1

0

尝试这个:

CREATE FUNCTION CONTACT_INFO_EXISTS(
    hp VARCHAR(64),
    wp VARCHAR(32),
    mp VARCHAR(32),
    f VARCHAR(32),
    pe VARCHAR(64),
    se VARCHAR(64),
    c TIMESTAMP
)
RETURNS VARCHAR(36)
READS SQL DATA
BEGIN
    DECLARE c_id CHAR(36);

    SET c_id = NULL;

     IF EXISTS (SELECT * FROM contact_info
                  WHERE (home_phone = hp OR hp IS NULL)
                        AND (work_phone = wp OR wp IS NULL)
                        AND (mobile_phone = mp OR mp IS NULL)
                        AND (fax = f OR f IS NULL)
                        AND (primary_email = pe OR pe IS NULL)
                        AND (secondary_email = se OR se IS NULL)
                        AND (last_updated = c OR c IS NULL)) THEN 
         SELECT contact_infouuid INTO c_id FROM contact_info
              WHERE (home_phone = hp OR hp IS NULL)
                    AND (work_phone = wp OR wp IS NULL)
                    AND (mobile_phone = mp OR mp IS NULL)
                    AND (fax = f OR f IS NULL)
                    AND (primary_email = pe OR pe IS NULL)
                    AND (secondary_email = se OR se IS NULL)
                    AND (last_updated = c OR c IS NULL)
              LIMIT 1;
     END IF;
    RETURN IF(c_id IS NOT NULL, c_id, '0');
END$$
于 2012-12-08T18:14:32.067 回答