Mysql хранимая процедура для вставки запроса + массив json - PullRequest
0 голосов
/ 04 сентября 2018

Я хочу вставить массив 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"}]

Как мы можем вставить этот массив в базу данных

...