이름 출력 쿼리(feat. heidisql string+int)
SET nC = CONCAT('CT0',CAST(t_INT AS CHAR(10)));
##CONCAT('string','string');
int to string??
CAST(int as char(10));
DELIMITER $$
DROP PROCEDURE IF EXISTS query_test $$
CREATE PROCEDURE query_test(IN var INT)
BEGIN
DECLARE nCnt INT DEFAULT 0;
DECLARE t_INT INT DEFAULT 10100;
DECLARE nC varchar(100) DEFAULT 'CT0';
WHILE (nCnt < var) DO
SET nCnt = nCnt + 1;
SET t_INT = t_INT + 1;
SET nC = CONCAT('CT0',CAST(t_INT AS CHAR(10)));
SELECT nC;
# SELECT nC AS 결과;
END WHILE;
END $$
DELIMITER ;
UPGRADE 직접 INSERT하는 프로시져
DELIMITER $$
DROP PROCEDURE IF EXISTS query_test $$
CREATE PROCEDURE query_test(IN var INT)
BEGIN
DECLARE nCnt INT DEFAULT 0;
DECLARE t_INT INT DEFAULT 10100;
DECLARE nC varchar(100) DEFAULT 'CT0';
WHILE (nCnt < var) DO
SET nCnt = nCnt + 1;
SET t_INT = t_INT + 1;
SET nC = CONCAT('CT0',CAST(t_INT AS CHAR(10)));
//assembly_usedtime에 해당하는 데이터를넣는다
INSERT INTO assembly_usedtime VALUES(nC,100,DEFAULT,200,100,RAND()*(10000-9700)+9700,100);
SELECT nC;
# SELECT nC AS 결과;
END WHILE;
END $$
DELIMITER ;
//RANDOM VALUE 사용법
number >= min and <max
RAND()*(max-min)+min
number >= 9700 and <10000
RAND()*(10000-9700)+9700
댓글 없음:
댓글 쓰기