shell调用无参数存储过程

注意:需要将结尾;做修改
delimiter #

# 编写存储过程
CREATE PROCEDURE create_tel()
BEGIN
    DECLARE id INT;
    SET id=10;
    WHILE id<20
	DO
	INSERT INTO td_test VALUES(id,'张三');
	SET id=id+1;
    END WHILE;

END#
#!/bin/sh
DIR="path"
DATE=$(date +%Y%m%d --date '1 days ago')
HOST='0.0.0.1'
USER='usm'
PASSWD='passwd'
port=3308
DATABASE='usmdb'
FILE=result.log
cd ${DIR}
echo "the date:"${DATE}
execSql="call create_tel()"
if mysql -h ${HOST} -P ${port} -u ${USER} -p'${PASSWD}' -D ${DATABASE} -e "${execSql}";then
    echo "login ok">>${FILE}
else
    echo "login fail">>${FILE}
fi

你可能感兴趣的:(sql,mysql,存储过程)