我想使用存储过程将一个joson数组插入表中。
我的程序是
DELIMITER $$
USE `calllog_db`$$
DROP PROCEDURE IF EXISTS `insert_call_log_history`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `insert_call_log_history`(IN UserId TEXT, PhoneNumber TEXT, IN DialedTime TEXT, IN ConnectedTime TEXT, IN DisconnectedTime TEXT, IN RecordedFile TEXT, IN CallType TEXT, IN CallSummary TEXT)
BEGIN
INSERT INTO `call_log` (`UserId`,`PhoneNumber`,`DialedTime`,`ConnectedTime`,`DisconnectedTime`,`RecordedFile`,`CallType`,`CallSummary`) VALUES (UserId,PhoneNumber,DialedTime,ConnectedTime,DisconnectedTime,RecordedFile,CallType,CallSummary);
SELECT LAST_INSERT_ID() AS LastInsertId;
END$$
DELIMITER ;
我的json数组是,
[ {"CallLogId":"1","UserId" :"1","PhoneNumber":"+917012535558","DialedTime":"2018-09-03 01:00:00","ConnectedTime":"2018-09-03 01:01:00","DisconnectedTime":"2018-09-03 01:05:00","RecordedFile":"","CallType":"Incomming","CallSummary":"Ring - receive -end"},
{"CallLogId":"1","UserId" :"1","PhoneNumber":"+917012535558","DialedTime":"2018-09-03 02:00:00","ConnectedTime":"2018-09-03 02:02:00","DisconnectedTime":"2018-09-03 02:06:00","RecordedFile":"","CallType":"Incomming","CallSummary":"Ring - receive -end"},
{"CallLogId":"1","UserId" :"1","PhoneNumber":"+917012535558","DialedTime":"2018-09-03 03:00:00","ConnectedTime":"2018-09-03 03:03:00","DisconnectedTime":"2018-09-03 03:07:00","RecordedFile":"","CallType":"Incomming","CallSummary":"Ring - receive -end"},
{"CallLogId":"1","UserId" :"1","PhoneNumber":"+917012535558","DialedTime":"2018-09-03 04:00:00","ConnectedTime":"2018-09-03 04:04:00","DisconnectedTime":"2018-09-03 04:08:00","RecordedFile":"","CallType":"Incomming","CallSummary":"Ring - receive -end"}]
我们如何将此数组插入数据库