{\rtf1\ansi\ansicpg1252\cocoartf2636
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 .AppleSystemUIFontMonospaced-Bold;\f1\fnil\fcharset0 .AppleSystemUIFontMonospaced-Regular;}
{\colortbl;\red255\green255\blue255;\red10\green22\blue51;\red255\green255\blue254;\red0\green0\blue0;
\red100\green117\blue135;\red24\green24\blue24;\red81\green59\blue178;\red251\green0\blue7;\red251\green0\blue255;
}
{\*\expandedcolortbl;;\cssrgb\c3529\c11765\c25882;\cssrgb\c100000\c100000\c99608;\cssrgb\c0\c0\c0;
\cssrgb\c46667\c53333\c60000;\cssrgb\c12549\c12549\c12549;\cssrgb\c39608\c32941\c75294;\cssrgb\c100000\c0\c0;\cssrgb\c100000\c0\c100000;
}
\margl1440\margr1440\vieww34360\viewh19160\viewkind0
\deftab720
\pard\pardeftab720\partightenfactor0

\f0\b\fs26 \cf2 \cb3 \expnd0\expndtw0\kerning0
\outl0\strokewidth0 \strokec2 \
DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 CreateSystemRecord\cf0 \strokec4 ;\cb1 \
\
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 CREATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DEFINER\cf5 \strokec5 =\cf0 \strokec4 `
\f0\b \cf2 \strokec2 root
\f1\b0 \cf0 \strokec4 `\cf6 \strokec6 @\cf0 \strokec4 `\cf6 \strokec6 localhost\cf0 \strokec4 ` 
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 CreateSystemRecord\cf0 \strokec4 (\cf6 \strokec6 IN_CONTEXTID\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 50\cf0 \strokec4 ), \cf6 \strokec6 IN_CHANNELID\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_ASSETPROFILE\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 500\cf0 \strokec4 ),\cb1 \
\pard\pardeftab720\partightenfactor0
\cf0 \cb3     \cf6 \strokec6 IN_PROGRAMEXTERNALID\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 20\cf0 \strokec4 ), \cf6 \strokec6 IN_PROGRAMSTARTTIME\cf0 \strokec4  
\f0\b \cf2 \strokec2 bigint
\f1\b0 \cf0 \strokec4 ,\cf6 \strokec6 IN_PROGRAMDURATION\cf0 \strokec4  
\f0\b \cf2 \strokec2 int
\f1\b0 \cf0 \strokec4 ,\cf6 \strokec6 IN_RECORDINGDURATION\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 ,\cf6 \strokec6 IN_ENABLENPVRTRICKPLAY\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 ,\cb1 \
\cb3     \cf6 \strokec6 IN_ENABLENPVRSKIPJUMP\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 ,\cf6 \strokec6 IN_EVENTUPDATESTATUS\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 10\cf0 \strokec4 ),\cf6 \strokec6 IN_SCHEDULEQUALIFIER1\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 640\cf0 \strokec4 ),\cf6 \strokec6 IN_SCHEDULEQUALIFIER2\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 640\cf0 \strokec4 ),\cb1 \
\cb3     \cf6 \strokec6 IN_SCHEDULEQUALIFIER3\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 640\cf0 \strokec4 ),\cf6 \strokec6 IN_SCHEDULEQUALIFIER4\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 640\cf0 \strokec4 )\cb1 \
\cb3     ,\cf6 \strokec6 IN_SCHEDULEQUALIFIER5\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 640\cf0 \strokec4 ),\cf6 \strokec6 IN_CHANNELLANGUAGE\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 20\cf0 \strokec4 ),\cf6 \strokec6 IN_RECORDINGSTARTTIME\cf0 \strokec4  
\f0\b \cf2 \strokec2 bigint
\f1\b0 \cf0 \strokec4 ,\cb1 \
\cb3     \cf6 \strokec6 IN_PROGRAMDETAILRECORD\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 2000\cf0 \strokec4 ), \cf6 \strokec6 IN_EPISODEID\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 5\cf0 \strokec4 ), \cf6 \strokec6 IN_SERIESREFERENCE\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 15\cf0 \strokec4 ),\cb1 \
\cb3     \cf6 \strokec6 IN_programtitle\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 128\cf0 \strokec4 ), \cf6 \strokec6 IN_BLACK_LISTED_MDP\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 500\cf0 \strokec4 ), \cf6 \strokec6 EPISODESCOPE\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 5\cf0 \strokec4 ),\cb1 \
\cb3     
\f0\b \cf2 \strokec2 OUT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_RECORDID\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_CURRENTTIME\cf0 \strokec4  
\f0\b \cf2 \strokec2 BIGINT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_HTTPPATH\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 256\cf0 \strokec4 ), \cf6 \strokec6 IN_MSSPPATH\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 256\cf0 \strokec4 ), \cf6 \strokec6 IN_RECPATH3GP\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 256\cf0 \strokec4 ),\cb1 \
\cb3     \cf6 \strokec6 IN_ENABLEPRIVATECOPY\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_SCHEDULEID\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 256\cf0 \strokec4 ), \cf6 \strokec6 IN_CHANNELREFNUMBER\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 50\cf0 \strokec4 ), \cf6 \strokec6 IN_ISMEDIATORDISABLE\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 ,\cb1 \
\cb3     \cf6 \strokec6 IN_CHANNEL_SCHEDULEID_MAPPING\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 4000\cf0 \strokec4 ), \cf6 \strokec6 IN_COPY_PROTECTIONS\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 256\cf0 \strokec4 ), \cf6 \strokec6 IN_EXCLUDED_PLATFORMS\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 100\cf0 \strokec4 ))\cb1 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 BEGIN
\f1\b0 \cf0 \cb1 \strokec4 \
\
\pard\pardeftab720\partightenfactor0
\cf0 \cb3   
\f0\b \cf2 \strokec2 DECLARE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 PID\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 ;\cb1 \
\cb3   
\f0\b \cf2 \strokec2 DECLARE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 NPVRASSETCOUNT\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 ;\cb1 \
\cb3   
\f0\b \cf2 \strokec2 DECLARE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 V_STATUS\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 20\cf0 \strokec4 );\cb1 \
\cb3   
\f0\b \cf2 \strokec2 DECLARE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 V_STATUS_DETAILS\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 20\cf0 \strokec4 );\cb1 \
\
\cb3     
\f0\b \cf2 \strokec2 DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 TABLE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 ASSET_DATA\cf0 \strokec4 ;\cb1 \
\cb3     
\f0\b \cf2 \strokec2 CREATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 temporary\cf0 \strokec4  
\f0\b \cf2 \strokec2 TABLE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 ASSET_DATA\cf0 \strokec4  \cf6 \strokec6 engine\cf5 \strokec5 =\cf6 \strokec6 memory\cf0 \cb1 \strokec4 \
\
\cb3     
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 *\cf0 \strokec4  
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  (\cb1 \
\cb3     
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 ch\cf0 \strokec4 .\cf6 \strokec6 CHANNELID\cf0 \strokec4  \cf5 \strokec5 <>\cf0 \strokec4  \cf6 \strokec6 IN_CHANNELID\cf0 \strokec4 , \cf6 \strokec6 findScheduleId\cf0 \strokec4 (
\f0\b \cf2 \strokec2 CONCAT
\f1\b0 \cf0 \strokec4 (\cf8 \cb3 \strokec8 'INCLUDEDID_'\cf0 \cb3 \strokec4 , \cf6 \strokec6 ch\cf0 \strokec4 .\cf6 \strokec6 CHANNELEXTERNALID\cf0 \strokec4 ), \cf6 \strokec6 IN_CHANNEL_SCHEDULEID_MAPPING\cf0 \strokec4 ), \cf6 \strokec6 IN_SCHEDULEID\cf0 \strokec4 ) \cf6 \strokec6 ASSET_SCHEDULEID\cf0 \strokec4 ,\cb1 \
\cb3     \cf6 \strokec6 externalID\cf0 \strokec4 , \cf6 \strokec6 parentexternalID\cf0 \strokec4 , \cf6 \strokec6 ACCESSURL\cf0 \strokec4 , \cf6 \strokec6 MULTICASTIP\cf0 \strokec4 , \cf6 \strokec6 MULTICASTPORT\cf0 \strokec4 , \cf6 \strokec6 RECSUBSYSTEM\cf0 \strokec4 , \cf6 \strokec6 RECORDINGPATH\cf0 \strokec4 ,\cf6 \strokec6 ch\cf0 \strokec4 .\cf6 \strokec6 ASSETPROFILE\cf0 \strokec4 , \cf6 \strokec6 ch\cf0 \strokec4 .\cf6 \strokec6 CHANNELEXTERNALID\cf0 \cb1 \strokec4 \
\cb3     
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  (
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 channelID\cf0 \strokec4 , \cf6 \strokec6 mtp\cf0 \strokec4 .\cf6 \strokec6 externalID\cf0 \strokec4 , \cf6 \strokec6 mtp\cf0 \strokec4 .\cf6 \strokec6 parentexternalID\cf0 \strokec4 , \cf6 \strokec6 ACCESSURL\cf0 \strokec4 , \cf6 \strokec6 MULTICASTIP\cf0 \strokec4 ,\cb1 \
\cb3     \cf6 \strokec6 MULTICASTPORT\cf0 \strokec4 , (\cf6 \strokec6 mtp\cf0 \strokec4 .\cf6 \strokec6 RECORDINGSUBSYSTEM\cf0 \strokec4 ) \cf6 \strokec6 RECSUBSYSTEM\cf0 \strokec4 , \cf6 \strokec6 mtp\cf0 \strokec4 .\cf6 \strokec6 RECORDINGPATH\cf0 \cb1 \strokec4 \
\cb3     
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  (
\f0\b \cf2 \strokec2 select
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 distinct
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 c\cf0 \strokec4 .\cf6 \strokec6 mtpexternalid\cf0 \strokec4 , \cf6 \strokec6 c\cf0 \strokec4 .\cf6 \strokec6 ACCESSURL\cf0 \strokec4 , \cf6 \strokec6 c\cf0 \strokec4 .\cf6 \strokec6 MULTICASTIP\cf0 \strokec4 , \cf6 \strokec6 c\cf0 \strokec4 .\cf6 \strokec6 MULTICASTPORT\cf0 \strokec4 , \cf6 \strokec6 c\cf0 \strokec4 .\cf6 \strokec6 CHANNELID\cf0 \cb1 \strokec4 \
\cb3     
\f0\b \cf2 \strokec2 from
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 CHANNELSTREAM\cf0 \strokec4  \cf6 \strokec6 c\cf0 \cb1 \strokec4 \
\cb3     \cf5 \strokec5 INNER\cf0 \strokec4  \cf5 \strokec5 JOIN\cf0 \strokec4  \cf6 \strokec6 CHANNELSTREAMMAPPING\cf0 \strokec4  \cf6 \strokec6 csm\cf0 \cb1 \strokec4 \
\cb3     
\f0\b \cf2 \strokec2 ON
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 c\cf0 \strokec4 .\cf6 \strokec6 channelID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 csm\cf0 \strokec4 .\cf6 \strokec6 channelId\cf0 \strokec4  \cf5 \strokec5 and\cf0 \cb1 \strokec4 \
\cb3     \cf6 \strokec6 c\cf0 \strokec4 .\cf6 \strokec6 mtpexternalid\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 csm\cf0 \strokec4 .\cf6 \strokec6 MTPEXTERNALID\cf0 \cb1 \strokec4 \
\cb3     
\f0\b \cf2 \strokec2 where
\f1\b0 \cf0 \strokec4  (\cf6 \strokec6 c\cf0 \strokec4 .\cf6 \strokec6 channelid\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_CHANNELID\cf0 \cb1 \strokec4 \
\cb3     \cf5 \strokec5 OR\cf0 \strokec4  \cf6 \strokec6 c\cf0 \strokec4 .\cf6 \strokec6 channelID\cf0 \strokec4  \cf5 \strokec5 IN\cf0 \strokec4  (
\f0\b \cf2 \strokec2 select
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 INCLUDEDCHANNELID\cf0 \strokec4  
\f0\b \cf2 \strokec2 from
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 INCLUDEDCHANNELS\cf0 \strokec4  \cf6 \strokec6 ic\cf0 \strokec4  
\f0\b \cf2 \strokec2 where
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 ic\cf0 \strokec4 .\cf6 \strokec6 CHANNELID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_CHANNELID\cf0 \strokec4 ))\cb1 \
\cb3     \cf5 \strokec5 AND\cf0 \strokec4  \cf5 \strokec5 NOT\cf0 \strokec4  \cf6 \strokec6 find_in_set\cf0 \strokec4 (\cf6 \strokec6 csm\cf0 \strokec4 .\cf6 \strokec6 MDPEXTERNALID\cf0 \strokec4 , \cf6 \strokec6 IN_BLACK_LISTED_MDP\cf0 \strokec4 )\cb1 \
\cb3     \cf5 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 c\cf0 \strokec4 .\cf6 \strokec6 ENABLENPVR\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 1\cf0 \strokec4 )\cb1 \
\cb3     \cf6 \strokec6 T\cf0 \strokec4  \cf5 \strokec5 INNER\cf0 \strokec4  \cf5 \strokec5 JOIN\cf0 \strokec4  \cf6 \strokec6 MEDIATYPEPROFILES\cf0 \strokec4  \cf6 \strokec6 mtp\cf0 \cb1 \strokec4 \
\cb3     
\f0\b \cf2 \strokec2 ON
\f1\b0 \cf0 \strokec4  (\cf6 \strokec6 T\cf0 \strokec4 .\cf6 \strokec6 mtpexternalid\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 mtp\cf0 \strokec4 .\cf6 \strokec6 externalid\cf0 \cb1 \strokec4 \
\cb3     \cf5 \strokec5 OR\cf0 \strokec4  \cf6 \strokec6 T\cf0 \strokec4 .\cf6 \strokec6 MTPEXTERNALID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 mtp\cf0 \strokec4 .\cf6 \strokec6 PARENTEXTERNALID\cf0 \strokec4 )\cb1 \
\cb3     
\f0\b \cf2 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 mtp\cf0 \strokec4 .\cf6 \strokec6 CONTEXTID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_CONTEXTID\cf0 \strokec4 ) \cf6 \strokec6 TEMP\cf0 \cb1 \strokec4 \
\cb3     \cf5 \strokec5 INNER\cf0 \strokec4  \cf5 \strokec5 JOIN\cf0 \strokec4  \cf6 \strokec6 CHANNEL\cf0 \strokec4  \cf6 \strokec6 ch\cf0 \cb1 \strokec4 \
\cb3     
\f0\b \cf2 \strokec2 ON
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 TEMP\cf0 \strokec4 .\cf6 \strokec6 CHANNELID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 ch\cf0 \strokec4 .\cf6 \strokec6 CHANNELID\cf0 \cb1 \strokec4 \
\cb3     
\f0\b \cf2 \strokec2 ORDER
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 BY
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 ch\cf0 \strokec4 .\cf6 \strokec6 CHANNELID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_CHANNELID\cf0 \strokec4 , \cf7 \strokec7 0\cf0 \strokec4 , \cf7 \strokec7 1\cf0 \strokec4 )\cb1 \
\cb3     ) \cf6 \strokec6 TEMP\cf0 \strokec4  
\f0\b \cf2 \strokec2 GROUP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 BY
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 EXTERNALID\cf0 \strokec4 ;\cb1 \
\
\cb3     
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf9 \strokec9 COUNT\cf0 \strokec4 (\cf5 \strokec5 *\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 NPVRASSETCOUNT\cf0 \strokec4  
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 ASSET_DATA\cf0 \strokec4 ;\cb1 \
\
\cb3     
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  (\cf6 \strokec6 NPVRASSETCOUNT\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \
\cb3         
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_RECORDID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ;\cb1 \
\cb3     
\f0\b \cf2 \strokec2 ELSE
\f1\b0 \cf0 \cb1 \strokec4 \
\
\cb3         
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 PROGRAMID\cf0 \strokec4  
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 PID\cf0 \cb1 \strokec4 \
\cb3         
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 PROGRAMDETAILS\cf0 \cb1 \strokec4 \
\cb3         
\f0\b \cf2 \strokec2 WHERE
\f1\b0 \cf0 \strokec4   \cf6 \strokec6 CONTEXTID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_CONTEXTID\cf0 \cb1 \strokec4 \
\cb3         \cf5 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 PROGRAMEXTERNALID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_PROGRAMEXTERNALID\cf0 \strokec4 ;\cb1 \
\
\cb3         
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 PID\cf0 \strokec4  \cf5 \strokec5 IS\cf0 \strokec4  \cf5 \strokec5 NULL\cf0 \strokec4  
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \
\cb3         
\f0\b \cf2 \strokec2 INSERT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 IGNORE\cf0 \strokec4  
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 PROGRAMDETAILS\cf0 \strokec4  (\cf6 \strokec6 ProgramExternalID\cf0 \strokec4 , \cf6 \strokec6 contextID\cf0 \strokec4 , \cf6 \strokec6 episodeID\cf0 \strokec4 , \cf6 \strokec6 SERIESREFERENCE\cf0 \strokec4 , \cf6 \strokec6 programtitle\cf0 \strokec4 , \cf6 \strokec6 PROGRAMDETAILRECORD\cf0 \strokec4 , \cf6 \strokec6 ENABLEINDIVIDUALCOPY\cf0 \strokec4 )\cb1 \
\cb3         
\f0\b \cf2 \strokec2 Values
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 IN_PROGRAMEXTERNALID\cf0 \strokec4 , \cf6 \strokec6 IN_CONTEXTID\cf0 \strokec4 , \cf6 \strokec6 IN_EPISODEID\cf0 \strokec4 , \cf6 \strokec6 IN_SERIESREFERENCE\cf0 \strokec4 , \cf6 \strokec6 IN_programtitle\cf0 \strokec4 , \cf6 \strokec6 IN_PROGRAMDETAILRECORD\cf0 \strokec4 , \cf6 \strokec6 IN_ENABLEPRIVATECOPY\cf0 \strokec4 );\cb1 \
\cb3         
\f0\b \cf2 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\
\cb3         
\f0\b \cf2 \strokec2 INSERT
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 SYSTEMNPVRRECORDING\cf0 \cb1 \strokec4 \
\cb3         (\cf6 \strokec6 CHANNELID\cf0 \strokec4 ,\cf6 \strokec6 PROGRAMEXTERNALID\cf0 \strokec4 ,\cf6 \strokec6 CONTEXTID\cf0 \strokec4 ,\cf6 \strokec6 PROGRAMSTARTTIME\cf0 \strokec4 ,\cf6 \strokec6 PROGRAMDURATION\cf0 \strokec4 ,\cf6 \strokec6 RECORDINGDURATION\cf0 \strokec4 ,\cf6 \strokec6 ENABLENPVRTRICKPLAY\cf0 \strokec4 ,\cb1 \
\cb3         \cf6 \strokec6 ENABLENPVRSKIPJUMP\cf0 \strokec4 ,\cf6 \strokec6 EVENTUPDATESTATUS\cf0 \strokec4 ,\cf6 \strokec6 SCHEDULEQUALIFIER1\cf0 \strokec4 ,\cf6 \strokec6 SCHEDULEQUALIFIER2\cf0 \strokec4 ,\cf6 \strokec6 SCHEDULEQUALIFIER3\cf0 \strokec4 ,\cf6 \strokec6 SCHEDULEQUALIFIER4\cf0 \cb1 \strokec4 \
\cb3         ,\cf6 \strokec6 SCHEDULEQUALIFIER5\cf0 \strokec4 ,\cf6 \strokec6 CHANNELLANGUAGE\cf0 \strokec4 ,\cf6 \strokec6 RECORDINGSTARTTIME\cf0 \strokec4 ,\cf6 \strokec6 EPISODESCOPE\cf0 \strokec4 , \cf6 \strokec6 SYSREQUESTEDEPISODE\cf0 \strokec4 , \cf6 \strokec6 SCHEDULEID\cf0 \strokec4 , \cf6 \strokec6 CHANNELREFNUMBER\cf0 \strokec4 , \cf6 \strokec6 COPYPROTECTIONS\cf0 \strokec4 , \cf6 \strokec6 EXCLUDEDPLATFORMS\cf0 \strokec4 )\cb1 \
\cb3         
\f0\b \cf2 \strokec2 VALUES
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 IN_CHANNELID\cf0 \strokec4 ,\cf6 \strokec6 IN_PROGRAMEXTERNALID\cf0 \strokec4 ,\cf6 \strokec6 IN_CONTEXTID\cf0 \strokec4 ,\cf6 \strokec6 IN_PROGRAMSTARTTIME\cf0 \strokec4 ,\cf6 \strokec6 IN_PROGRAMDURATION\cf0 \strokec4 ,\cf6 \strokec6 IN_RECORDINGDURATION\cf0 \strokec4 ,\cf6 \strokec6 IN_ENABLENPVRTRICKPLAY\cf0 \strokec4 ,\cb1 \
\cb3         \cf6 \strokec6 IN_ENABLENPVRSKIPJUMP\cf0 \strokec4 ,\cf6 \strokec6 IN_EVENTUPDATESTATUS\cf0 \strokec4 ,\cf6 \strokec6 IN_SCHEDULEQUALIFIER1\cf0 \strokec4 ,\cf6 \strokec6 IN_SCHEDULEQUALIFIER2\cf0 \strokec4 ,\cf6 \strokec6 IN_SCHEDULEQUALIFIER3\cf0 \strokec4 ,\cf6 \strokec6 IN_SCHEDULEQUALIFIER4\cf0 \cb1 \strokec4 \
\cb3         ,\cf6 \strokec6 IN_SCHEDULEQUALIFIER5\cf0 \strokec4 ,\cf6 \strokec6 IN_CHANNELLANGUAGE\cf0 \strokec4 ,\cf6 \strokec6 IN_RECORDINGSTARTTIME\cf0 \strokec4 ,\cf6 \strokec6 EPISODESCOPE\cf0 \strokec4 , 
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 EVENTUPDATESTATUS\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf8 \cb3 \strokec8 'Complete'\cf0 \cb3 \strokec4 , \cf7 \strokec7 1\cf0 \strokec4 , \cf7 \strokec7 0\cf0 \strokec4 ), \cf6 \strokec6 IN_SCHEDULEID\cf0 \strokec4 , \cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\cf6 \strokec6 IN_CHANNELREFNUMBER\cf0 \strokec4 , \cf6 \strokec6 IN_COPY_PROTECTIONS\cf0 \strokec4 , \cf6 \strokec6 IN_EXCLUDED_PLATFORMS\cf0 \strokec4 );\cb1 \
\
\cb3         
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 LAST_INSERT_ID\cf0 \strokec4 () 
\f0\b \cf2 \strokec2 into
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_RECORDID\cf0 \strokec4 ;\cb1 \
\
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  (\cf6 \strokec6 IN_ISMEDIATORDISABLE\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 1\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  ((\cf6 \strokec6 UNIX_TIMESTAMP\cf0 \strokec4 () \cf5 \strokec5 *\cf0 \strokec4  \cf7 \strokec7 1000\cf0 \strokec4 ) \cf5 \strokec5 >\cf0 \strokec4  \cf6 \strokec6 IN_RECORDINGSTARTTIME\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 V_STATUS\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 "RecordFailed"\cf0 \strokec4 ;\cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 V_STATUS_DETAILS\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 "Recording Failed"\cf0 \strokec4 ;\cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 ELSE
\f1\b0 \cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 V_STATUS\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 "ScheduleSuccess"\cf0 \strokec4 ;\cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 V_STATUS_DETAILS\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 "Schedule Success"\cf0 \strokec4 ;\cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 ELSE
\f1\b0 \cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 V_STATUS\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 "Scheduling"\cf0 \strokec4 ;\cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 V_STATUS_DETAILS\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 "Scheduling"\cf0 \strokec4 ;\cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\
\
\cb3         
\f0\b \cf2 \strokec2 INSERT
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 NPVRASSET\cf0 \strokec4  (\cf6 \strokec6 RECORDID\cf0 \strokec4 , \cf6 \strokec6 MTPExternalID\cf0 \strokec4 , 
\f0\b \cf2 \strokec2 STATUS
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 STATUSDETAIL\cf0 \strokec4 , \cf6 \strokec6 ASSETSTARTDELTA\cf0 \strokec4 , \cf6 \strokec6 ASSETPROFILE\cf0 \strokec4 , \cf6 \strokec6 ASSETURL\cf0 \strokec4 , \cf6 \strokec6 ASSETSTARTTIME\cf0 \strokec4 , \cf6 \strokec6 SCHEDULEID\cf0 \strokec4 , \cf6 \strokec6 CHANNELEXTERNALID\cf0 \strokec4 )\cb1 \
\cb3         
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_RECORDID\cf0 \strokec4 , \cf6 \strokec6 externalID\cf0 \strokec4 , \cf6 \strokec6 V_STATUS\cf0 \strokec4 , \cf6 \strokec6 V_STATUS_DETAILS\cf0 \strokec4 , \cf7 \strokec7 0\cf0 \strokec4 , \cf6 \strokec6 ASSETPROFILE\cf0 \strokec4 ,\cb1 \
\cb3         \cf6 \strokec6 generateRecordFileName\cf0 \strokec4 (\cf6 \strokec6 RECSUBSYSTEM\cf0 \strokec4 , \cf6 \strokec6 ACCESSURL\cf0 \strokec4 , \cf6 \strokec6 MULTICASTIP\cf0 \strokec4 , \cf6 \strokec6 MULTICASTPORT\cf0 \strokec4 , \cf6 \strokec6 IN_RECORDINGSTARTTIME\cf0 \strokec4 , \cf6 \strokec6 RECORDINGPATH\cf0 \strokec4 ,\cf6 \strokec6 IN_HTTPPATH\cf0 \strokec4 , \cf6 \strokec6 IN_MSSPPATH\cf0 \strokec4 , \cf6 \strokec6 IN_RECPATH3GP\cf0 \strokec4 ,\cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\cf6 \strokec6 IN_PROGRAMSTARTTIME\cf0 \strokec4 , \cf6 \strokec6 IN_RECORDINGDURATION\cf0 \strokec4 , \cf6 \strokec6 IN_PROGRAMEXTERNALID\cf0 \strokec4 ), \cf6 \strokec6 IN_RECORDINGSTARTTIME\cf0 \strokec4 , \cf6 \strokec6 ASSET_SCHEDULEID\cf0 \strokec4 , \cf6 \strokec6 CHANNELEXTERNALID\cf0 \cb1 \strokec4 \
\cb3         
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 ASSET_DATA\cf0 \cb1 \strokec4 \
\cb3         
\f0\b \cf2 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 parentexternalID\cf0 \strokec4  \cf5 \strokec5 IS\cf0 \strokec4  \cf5 \strokec5 NULL\cf0 \strokec4 ;\cb1 \
\
\cb3         
\f0\b \cf2 \strokec2 INSERT
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 NPVRASSET\cf0 \strokec4  (\cf6 \strokec6 RECORDID\cf0 \strokec4 , \cf6 \strokec6 MTPExternalID\cf0 \strokec4 , 
\f0\b \cf2 \strokec2 STATUS
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 STATUSDETAIL\cf0 \strokec4 , \cf6 \strokec6 ASSETSTARTDELTA\cf0 \strokec4 , \cf6 \strokec6 ASSETPROFILE\cf0 \strokec4 , \cf6 \strokec6 ASSETURL\cf0 \strokec4 , \cf6 \strokec6 PARENTASSETID\cf0 \strokec4 , \cf6 \strokec6 ASSETSTARTTIME\cf0 \strokec4 , \cf6 \strokec6 SCHEDULEID\cf0 \strokec4 , \cf6 \strokec6 CHANNELEXTERNALID\cf0 \strokec4 )\cb1 \
\cb3         
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_RECORDID\cf0 \strokec4 , \cf6 \strokec6 externalID\cf0 \strokec4 , \cf6 \strokec6 V_STATUS\cf0 \strokec4 , \cf6 \strokec6 V_STATUS_DETAILS\cf0 \strokec4 , \cf7 \strokec7 0\cf0 \strokec4 , \cf6 \strokec6 ASSETPROFILE\cf0 \strokec4 ,\cb1 \
\cb3         \cf6 \strokec6 generateRecordFileName\cf0 \strokec4 (\cf6 \strokec6 RECSUBSYSTEM\cf0 \strokec4 , \cf6 \strokec6 ACCESSURL\cf0 \strokec4 , \cf6 \strokec6 MULTICASTIP\cf0 \strokec4 , \cf6 \strokec6 MULTICASTPORT\cf0 \strokec4 , \cf6 \strokec6 IN_RECORDINGSTARTTIME\cf0 \strokec4 , \cf6 \strokec6 RECORDINGPATH\cf0 \strokec4 ,\cf6 \strokec6 IN_HTTPPATH\cf0 \strokec4 , \cf6 \strokec6 IN_MSSPPATH\cf0 \strokec4 , \cf6 \strokec6 IN_RECPATH3GP\cf0 \strokec4 ,\cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\cf6 \strokec6 IN_PROGRAMSTARTTIME\cf0 \strokec4 , \cf6 \strokec6 IN_RECORDINGDURATION\cf0 \strokec4 , \cf6 \strokec6 IN_PROGRAMEXTERNALID\cf0 \strokec4 ),\cb1 \
\cb3         (
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 ID\cf0 \strokec4  
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 NPVRASSET\cf0 \strokec4  
\f0\b \cf2 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 MTPEXTERNALID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 PARENTEXTERNALID\cf0 \strokec4  \cf5 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 RECORDID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 OUT_RECORDID\cf0 \strokec4 ),\cb1 \
\cb3         \cf6 \strokec6 IN_RECORDINGSTARTTIME\cf0 \strokec4 , \cf6 \strokec6 ASSET_SCHEDULEID\cf0 \strokec4 , \cf6 \strokec6 CHANNELEXTERNALID\cf0 \cb1 \strokec4 \
\cb3         
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 ASSET_DATA\cf0 \cb1 \strokec4 \
\cb3         
\f0\b \cf2 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 parentexternalID\cf0 \strokec4  \cf5 \strokec5 IS\cf0 \strokec4  \cf5 \strokec5 NOT\cf0 \strokec4  \cf5 \strokec5 NULL\cf0 \strokec4 ;\cb1 \
\cb3     
\f0\b \cf2 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\
\cb3     
\f0\b \cf2 \strokec2 DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 TABLE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 ASSET_DATA\cf0 \strokec4 ;\cb1 \
\
\
\cb3     
\f0\b \cf2 \strokec2 END
\f1\b0 \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  ;\cb1 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 \
\
\
==================================================\
\
DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 SCHEDULE_SERIES_RECORD\cf0 \strokec4 ;\cb1 \
\
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 CREATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DEFINER\cf5 \strokec5 =\cf0 \strokec4 `
\f0\b \cf2 \strokec2 root
\f1\b0 \cf0 \strokec4 `\cf6 \strokec6 @\cf0 \strokec4 `\cf6 \strokec6 localhost\cf0 \strokec4 ` 
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  `\cf6 \strokec6 SCHEDULE_SERIES_RECORD\cf0 \strokec4 `(\cf6 \strokec6 IN_USERID\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_CONTEXTID\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 500\cf0 \strokec4 ),\cb1 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 IN_SERIESREFNO\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 20\cf0 \strokec4 ), \cf6 \strokec6 IN_EPSCOPE_SCOPE\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 30\cf0 \strokec4 ),\cb1 \
\cf6 \cb3 \strokec6 IN_ChannelBound\cf0 \strokec4  
\f0\b \cf2 \strokec2 tinyint
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 1\cf0 \strokec4 ), \cf6 \strokec6 IN_AUTO_DELETE_WHEN_SPACE_NEEDED\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_CHANNELID\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf0 \cb3 , \cf6 \strokec6 IN_EPISODE_LIMIT\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , 
\f0\b \cf2 \strokec2 OUT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 TEMPID\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_CURRENTTIME\cf0 \strokec4  
\f0\b \cf2 \strokec2 BIGINT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 RECORDIDS\cf0 \strokec4  
\f0\b \cf2 \strokec2 TEXT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 ENABLESTARTSTOPMARKS\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 ,\cb1 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 IN_SERIESEXISTS\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 ENABLEPRIVATECOPY\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , 
\f0\b \cf2 \strokec2 OUT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 PRIVATEASSETRECORDIDS\cf0 \strokec4  
\f0\b \cf2 \strokec2 TEXT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_PROGRAMTITLE\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 128\cf0 \strokec4 ))\cb1 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 BEGIN
\f1\b0 \cf0 \cb1 \strokec4 \
\

\f0\b \cf2 \cb3 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 SERIESID\cf0 \strokec4  
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 TEMPID\cf0 \strokec4  
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 SYSTEMNPVRSERIESRECORDING\cf0 \cb1 \strokec4 \

\f0\b \cf2 \cb3 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 CONTEXTID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_CONTEXTID\cf0 \strokec4  \cf5 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 SERIESREFNO\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_SERIESREFNO\cf0 \cb1 \strokec4 \

\f0\b \cf2 \cb3 \strokec2 LIMIT
\f1\b0 \cf0 \strokec4  \cf7 \strokec7 1\cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 IF
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 TEMPID\cf0 \strokec4  \cf5 \strokec5 IS\cf0 \strokec4  \cf5 \strokec5 NULL\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \
\
\pard\pardeftab720\partightenfactor0
\cf0 \cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 INSERT
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 SYSTEMNPVRSERIESRECORDING\cf0 \strokec4  (\cf6 \strokec6 ContextID\cf0 \strokec4 , \cf6 \strokec6 SERIESREFNO\cf0 \strokec4 , \cf6 \strokec6 Title\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 VALUES
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 IN_CONTEXTID\cf0 \strokec4 , \cf6 \strokec6 IN_SERIESREFNO\cf0 \strokec4 , \cf6 \strokec6 IN_PROGRAMTITLE\cf0 \strokec4 );\cb1 \
\cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 LAST_INSERT_ID\cf0 \strokec4 () 
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 TEMPID\cf0 \strokec4 ;\cb1 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 COMMIT
\f1\b0 \cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 IF
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 IN_SERIESEXISTS\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \
\
\pard\pardeftab720\partightenfactor0
\cf0 \cb3     
\f0\b \cf2 \strokec2 INSERT
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 USERNPVRSERIESRECORDING\cf0 \strokec4  (\cf6 \strokec6 userID\cf0 \strokec4 , \cf6 \strokec6 SERIESID\cf0 \strokec4 , \cf6 \strokec6 CHANNELID\cf0 \strokec4 , \cf6 \strokec6 DELETEWHENSPACENEEDED\cf0 \strokec4 , \cf6 \strokec6 CHANNELBOUND\cf0 \strokec4 , \cf6 \strokec6 EPISODESCOPE\cf0 \strokec4 , \cf6 \strokec6 EPISODESTOKEEP\cf0 \strokec4 , \cf6 \strokec6 SCHEDULETIMESTAMP\cf0 \strokec4 )\cb1 \
\cb3     
\f0\b \cf2 \strokec2 VALUES
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 IN_USERID\cf0 \strokec4 , \cf6 \strokec6 TEMPID\cf0 \strokec4 , \cf6 \strokec6 IN_CHANNELID\cf0 \strokec4 , \cf6 \strokec6 IN_AUTO_DELETE_WHEN_SPACE_NEEDED\cf0 \strokec4 , \cf6 \strokec6 IN_ChannelBound\cf0 \strokec4 , \cf6 \strokec6 IN_EPSCOPE_SCOPE\cf0 \strokec4 , \cf6 \strokec6 IN_EPISODE_LIMIT\cf0 \strokec4 , \cf9 \strokec9 CURRENT_TIMESTAMP\cf0 \strokec4 );\cb1 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 ELSE
\f1\b0 \cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf0 \cb3     
\f0\b \cf2 \strokec2 UPDATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 USERNPVRSERIESRECORDING\cf0 \cb1 \strokec4 \
\cb3     
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 MARKEDFORDELETE\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ,\cb1 \
\cb3     \cf6 \strokec6 CHANNELID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_CHANNELID\cf0 \strokec4 ,\cb1 \
\cb3     \cf6 \strokec6 DELETEWHENSPACENEEDED\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_AUTO_DELETE_WHEN_SPACE_NEEDED\cf0 \strokec4 ,\cb1 \
\cb3     \cf6 \strokec6 CHANNELBOUND\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_ChannelBound\cf0 \strokec4 ,\cb1 \
\cb3     \cf6 \strokec6 EPISODESCOPE\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_EPSCOPE_SCOPE\cf0 \strokec4 ,\cb1 \
\cb3     \cf6 \strokec6 EPISODESTOKEEP\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_EPISODE_LIMIT\cf0 \strokec4 ,\cb1 \
\cb3     \cf6 \strokec6 SCHEDULETIMESTAMP\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf9 \strokec9 CURRENT_TIMESTAMP\cf0 \cb1 \strokec4 \
\cb3     
\f0\b \cf2 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 USERID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_USERID\cf0 \cb1 \strokec4 \
\cb3     \cf5 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 SERIESID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 TEMPID\cf0 \strokec4 ;\cb1 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 CREATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 temporary\cf0 \strokec4  
\f0\b \cf2 \strokec2 TABLE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 NOT\cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 TEMP_TABLE_IDS\cf0 \strokec4 (\cf6 \strokec6 ID\cf0 \strokec4  
\f0\b \cf2 \strokec2 BIGINT
\f1\b0 \cf0 \strokec4 ) \cf6 \strokec6 ENGINE\cf5 \strokec5 =\cf6 \strokec6 MEMORY\cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 CALL
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 POPULATE_TEMP_TABLE\cf0 \strokec4 (\cf6 \strokec6 RECORDIDS\cf0 \strokec4 );\cb1 \
\
\

\f0\b \cf2 \cb3 \strokec2 CALL
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 CreateUserRecording\cf0 \strokec4 (\cf6 \strokec6 IN_USERID\cf0 \strokec4 , \cf6 \strokec6 TEMPID\cf0 \strokec4 , \cf6 \strokec6 IN_AUTO_DELETE_WHEN_SPACE_NEEDED\cf0 \strokec4 , \cf6 \strokec6 IN_CURRENTTIME\cf0 \strokec4 , \cf6 \strokec6 ENABLESTARTSTOPMARKS\cf0 \strokec4 , \cf6 \strokec6 ENABLEPRIVATECOPY\cf0 \strokec4 , \cf6 \strokec6 IN_CONTEXTID\cf0 \strokec4 , \cf6 \strokec6 PRIVATEASSETRECORDIDS\cf0 \strokec4 );\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 DELETE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 TEMP_TABLE_IDS\cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 END
\f1\b0 \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  ;\cb1 \
\
\
\
\
==================================\
\
\
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 UPDATE_NPVRASSET_STATUS\cf0 \strokec4 ;\cb1 \
\
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 CREATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DEFINER\cf5 \strokec5 =\cf0 \strokec4 `
\f0\b \cf2 \strokec2 root
\f1\b0 \cf0 \strokec4 `\cf6 \strokec6 @\cf0 \strokec4 `\cf6 \strokec6 localhost\cf0 \strokec4 ` 
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 UPDATE_NPVRASSET_STATUS\cf0 \strokec4 (\cf6 \strokec6 IN_RECORDID\cf0 \strokec4  
\f0\b \cf2 \strokec2 BIGINT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_STATUS\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 20\cf0 \strokec4 ), \cb1 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 IN_STATUSDETAIL\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 500\cf0 \strokec4 ), \cf6 \strokec6 IN_BATCH_SIZE\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , 
\f0\b \cf2 \strokec2 OUT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_RECORDS_UPDATED\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 )\cb1 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 BEGIN
\f1\b0 \cf0 \cb1 \strokec4 \
\

\f0\b \cf2 \cb3 \strokec2 DECLARE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 V_ROWCOUNT\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 DEFAULT
\f1\b0 \cf0 \strokec4  \cf7 \strokec7 1\cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_RECORDS_UPDATED\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 WHILE
\f1\b0 \cf0 \strokec4  (\cf6 \strokec6 V_ROWCOUNT\cf0 \strokec4  \cf5 \strokec5 >\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ) \cf6 \strokec6 DO\cf0 \cb1 \strokec4 \
\
\pard\pardeftab720\partightenfactor0
\cf0 \cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 UPDATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 NPVRASSET\cf0 \strokec4  
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 STATUS
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_STATUS\cf0 \strokec4 , \cf6 \strokec6 STATUSDETAIL\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_STATUSDETAIL\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 RECORDID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_RECORDID\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\cf5 \strokec5 AND\cf0 \strokec4  
\f0\b \cf2 \strokec2 STATUS
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 IN\cf0 \strokec4  (\cf8 \cb3 \strokec8 'Scheduling'\cf0 \cb3 \strokec4 , \cf8 \cb3 \strokec8 'Rescheduling'\cf0 \cb3 \strokec4 , \cf8 \cb3 \strokec8 'ScheduleSuccess'\cf0 \cb3 \strokec4 , \cf8 \cb3 \strokec8 'RescheduleSuccess'\cf0 \cb3 \strokec4 )\cb1 \
\cb3 \'a0\'a0\'a0\'a0\cf5 \strokec5 AND\cf0 \strokec4  
\f0\b \cf2 \strokec2 STATUS
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 <>\cf0 \strokec4  \cf6 \strokec6 IN_STATUS\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 LIMIT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 IN_BATCH_SIZE\cf0 \strokec4 ;\cb1 \
\
\cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 ROW_COUNT\cf0 \strokec4 () 
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 V_ROWCOUNT\cf0 \strokec4 ;\cb1 \
\cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_RECORDS_UPDATED\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 OUT_RECORDS_UPDATED\cf0 \strokec4  \cf5 \strokec5 +\cf0 \strokec4  \cf6 \strokec6 V_ROWCOUNT\cf0 \strokec4 ;\cb1 \
\
\cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 V_ROWCOUNT\cf0 \strokec4  \cf5 \strokec5 >\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4  
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 COMMIT
\f1\b0 \cf0 \strokec4 ;\cb1 \
\cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 WHILE
\f1\b0 \cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 END
\f1\b0 \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  ;\
\
======================================\
\
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \strokec2 DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 UPDATE_SERIES_RECORD\cf0 \strokec4 ;\cb1 \
\
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 CREATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DEFINER\cf5 \strokec5 =\cf0 \strokec4 `
\f0\b \cf2 \strokec2 root
\f1\b0 \cf0 \strokec4 `\cf6 \strokec6 @\cf0 \strokec4 `\cf6 \strokec6 localhost\cf0 \strokec4 ` 
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 UPDATE_SERIES_RECORD\cf0 \strokec4 (\cf6 \strokec6 IN_USERID\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_SERIESID\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_EPSCOPE_SCOPE\cf0 \strokec4  
\f0\b \cf2 \strokec2 varchar
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 30\cf0 \strokec4 ),\cb1 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 IN_ChannelBound\cf0 \strokec4  
\f0\b \cf2 \strokec2 tinyint
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 1\cf0 \strokec4 ), \cf6 \strokec6 DELETE_FLAG_CHANGED\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 EPISODE_LIMIT_DECREASED\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_AUTO_DELETE_WHEN_SPACE_NEEDED\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_EPISODE_LIMIT\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 ,\cb1 \
\cf6 \cb3 \strokec6 IN_CURRENTTIME\cf0 \strokec4  
\f0\b \cf2 \strokec2 BIGINT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 RECORDIDS\cf0 \strokec4  
\f0\b \cf2 \strokec2 TEXT
\f1\b0 \cf0 \strokec4 , 
\f0\b \cf2 \strokec2 OUT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_DELETE_REC_IDS\cf0 \strokec4  
\f0\b \cf2 \strokec2 TEXT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 ENABLESTARTSTOPMARKS\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 ENABLEPRIVATECOPY\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_CONTEXTID\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 50\cf0 \strokec4 ),\cb1 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 OUT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 PRIVATEASSETRECORDIDS\cf0 \strokec4  
\f0\b \cf2 \strokec2 TEXT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_ENABLEREBROADCASTHAINDLING\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 )\cb1 \

\f0\b \cf2 \cb3 \strokec2 BEGIN
\f1\b0 \cf0 \cb1 \strokec4 \
\

\f0\b \cf2 \cb3 \strokec2 DECLARE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DELETED_RECORDIDS\cf0 \strokec4  
\f0\b \cf2 \strokec2 TEXT
\f1\b0 \cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 TABLE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 TEMP_TABLE_IDS\cf0 \strokec4 ;\cb1 \

\f0\b \cf2 \cb3 \strokec2 CREATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 temporary\cf0 \strokec4  
\f0\b \cf2 \strokec2 TABLE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 TEMP_TABLE_IDS\cf0 \strokec4 (\cf6 \strokec6 ID\cf0 \strokec4  
\f0\b \cf2 \strokec2 BIGINT
\f1\b0 \cf0 \strokec4 ) \cf6 \strokec6 ENGINE\cf5 \strokec5 =\cf6 \strokec6 MEMORY\cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 CALL
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 POPULATE_TEMP_TABLE\cf0 \strokec4 (\cf6 \strokec6 RECORDIDS\cf0 \strokec4 );\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 TABLE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 DELETEDRECORDIDS\cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 CREATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 TEMPORARY\cf0 \strokec4  
\f0\b \cf2 \strokec2 TABLE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DELETEDRECORDIDS\cf0 \strokec4  \cf6 \strokec6 ENGINE\cf5 \strokec5 =\cf6 \strokec6 MEMORY\cf0 \cb1 \strokec4 \

\f0\b \cf2 \cb3 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 U\cf0 \strokec4 .\cf6 \strokec6 RECORDID\cf0 \strokec4  
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 USERNPVRRECORDING\cf0 \strokec4  \cf6 \strokec6 U\cf0 \cb1 \strokec4 \

\f0\b \cf2 \cb3 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 userID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_USERID\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf5 \cb3 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 SERIESID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_SERIESID\cf0 \cb1 \strokec4 \
\cf5 \cb3 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 U\cf0 \strokec4 .\cf6 \strokec6 RECORDID\cf0 \strokec4  \cf5 \strokec5 NOT\cf0 \strokec4  \cf5 \strokec5 IN\cf0 \strokec4  (
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 ID\cf0 \strokec4  
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 TEMP_TABLE_IDS\cf0 \strokec4 )\cb1 \
\cf5 \cb3 \strokec5 AND\cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf0 \cb3 \'a0\'a0\'a0\'a0(\cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf7 \strokec7 1\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 SYSTEMNPVRRECORDING\cf0 \strokec4  \cf6 \strokec6 S\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 U\cf0 \strokec4 .\cf6 \strokec6 RECORDID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 S\cf0 \strokec4 .\cf6 \strokec6 RECORDID\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\cf5 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 IN_CURRENTTIME\cf0 \strokec4  \cf5 \strokec5 <\cf0 \strokec4  \cf6 \strokec6 RECORDINGSTARTTIME\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0)\cb1 \
\pard\pardeftab720\partightenfactor0
\cf5 \cb3 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 U\cf0 \strokec4 .\cf6 \strokec6 MARKEDFORDELETE\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ;\cb1 \
\
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 UPDATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 USERNPVRSERIESRECORDING\cf0 \cb1 \strokec4 \

\f0\b \cf2 \cb3 \strokec2 SET
\f1\b0 \cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELETEWHENSPACENEEDED\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_AUTO_DELETE_WHEN_SPACE_NEEDED\cf0 \strokec4 ,\cb1 \
\cf6 \cb3 \strokec6 CHANNELBOUND\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_ChannelBound\cf0 \strokec4 ,\cb1 \
\cf6 \cb3 \strokec6 EPISODESCOPE\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_EPSCOPE_SCOPE\cf0 \strokec4 ,\cb1 \
\cf6 \cb3 \strokec6 EPISODESTOKEEP\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_EPISODE_LIMIT\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 userID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_USERID\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf5 \cb3 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 SERIESID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_SERIESID\cf0 \strokec4 ;\cb1 \
\
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 IF
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 DELETE_FLAG_CHANGED\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 1\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \

\f0\b \cf2 \cb3 \strokec2 CALL
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 UPDATE_DELETEWHENSPACENEEDEDFLAG\cf0 \strokec4 (\cf6 \strokec6 IN_USERID\cf0 \strokec4 , \cf6 \strokec6 IN_SERIESID\cf0 \strokec4 , \cf6 \strokec6 IN_AUTO_DELETE_WHEN_SPACE_NEEDED\cf0 \strokec4 );\cb1 \

\f0\b \cf2 \cb3 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 IF
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 EPISODE_LIMIT_DECREASED\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 1\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \

\f0\b \cf2 \cb3 \strokec2 CALL
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 VALIDATE_DELETE_SERIES_EPISODES\cf0 \strokec4 (\cf6 \strokec6 IN_USERID\cf0 \strokec4 , \cf6 \strokec6 IN_SERIESID\cf0 \strokec4 , \cf6 \strokec6 IN_EPISODE_LIMIT\cf0 \strokec4 , \cf6 \strokec6 DELETED_RECORDIDS\cf0 \strokec4 , \cf6 \strokec6 IN_ENABLEREBROADCASTHAINDLING\cf0 \strokec4 );\cb1 \

\f0\b \cf2 \cb3 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 CALL
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 CreateUserRecording\cf0 \strokec4 (\cf6 \strokec6 IN_USERID\cf0 \strokec4 , \cf6 \strokec6 IN_SERIESID\cf0 \strokec4 , \cf6 \strokec6 IN_AUTO_DELETE_WHEN_SPACE_NEEDED\cf0 \strokec4 , \cf6 \strokec6 IN_CURRENTTIME\cf0 \strokec4 , \cf6 \strokec6 ENABLESTARTSTOPMARKS\cf0 \strokec4 , \cf6 \strokec6 ENABLEPRIVATECOPY\cf0 \strokec4 , \cf6 \strokec6 IN_CONTEXTID\cf0 \strokec4 , \cf6 \strokec6 PRIVATEASSETRECORDIDS\cf0 \strokec4 );\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 UPDATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 USERNPVRRECORDING\cf0 \strokec4  \cf6 \strokec6 U\cf0 \cb1 \strokec4 \

\f0\b \cf2 \cb3 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 MARKEDFORDELETE\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 1\cf0 \strokec4 ,\cb1 \

\f0\b \cf2 \cb3 \strokec2 STATUS
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf8 \cb3 \strokec8 'ScheduleCancelled'\cf0 \cb3 \strokec4 ,\cb1 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 STATUSDETAILS\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf8 \cb3 \strokec8 'Schedule Cancelled'\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 userID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_USERID\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf5 \cb3 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 U\cf0 \strokec4 .\cf6 \strokec6 RECORDID\cf0 \strokec4  \cf5 \strokec5 IN\cf0 \strokec4 (
\f0\b \cf2 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 D\cf0 \strokec4 .\cf6 \strokec6 RECORDID\cf0 \strokec4  
\f0\b \cf2 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DELETEDRECORDIDS\cf0 \strokec4  \cf6 \strokec6 D\cf0 \strokec4 );\cb1 \
\
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 SELECT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 GROUP_CONCAT\cf0 \strokec4 (\cf6 \strokec6 RECORDID\cf0 \strokec4  \cf6 \strokec6 SEPARATOR\cf0 \strokec4  \cf6 \strokec6 ","\cf0 \strokec4 ) \cf6 \strokec6 ids\cf0 \cb1 \strokec4 \

\f0\b \cf2 \cb3 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_DELETE_REC_IDS\cf0 \cb1 \strokec4 \

\f0\b \cf2 \cb3 \strokec2 FROM
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DELETEDRECORDIDS\cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 IF
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 length\cf0 \strokec4 (\cf6 \strokec6 DELETED_RECORDIDS\cf0 \strokec4 ) \cf5 \strokec5 >\cf0 \strokec4  \cf7 \strokec7 0\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf0 \cb3             \cf5 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 length\cf0 \strokec4 (\cf6 \strokec6 OUT_DELETE_REC_IDS\cf0 \strokec4 ) \cf5 \strokec5 >\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \
\cb3             
\f0\b \cf2 \strokec2 select
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 CONCAT
\f1\b0 \cf0 \strokec4 (
\f0\b \cf2 \strokec2 CONCAT
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 DELETED_RECORDIDS\cf0 \strokec4 , \cf8 \cb3 \strokec8 ','\cf0 \cb3 \strokec4 ), \cf6 \strokec6 OUT_DELETE_REC_IDS\cf0 \strokec4 )\cb1 \
\cb3             
\f0\b \cf2 \strokec2 INTO
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_DELETE_REC_IDS\cf0 \strokec4 ;\cb1 \
\cb3         \cf6 \strokec6 ELSEIF\cf0 \strokec4 (\cf6 \strokec6 length\cf0 \strokec4 (\cf6 \strokec6 DELETED_RECORDIDS\cf0 \strokec4 ) \cf5 \strokec5 >\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \
\cb3             
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 OUT_DELETE_REC_IDS\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 DELETED_RECORDIDS\cf0 \strokec4 ;\cb1 \
\cb3         
\f0\b \cf2 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 TABLE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 TEMP_TABLE_IDS\cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 TABLE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 DELETEDRECORDIDS\cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 END
\f1\b0 \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  ;\cb1 \
\pard\pardeftab720\partightenfactor0
\cf0 \cb3 \
===========================================\
\
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \strokec2 DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 UPDATEUSERNPVRSTATUSBYRECORDID\cf0 \strokec4 ;\cb1 \
\
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 CREATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DEFINER\cf5 \strokec5 =\cf0 \strokec4 `
\f0\b \cf2 \strokec2 root
\f1\b0 \cf0 \strokec4 `\cf6 \strokec6 @\cf0 \strokec4 `\cf6 \strokec6 localhost\cf0 \strokec4 ` 
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 UPDATEUSERNPVRSTATUSBYRECORDID\cf0 \strokec4 (
\f0\b \cf2 \strokec2 BATCHSIZE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_RECORDID\cf0 \strokec4  
\f0\b \cf2 \strokec2 BIGINT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_STATUS\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 20\cf0 \strokec4 ), \cf6 \strokec6 IN_STATUSDETAILS\cf0 \strokec4  
\f0\b \cf2 \strokec2 VARCHAR
\f1\b0 \cf0 \strokec4 (\cf7 \strokec7 500\cf0 \strokec4 ), \cf6 \strokec6 IN_ISFAILED\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , 
\f0\b \cf2 \strokec2 OUT
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 TOTALROWSUPDATED\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 )\cb1 \

\f0\b \cf2 \cb3 \strokec2 BEGIN
\f1\b0 \cf0 \cb1 \strokec4 \
\
\pard\pardeftab720\partightenfactor0
\cf0 \cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 TOTALROWSUPDATED\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ;\cb1 \
\
\cb3 \'a0\'a0\'a0\'a0\cf6 \strokec6 UPDATE_LOOP\cf0 \strokec4 : 
\f0\b \cf2 \strokec2 LOOP
\f1\b0 \cf0 \cb1 \strokec4 \
\
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 UPDATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 USERNPVRRECORDING\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 STATUS
\f1\b0 \cf5 \strokec5 =\cf6 \strokec6 IN_STATUS\cf0 \strokec4 , \cf6 \strokec6 STATUSDETAILS\cf5 \strokec5 =\cf6 \strokec6 IN_STATUSDETAILS\cf0 \strokec4 , \cf6 \strokec6 ISFAILED\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_ISFAILED\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 WHERE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 RECORDID\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 IN_RECORDID\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\cf5 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 MARKEDFORDELETE\cf5 \strokec5 =\cf7 \strokec7 0\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\cf5 \strokec5 AND\cf0 \strokec4  \cf6 \strokec6 ISFAILED\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 0\cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\cf5 \strokec5 AND\cf0 \strokec4  
\f0\b \cf2 \strokec2 STATUS
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 <>\cf0 \strokec4  \cf6 \strokec6 IN_STATUS\cf0 \strokec4 ;\cb1 \
\
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 TOTALROWSUPDATED\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf6 \strokec6 TOTALROWSUPDATED\cf0 \strokec4  \cf5 \strokec5 +\cf0 \strokec4  \cf6 \strokec6 ROW_COUNT\cf0 \strokec4 ();\cb1 \
\
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 ROW_COUNT\cf0 \strokec4 () \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0\cf6 \strokec6 LEAVE\cf0 \strokec4  \cf6 \strokec6 UPDATE_LOOP\cf0 \strokec4 ;\cb1 \
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\
\cb3 \'a0\'a0\'a0\'a0\'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 COMMIT
\f1\b0 \cf0 \strokec4 ;\cb1 \
\cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 LOOP
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 UPDATE_LOOP\cf0 \strokec4 ;\cb1 \
\
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 END
\f1\b0 \cf0 \strokec4  \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  ;\cb1 \
\pard\pardeftab720\partightenfactor0
\cf0 \cb3 \
\
==================================\
\
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \strokec2 DROP
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4  \cf5 \strokec5 EXISTS\cf0 \strokec4  \cf6 \strokec6 VALIDATE_QUOTA_AND_EPISODELIMIT\cf0 \strokec4 ;\cb1 \
\
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 CREATE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DEFINER\cf5 \strokec5 =\cf0 \strokec4 `
\f0\b \cf2 \strokec2 root
\f1\b0 \cf0 \strokec4 `\cf6 \strokec6 @\cf0 \strokec4 `\cf6 \strokec6 localhost\cf0 \strokec4 ` 
\f0\b \cf2 \strokec2 PROCEDURE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 VALIDATE_QUOTA_AND_EPISODELIMIT\cf0 \strokec4 (\cf6 \strokec6 IN_RECORDID\cf0 \strokec4  
\f0\b \cf2 \strokec2 BIGINT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_NEEDEDMINUTES\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_BATCHSIZE\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 INOUT\cf0 \strokec4  \cf6 \strokec6 USERIDSTONOTIFY\cf0 \strokec4  \cf6 \strokec6 LONGTEXT\cf0 \strokec4 , \cf6 \strokec6 INOUT\cf0 \strokec4  \cf6 \strokec6 USER_PROCESSED_COUNT\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 , \cf6 \strokec6 IN_ENABLEREBROADCASTHAINDLING\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 )\cb1 \

\f0\b \cf2 \cb3 \strokec2 BEGIN
\f1\b0 \cf0 \cb1 \strokec4 \

\f0\b \cf2 \cb3 \strokec2 DECLARE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 VAR_LOCAL_USERIDS\cf0 \strokec4  \cf6 \strokec6 LONGTEXT\cf0 \strokec4 ;\cb1 \

\f0\b \cf2 \cb3 \strokec2 DECLARE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 VAR_UPDATED_ROW_COUNT\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 ;\cb1 \

\f0\b \cf2 \cb3 \strokec2 DECLARE
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 VAR_NEEDEDSECONDS\cf0 \strokec4  
\f0\b \cf2 \strokec2 INT
\f1\b0 \cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 SET
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 USER_PROCESSED_COUNT\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 0\cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 IF
\f1\b0 \cf0 \strokec4 (\cf6 \strokec6 IN_ENABLEREBROADCASTHAINDLING\cf0 \strokec4  \cf5 \strokec5 =\cf0 \strokec4  \cf7 \strokec7 1\cf0 \strokec4 ) 
\f0\b \cf2 \strokec2 THEN
\f1\b0 \cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf0 \cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 CALL
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DELETE_OLDEST_SERIES_RECORD_REBROADCAST_ENABLED\cf0 \strokec4 (\cf6 \strokec6 IN_RECORDID\cf0 \strokec4 , \cf6 \strokec6 IN_BATCHSIZE\cf0 \strokec4 , \cf6 \strokec6 USERIDSTONOTIFY\cf0 \strokec4 );\cb1 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 ELSE
\f1\b0 \cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf0 \cb3 \'a0\'a0\'a0\'a0
\f0\b \cf2 \strokec2 CALL
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 DELETE_OLDEST_SERIES_RECORD_REBROADCAST_DISABLED\cf0 \strokec4 (\cf6 \strokec6 IN_RECORDID\cf0 \strokec4 , \cf6 \strokec6 IN_BATCHSIZE\cf0 \strokec4 , \cf6 \strokec6 USERIDSTONOTIFY\cf0 \strokec4 );\cb1 \
\pard\pardeftab720\partightenfactor0

\f0\b \cf2 \cb3 \strokec2 END
\f1\b0 \cf0 \strokec4  
\f0\b \cf2 \strokec2 IF
\f1\b0 \cf0 \strokec4 ;\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 CALL
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 VALIDATE_NPVR_QUOTA_AND_DELETE_OLDEST_RECORD\cf0 \strokec4 (\cf6 \strokec6 IN_RECORDID\cf0 \strokec4 , \cf6 \strokec6 IN_NEEDEDMINUTES\cf0 \strokec4 , \cf6 \strokec6 IN_BATCHSIZE\cf0 \strokec4 , \cf6 \strokec6 USERIDSTONOTIFY\cf0 \strokec4 , \cf6 \strokec6 USER_PROCESSED_COUNT\cf0 \strokec4 , \cf6 \strokec6 IN_ENABLEREBROADCASTHAINDLING\cf0 \strokec4 );\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 CALL
\f1\b0 \cf0 \strokec4  \cf6 \strokec6 UPDATE_STATUS_FOR_QUOTA_CHECK\cf0 \strokec4 (\cf6 \strokec6 IN_RECORDID\cf0 \strokec4 , \cf6 \strokec6 IN_BATCHSIZE\cf0 \strokec4 , \cf6 \strokec6 USER_PROCESSED_COUNT\cf0 \strokec4 );\cb1 \
\

\f0\b \cf2 \cb3 \strokec2 END
\f1\b0 \cf0 \strokec4  \cf7 \strokec7 $$\cf0 \cb1 \strokec4 \
\pard\pardeftab720\partightenfactor0
\cf6 \cb3 \strokec6 DELIMITER\cf0 \strokec4  ;\cb1 \
\pard\pardeftab720\partightenfactor0
\cf0 \cb3 \
\
\
\pard\pardeftab720\partightenfactor0
\cf0 \cb1 \
}