-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `mtm_dashboard`
--

-- --------------------------------------------------------

--
-- Stand-in structure for view `order_details_extracted`
-- (See below for the actual view)
--
CREATE TABLE `order_details_extracted` (
`id` int(11)
,`timestamp` datetime(3)
,`user_id` varchar(50)
,`log_date` date
,`Txn` mediumtext
,`extracted_user` mediumtext
,`qty` mediumtext
,`leg_id` mediumtext
,`symbol` mediumtext
,`isexit` mediumtext
,`exitsl` mediumtext
,`OrderType` mediumtext
,`AtBroker` mediumtext
,`portfolio` mediumtext
);

-- --------------------------------------------------------

--
-- Structure for view `order_details_extracted`
--

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `order_details_extracted`  AS SELECT `logs`.`id` AS `id`, `logs`.`timestamp` AS `timestamp`, `logs`.`user_id` AS `user_id`, `logs`.`log_date` AS `log_date`, trim(substring_index(substring_index(`logs`.`message`,'Txn:',-1),';',1)) AS `Txn`, trim(substring_index(substring_index(`logs`.`message`,'User:',-1),';',1)) AS `extracted_user`, trim(substring_index(substring_index(`logs`.`message`,'Qty:',-1),';',1)) AS `qty`, trim(substring_index(substring_index(`logs`.`message`,'Leg ID:',-1),';',1)) AS `leg_id`, trim(substring_index(substring_index(`logs`.`message`,'Symbol:',-1),';',1)) AS `symbol`, trim(substring_index(substring_index(`logs`.`message`,'IsExit:',-1),';',1)) AS `isexit`, trim(substring_index(substring_index(`logs`.`message`,'ExitSL:',-1),';',1)) AS `exitsl`, trim(substring_index(substring_index(`logs`.`message`,'OrderType:',-1),';',1)) AS `OrderType`, trim(substring_index(substring_index(`logs`.`message`,'AtBroker:',-1),';',1)) AS `AtBroker`, trim(substring_index(substring_index(`logs`.`message`,'Portfolio:',-1),';',1)) AS `portfolio` FROM `logs` WHERE `logs`.`message` like '%Initiating Order Placement for User%' AND `logs`.`message` like '%Qty:%' ;


--
-- Metadata
--
USE `phpmyadmin`;

--
-- Metadata for table order_details_extracted
--

--
-- Metadata for database mtm_dashboard
--
COMMIT;

