c r e a t e   P r o c e d u r e   D o w n C l a s s 
 
 ( 
 
 @ Y X _ I D   i n t 
 
 ) 
 
 a s 
 
 d e c l a r e   @ F _ P a r e n t I D   v a r c h a r ( 1 0 0 ) / * 6r~R{|* / 
 
 d e c l a r e   @ F _ P a t h   v a r c h a r ( 1 0 0 ) / * 6r~R{|_* / 
 
 d e c l a r e   @ F _ C h i l d   i n t / * 6r~R{|vC h i l d * / 
 
 d e c l a r e   @ F _ P r e v I D   i n t / * 6r~R{|vTm^R{|
N*NI D * / 
 
 d e c l a r e   @ F _ N e x t I D   i n t / * 6r~R{|vTm^R{|N*NI D * / 
 
 d e c l a r e   @ F _ O r d e r I D   i n t   / * 6r~R{|vc^I D * / 
 
 d e c l a r e   @ T e m p P a t h   v a r c h a r ( 1 0 0 )   / * 4Ne_* / 
 
 d e c l a r e   @ T e m p N u m   i n t   / * 4Nei n t W* / 
 
 s e l e c t     @ F _ P a r e n t I D = Y X _ P a r e n t I D , @ F _ P a t h = Y X _ P a r e n t P a t h , @ F _ C h i l d = Y X _ C h i l d , @ F _ P r e v I D = Y X _ P r e v I D , @ F _ N e x t I D = Y X _ N e x t I D 
 
 , @ F _ O r d e r I D = Y X _ O r d e r I D   f r o m   Y X _ p r o d u c t c l a s s   w h e r e   Y X _ I D = @ Y X _ I D 
 
 	 
 
 	 i f   @ F _ N e x t I D > 0 
 
                 b e g i n 
 
                 	 e x e c   U p C l a s s   @ F _ N e x t I D 	 	 
 
 	 e n d 
 
 
 
 ~ 
 
 
 
 c r e a t e   P r o c e d u r e   D o w n N e w s C l a s s 
 
 ( 
 
 @ Y X _ I D   i n t 
 
 ) 
 
 a s 
 
 d e c l a r e   @ F _ P a r e n t I D   v a r c h a r ( 1 0 0 ) / * 6r~R{|* / 
 
 d e c l a r e   @ F _ P a t h   v a r c h a r ( 1 0 0 ) / * 6r~R{|_* / 
 
 d e c l a r e   @ F _ C h i l d   i n t / * 6r~R{|vC h i l d * / 
 
 d e c l a r e   @ F _ P r e v I D   i n t / * 6r~R{|vTm^R{|
N*NI D * / 
 
 d e c l a r e   @ F _ N e x t I D   i n t / * 6r~R{|vTm^R{|N*NI D * / 
 
 d e c l a r e   @ F _ O r d e r I D   i n t   / * 6r~R{|vc^I D * / 
 
 d e c l a r e   @ T e m p P a t h   v a r c h a r ( 1 0 0 )   / * 4Ne_* / 
 
 d e c l a r e   @ T e m p N u m   i n t   / * 4Nei n t W* / 
 
 s e l e c t     @ F _ P a r e n t I D = Y X _ P a r e n t I D , @ F _ P a t h = Y X _ P a r e n t P a t h , @ F _ C h i l d = Y X _ C h i l d , @ F _ P r e v I D = Y X _ P r e v I D , @ F _ N e x t I D = Y X _ N e x t I D 
 
 , @ F _ O r d e r I D = Y X _ O r d e r I D   f r o m   Y X _ N e w s C l a s s   w h e r e   Y X _ I D = @ Y X _ I D 
 
 	 
 
 	 i f   @ F _ N e x t I D > 0 
 
                 b e g i n 
 
                 	 e x e c   U p N e w s C l a s s   @ F _ N e x t I D 	 	 
 
 	 e n d 
 
 ~ 
 
 
 
 C R E A T E   P r o c e d u r e   G e t M e n t L i s t 
 
 / * gQezSRh* / 
 
 @ T e m p I D   i n t 
 
 a s 
 
 s e l e c t   *   f r o m   Y X _ C h a n n e l   w h e r e   Y X _ T e m p l a t e = @ T e m p I D 
 
 
 
 ~ 
 
 
 
 c r e a t e   P r o c e d u r e   P r o _ A r t i c l e T e m p l t e 
 
 ( 
 
 @ Y X _ C M S M o d e l N a m e   v a r c h a r ( 5 0 ) , 
 
 @ C h a n n e l I D   i n t , 
 
 @ Y X _ T e m p l a t e T y p e   i n t 
 
 ) 
 
 a s 
 
 s e l e c t   *   f r o m   Y X _ C M S M o d e l   w h e r e   Y X _ C M S M o d e l N a m e = @ Y X _ C M S M o d e l N a m e   a n d   Y X _ T e m p l a t e T y p e = @ Y X _ T e m p l a t e T y p e   a n d   C h a n n e l I D = @ C h a n n e l I D 
 
 
 
 ~ 
 
 
 
 c r e a t e   P r o c e d u r e   P r o _ G e t T e m p l a t e 
 
 ( 
 
 @ m o d e n a m e   v a r c h a r ( 5 0 ) , 
 
 @ T e m p l a t e I D   i n t 
 
 ) 
 
 a s 
 
 s e l e c t   *   f r o m   Y X _ C M S M o d e l   w h e r e   Y X _ C M S M o d e l N a m e = @ m o d e n a m e   a n d   Y X _ T e m p l a t e T y p e = @ T e m p l a t e I D 
 
 
 
 ~ 
 
 
 
 c r e a t e   P r o c e d u r e   P r o _ G e t Z K 
 
 ( 
 
 @ i d   i n t 
 
 ) 
 
 a s   
 
 s e l e c t   z d n a m e 1 , z d n a m e 2 , z d n a m e 3 , z d n a m e 4 , z d n a m e 5 , z d n a m e 6 , z d n a m e 7 , z d n a m e 8 , z d n a m e 9 
 
 , z d n a m e 1 0 , z d v a l u e 1 , z d v a l u e 2 , z d v a l u e 3 , z d v a l u e 4 , z d v a l u e 5 , z d v a l u e 6 , z d v a l u e 7 , z d v a l u e 8 , z d v a l u e 9 , z d v a l u e 1 0 
 
   f r o m   Y X _ P r o d u c t   w h e r e   Y X _ I D = @ i d   
 
 
 
 ~ 
 
 
 
 c r e a t e   P r o c e d u r e   P r o _ S e l e c t 
 
 ( 
 
 @ Y X _ s q l s t r   v a r c h a r ( 8 0 0 0 ) 
 
 ) 
 
 a s 
 
 e x e c ( @ Y X _ s q l s t r ) 
 
 
 
 ~ 
 
 
 
 C R E A T E   P r o c e d u r e   P r o _ S h o w P r o d u c t 
 
 ( 
 
 @ i d   i n t 
 
 ) 
 
 a s 
 
 s e l e c t   *   f r o m   Y X _ P r o d u c t   w h e r e   Y X _ I D = @ i d   
 
 
 
 ~ 
 
 C R E A T E   P r o c e d u r e   P r o _ d e l e t e A r t i c l e C M S c l a s s 
 
 ( 
 
 @ i d   i n t 
 
 ) 
 
 a s   
 
 u p d a t e   Y X _ A r t i c l e _ C M S C l a s s   s e t   y x _ n e x t i d = ( s e l e c t   y x _ n e x t i d   f r o m   Y X _ N e w s C l a s s   w h e r e   y x _ i d = @ i d )   w h e r e   y x _ n e x t i d = @ i d 
 
 u p d a t e   Y X _ A r t i c l e _ C M S C l a s s   s e t   y x _ p r e v i d = ( s e l e c t   y x _ p r e v i d   f r o m   Y X _ N e w s C l a s s   w h e r e   y x _ i d = @ i d   )   w h e r e   y x _ p r e v i d = @ i d 
 
 U p d a t e   Y X _ A r t i c l e _ C M S C l a s s   s e t   y x _ c h i l d = y x _ c h i l d - 1   w h e r e   y x _ i d = ( s e l e c t   y x _ p a r e n t i d   f r o m   Y X _ A r t i c l e _ C M S C l a s s   w h e r e   y x _ i d = @ i d ) 
 
 d e l e t e   f r o m   Y X _ C M S A r t i c l e   w h e r e   y x _ n e w s c l a s s = @ i d 
 
 d e l e t e   f r o m   Y X _ A r t i c l e _ C M S C l a s s   w h e r e   y x _ i d = @ i d 
 
 
 
 ~ 
 
 
 
 C R E A T E   P r o c e d u r e   P r o _ d e l e t e P r o c l a s s 
 
 ( 
 
 @ i d   i n t 
 
 ) 
 
 a s   
 
 u p d a t e   Y X _ P r o d u c t C l a s s   s e t   y x _ n e x t i d = ( s e l e c t   y x _ n e x t i d   f r o m   Y X _ P r o d u c t C l a s s   w h e r e   y x _ i d = @ i d )   w h e r e   y x _ n e x t i d = @ i d 
 
 u p d a t e   Y X _ P r o d u c t C l a s s   s e t   y x _ p r e v i d = ( s e l e c t   y x _ p r e v i d   f r o m   Y X _ P r o d u c t C l a s s   w h e r e   y x _ i d = @ i d   )   w h e r e   y x _ p r e v i d = @ i d 
 
 U p d a t e   Y X _ P r o d u c t C l a s s   s e t   y x _ c h i l d = y x _ c h i l d - 1   w h e r e   y x _ i d = ( s e l e c t   y x _ p a r e n t i d   f r o m   Y X _ P r o d u c t C l a s s   w h e r e   y x _ i d = @ i d ) 
 
 d e l e t e   f r o m   Y X _ P r o d u c t   w h e r e   y x _ c l a s s = @ i d 
 
 d e l e t e   f r o m   Y X _ P r o d u c t C l a s s   w h e r e   y x _ i d = @ i d 
 
 
 
 ~ 
 
 
 
 C R E A T E   P r o c e d u r e   P r o _ d e l e t e c l a s s 
 
 ( 
 
 @ i d   i n t 
 
 ) 
 
 a s   
 
 u p d a t e   Y X _ N e w s C l a s s   s e t   y x _ n e x t i d = ( s e l e c t   y x _ n e x t i d   f r o m   Y X _ N e w s C l a s s   w h e r e   y x _ i d = @ i d )   w h e r e   y x _ n e x t i d = @ i d 
 
 u p d a t e   Y X _ N e w s C l a s s   s e t   y x _ p r e v i d = ( s e l e c t   y x _ p r e v i d   f r o m   Y X _ N e w s C l a s s   w h e r e   y x _ i d = @ i d   )   w h e r e   y x _ p r e v i d = @ i d 
 
 U p d a t e   Y X _ N e w s C l a s s   s e t   y x _ c h i l d = y x _ c h i l d - 1   w h e r e   y x _ i d = ( s e l e c t   y x _ p a r e n t i d   f r o m   Y X _ N e w s C l a s s   w h e r e   y x _ i d = @ i d ) 
 
 d e l e t e   f r o m   y x _ n e w s   w h e r e   y x _ n e w s c l a s s = @ i d 
 
 d e l e t e   f r o m   Y X _ N e w s C l a s s   w h e r e   y x _ i d = @ i d 
 
 
 
 ~ 
 
 
 
 C R E A T E   p r o c   S h o w C o r r e l a t i o n 
 
 @ P r o d u c t I D   i n t 
 
 a s 
 
 d e c l a r e   @ Y X _ K e y s W o r d   v a r c h a r ( 5 0 ) , @ Y X _ P r o d u c t N a m e   v a r c h a r ( 5 0 ) 
 
 s e l e c t   @ Y X _ K e y s W o r d = Y X _ K e y s W o r d , @ Y X _ P r o d u c t N a m e = Y X _ P r o d u c t N a m e   f r o m   Y X _ P r o d u c t   w h e r e   Y X _ I D   =   @ P r o d u c t I D 
 
 s e l e c t   t o p   8     Y X _ I D , Y X _ P r o d u c t N a m e , Y X _ S p i c     f r o m   Y X _ P r o d u c t   w h e r e   ( Y X _ P r o d u c t N a m e   l i k e   ' % ' +   @ Y X _ P r o d u c t N a m e   + ' % '   o r   Y X _ K e y s W o r d   l i k e   ' % ' +   @ Y X _ K e y s W o r d   + ' % ' )   a n d   y x _ i d < > @ P r o d u c t I D   o r d e r   b y   Y X _ A d d T i m e   d e s c 
 
 
 
 
 
 ~ 
 
 
 
 C R E A T E   P r o c e d u r e   S h o w S q l 
 
 ( 
 
 @ s t r   v a r c h a r ( 5 0 0 ) 
 
 ) 
 
 a s 
 
 
 
 e x e c ( @ s t r ) 
 
 
 
 ~ 
 
 
 
 C R E A T E   P r o c e d u r e   U p C l a s s 
 
 ( 
 
 @ Y X _ I D   i n t 
 
 ) 
 
 a s 
 
 d e c l a r e   @ F _ P a r e n t I D   v a r c h a r ( 1 0 0 ) / * 6r~R{|* / 
 
 d e c l a r e   @ F _ P a t h   v a r c h a r ( 1 0 0 ) / * 6r~R{|_* / 
 
 d e c l a r e   @ F _ C h i l d   i n t / * 6r~R{|vC h i l d * / 
 
 d e c l a r e   @ F _ P r e v I D   i n t / * 6r~R{|vTm^R{|
N*NI D * / 
 
 d e c l a r e   @ F _ N e x t I D   i n t / * 6r~R{|vTm^R{|N*NI D * / 
 
 d e c l a r e   @ F _ O r d e r I D   i n t   / * 6r~R{|vc^I D * / 
 
 d e c l a r e   @ T e m p P a t h   v a r c h a r ( 1 0 0 )   / * 4Ne_* / 
 
 d e c l a r e   @ T e m p N u m   i n t   / * 4Nei n t W* / 
 
 d e c l a r e   @ F _ R o o t I D   i n t 
 
 s e l e c t     @ F _ P a r e n t I D = Y X _ P a r e n t I D , @ F _ P a t h = Y X _ P a r e n t P a t h , @ F _ C h i l d = Y X _ C h i l d , @ F _ R o o t I D = Y X _ R o o t I D , @ F _ P r e v I D = Y X _ P r e v I D , @ F _ N e x t I D = Y X _ N e x t I D 
 
 , @ F _ O r d e r I D = Y X _ O r d e r I D   f r o m   Y X _ p r o d u c t c l a s s   w h e r e   Y X _ I D = @ Y X _ I D 
 
 	 / * * ~b0R6r~R{|Nv@b	gR{|pev* * / 
 
                 d e c l a r e   @ F _ N e x t C l a s s P a t h   v a r c h a r ( 1 0 0 ) 
 
                 s e t   @ F _ N e x t C l a s s P a t h = @ F _ P a t h + ' , ' + C o n v e r t ( v a r c h a r ( 1 0 0 ) , @ Y X _ I D ) 
 
 	 d e c l a r e   @ F _ C h i l d N u m   i n t 
 
 	 s e l e c t   @ F _ C h i l d N u m = ( s e l e c t   c o u n t ( * )   f r o m   Y X _ P r o d u c t C l a s s   w h e r e   Y X _ P a r e n t P a t h   l i k e   @ F _ N e x t C l a s s P a t h + ' % '   a n d   Y X _ R o o t I D = @ F _ R o o t I D ) 
 
 	 s e t   @ F _ C h i l d N u m = @ F _ C h i l d N u m + 1 
 
 	 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 
 
 	 / * ~b0R6r~R{|vTm^R{|vOo`* / 
 
                 d e c l a r e   @ P r v _ P r e v I D   i n t 
 
                   d e c l a r e   @ P r v _ R o o t I D   i n t 
 
 i f   @ F _ P r e v I D > 0 
 
 	 b e g i n 
 
                                 / * R{|vvsQOo`* / 
 
                                 d e c l a r e   @ N e x t C l a s s P a t h   v a r c h a r ( 1 0 0 ) / * N^\R{|v_* / 
 
                         
 
                                 s e l e c t   @ N e x t C l a s s P a t h = Y X _ P a r e n t P a t h , @ P r v _ R o o t I D = Y X _ R o o t I D   f r o m   Y X _ P r o d u c t C l a s s   w h e r e   Y X _ I D = @ F _ P r e v I D 
 
                                 s e t   @ N e x t C l a s s P a t h = @ N e x t C l a s s P a t h + ' , ' + C o n v e r t ( v a r c h a r ( 1 0 0 ) , @ F _ P r e v I D ) 
 
 	 	 d e c l a r e   @ P r v _ C h i l d N u m   i n t   / * 
N*NR{|vpev* / 
 
 	 	 s e l e c t   @ P r v _ C h i l d N u m = ( s e l e c t   c o u n t ( * )   f r o m   Y X _ P r o d u c t C l a s s   w h e r e   Y X _ P a r e n t P a t h   l i k e   @ N e x t C l a s s P a t h + ' % '   a n d   Y X _ R o o t I D = @ P r v _ R o o t I D ) 
 
                                 / * BlQR{|v;`pe* / 
 
                                 s e t   @ P r v _ C h i l d N u m = @ P r v _ C h i l d N u m + 1 
 
                             
 
                                 ( s e l e c t   @ P r v _ P r e v I D = Y X _ P r e v I D   f r o m   Y X _ P r o d u c t C l a s s   w h e r e   Y X _ I D = @ F _ P r e v I D ) 
 
                                 
 
                                       / * O9eR{|vMOnT
NNvsQI D * / 
 
                                                 u p d a t e   Y X _ P r o d u c t C l a s s   s e t   Y X _ P r e v I D = @ Y X _ I D , Y X _ N e x t I D = @ F _ N e x t I D , 
 
                                                   Y X _ O r d e r I D = Y X _ O r d e r I D + @ F _ C h i l d N u m   w h e r e   Y X _ I D = @ F _ P r e v I D 
 
                                                         / * O9eR{|Nvc^I D * / 
 
                                                         u p d a t e   Y X _ P r o d u c t C l a s s   s e t   Y X _ O r d e r I D = Y X _ O r d e r I D + @ F _ C h i l d N u m   
 
                                                           w h e r e   Y X _ P a r e n t P a t h   l i k e   @ N e x t C l a s s P a t h + ' % '   a n d   Y X _ R o o t I D = @ P r v _ R o o t I D   
 
 	 	 	 / * * * * * * * * * * * * * * * * * * * * * * * * * / 
 
                                 / * * * * * * * * * * * * * * * * * / 
 
                                 / * * O9eR{|
N~R{|vn e x t I D * / 
 
                                 u p d a t e   Y X _ p r o d u c t c l a s s   s e t   Y X _ N e x t I D = @ Y X _ I D   w h e r e   Y X _ I D = @ P r v _ P r e v I D 
 
 	 	 	 / * O9enR{|I D * / 
 
 	 	 	 s e t   @ T e m p P a t h = @ F _ P a t h + ' , ' + C o n v e r t ( v a r c h a r ( 1 0 0 ) , @ Y X _ I D ) 
 
       	 	 	 u p d a t e   Y X _ P r o d u c t C l a s s   s e t   Y X _ P r e v I D = @ P r v _ P r e v I D , Y X _ N e x t I D = @ F _ P r e v I D , 
 
                                                 Y X _ O r d e r I D = Y X _ O r d e r I D - @ P r v _ C h i l d N u m   w h e r e   Y X _ I D = @ Y X _ I D 
 
                                                         / * O9eR{|Nvc^I D * / 
 
                                                 u p d a t e   Y X _ P r o d u c t C l a s s   s e t   Y X _ O r d e r I D = Y X _ O r d e r I D - @ P r v _ C h i l d N u m   
 
                                                 w h e r e   Y X _ P a r e n t P a t h   l i k e   @ T e m p P a t h + ' % '   a n d   Y X _ R o o t I D = @ F _ R o o t I D     
 
 	 	 	 / * * * * * * * * * * * * * / 
 
 	 	 i f   @ F _ N e x t I D   > 0 
 
 	 	 b e g i n 
 
                                     / * O9eN*Nv4N{|+RvP r e v I D * / 
 
                                 U p d a t e   Y X _ P r o d u c t C l a s s   s e t   Y X _ P r e v I D = @ F _ P r e v I D   w h e r e   Y X _ I D = @ F _ N e x t I D 
 
 	 	 e n d 
 
 	 	 
 
 	 e n d 
 
 
 
 ~ 
 
 
 
 C R E A T E   P r o c e d u r e   U p N e w s C l a s s 
 
 ( 
 
 @ Y X _ I D   i n t 
 
 ) 
 
 a s 
 
 d e c l a r e   @ F _ P a r e n t I D   v a r c h a r ( 1 0 0 ) / * 6r~R{|* / 
 
 d e c l a r e   @ F _ P a t h   v a r c h a r ( 1 0 0 ) / * 6r~R{|_* / 
 
 d e c l a r e   @ F _ C h i l d   i n t / * 6r~R{|vC h i l d * / 
 
 d e c l a r e   @ F _ P r e v I D   i n t / * 6r~R{|vTm^R{|
N*NI D * / 
 
 d e c l a r e   @ F _ N e x t I D   i n t / * 6r~R{|vTm^R{|N*NI D * / 
 
 d e c l a r e   @ F _ O r d e r I D   i n t   / * 6r~R{|vc^I D * / 
 
 d e c l a r e   @ T e m p P a t h   v a r c h a r ( 1 0 0 )   / * 4Ne_* / 
 
 d e c l a r e   @ T e m p N u m   i n t   / * 4Nei n t W* / 
 
 d e c l a r e   @ F _ R o o t I D   i n t 
 
 s e l e c t     @ F _ P a r e n t I D = Y X _ P a r e n t I D , @ F _ P a t h = Y X _ P a r e n t P a t h , @ F _ C h i l d = Y X _ C h i l d , @ F _ R o o t I D = Y X _ R o o t I D , @ F _ P r e v I D = Y X _ P r e v I D , @ F _ N e x t I D = Y X _ N e x t I D 
 
 , @ F _ O r d e r I D = Y X _ O r d e r I D   f r o m   Y X _ N e w s C l a s s   w h e r e   Y X _ I D = @ Y X _ I D 
 
 	 / * * ~b0R6r~R{|Nv@b	gR{|pev* * / 
 
                 d e c l a r e   @ F _ N e x t C l a s s P a t h   v a r c h a r ( 1 0 0 ) 
 
                 s e t   @ F _ N e x t C l a s s P a t h = @ F _ P a t h + ' , ' + C o n v e r t ( v a r c h a r ( 1 0 0 ) , @ Y X _ I D ) 
 
 	 d e c l a r e   @ F _ C h i l d N u m   i n t 
 
 	 s e l e c t   @ F _ C h i l d N u m = ( s e l e c t   c o u n t ( * )   f r o m   Y X _ N e w s C l a s s   w h e r e   Y X _ P a r e n t P a t h   l i k e   @ F _ N e x t C l a s s P a t h + ' % '   a n d   Y X _ R o o t I D = @ F _ R o o t I D ) 
 
 	 s e t   @ F _ C h i l d N u m = @ F _ C h i l d N u m + 1 
 
 	 / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / 
 
 	 / * ~b0R6r~R{|vTm^R{|vOo`* / 
 
                 d e c l a r e   @ P r v _ P r e v I D   i n t 
 
                   d e c l a r e   @ P r v _ R o o t I D   i n t 
 
 i f   @ F _ P r e v I D > 0 
 
 	 b e g i n 
 
                                 / * R{|vvsQOo`* / 
 
                                 d e c l a r e   @ N e x t C l a s s P a t h   v a r c h a r ( 1 0 0 ) / * N^\R{|v_* / 
 
                         
 
                                 s e l e c t   @ N e x t C l a s s P a t h = Y X _ P a r e n t P a t h , @ P r v _ R o o t I D = Y X _ R o o t I D   f r o m   Y X _ N e w s C l a s s   w h e r e   Y X _ I D = @ F _ P r e v I D 
 
                                 s e t   @ N e x t C l a s s P a t h = @ N e x t C l a s s P a t h + ' , ' + C o n v e r t ( v a r c h a r ( 1 0 0 ) , @ F _ P r e v I D ) 
 
 	 	 d e c l a r e   @ P r v _ C h i l d N u m   i n t   / * 
N*NR{|vpev* / 
 
 	 	 s e l e c t   @ P r v _ C h i l d N u m = ( s e l e c t   c o u n t ( * )   f r o m   Y X _ N e w s C l a s s   w h e r e   Y X _ P a r e n t P a t h   l i k e   @ N e x t C l a s s P a t h + ' % '   a n d   Y X _ R o o t I D = @ P r v _ R o o t I D ) 
 
                                 / * BlQR{|v;`pe* / 
 
                                 s e t   @ P r v _ C h i l d N u m = @ P r v _ C h i l d N u m + 1 
 
                             
 
                                 ( s e l e c t   @ P r v _ P r e v I D = Y X _ P r e v I D   f r o m   Y X _ N e w s C l a s s   w h e r e   Y X _ I D = @ F _ P r e v I D ) 
 
                                 
 
                                       / * O9eR{|vMOnT
NNvsQI D * / 
 
                                                 u p d a t e   Y X _ N e w s C l a s s   s e t   Y X _ P r e v I D = @ Y X _ I D , Y X _ N e x t I D = @ F _ N e x t I D , 
 
                                                   Y X _ O r d e r I D = Y X _ O r d e r I D + @ F _ C h i l d N u m   w h e r e   Y X _ I D = @ F _ P r e v I D 
 
                                                         / * O9eR{|Nvc^I D * / 
 
                                                         u p d a t e   Y X _ N e w s C l a s s   s e t   Y X _ O r d e r I D = Y X _ O r d e r I D + @ F _ C h i l d N u m   
 
                                                           w h e r e   Y X _ P a r e n t P a t h   l i k e   @ N e x t C l a s s P a t h + ' % '   a n d   Y X _ R o o t I D = @ P r v _ R o o t I D   
 
 	 	 	 / * * * * * * * * * * * * * * * * * * * * * * * * * / 
 
                                 / * * * * * * * * * * * * * * * * * / 
 
                                 / * * O9eR{|
N~R{|vn e x t I D * / 
 
                                 u p d a t e   Y X _ N e w s C l a s s   s e t   Y X _ N e x t I D = @ Y X _ I D   w h e r e   Y X _ I D = @ P r v _ P r e v I D 
 
 	 	 	 / * O9enR{|I D * / 
 
 	 	 	 s e t   @ T e m p P a t h = @ F _ P a t h + ' , ' + C o n v e r t ( v a r c h a r ( 1 0 0 ) , @ Y X _ I D ) 
 
       	 	 	 u p d a t e   Y X _ N e w s C l a s s   s e t   Y X _ P r e v I D = @ P r v _ P r e v I D , Y X _ N e x t I D = @ F _ P r e v I D , 
 
                                                 Y X _ O r d e r I D = Y X _ O r d e r I D - @ P r v _ C h i l d N u m   w h e r e   Y X _ I D = @ Y X _ I D 
 
                                                         / * O9eR{|Nvc^I D * / 
 
                                                 u p d a t e   Y X _ N e w s C l a s s   s e t   Y X _ O r d e r I D = Y X _ O r d e r I D - @ P r v _ C h i l d N u m   
 
                                                 w h e r e   Y X _ P a r e n t P a t h   l i k e   @ T e m p P a t h + ' % '   a n d   Y X _ R o o t I D = @ F _ R o o t I D     
 
 	 	 	 / * * * * * * * * * * * * * / 
 
 	 	 i f   @ F _ N e x t I D   > 0 
 
 	 	 b e g i n 
 
                                     / * O9eN*Nv4N{|+RvP r e v I D * / 
 
                                 U p d a t e   Y X _ N e w s C l a s s   s e t   Y X _ P r e v I D = @ F _ P r e v I D   w h e r e   Y X _ I D = @ F _ N e x t I D 
 
 	 	 e n d 
 
 	 	 
 
 	 e n d 
 
 
 
 ~ 
 
 
 
 C R E A T E   p r o c   U p P r o d u c t D Z 
 
 @ P r o _ D Z   v a r c h a r ( 5 0 ) 
 
 a s 
 
 u p d a t e   Y X _ P r o d u c t   s e t   Y X _ P r o D Z = ( Y X _ P r o D Z + ' , ' + @ P r o _ D Z ) 
 
 
 
 ~ 
 
 
 
 / * - - - - - - - - - - - mReS- - - - - - - - - - * / 
 
 C R E A T E   p r o c e d u r e   Y X _ C M S A d d C h a n n e l   
 
 @ Y X _ C h a n n e l N a m e     v a r c h a r ( 5 0 ) ,                         / * S
Ty* / 
 
 @ Y X _ C h a n n e l E x c     v a r c h a r ( 1 0 0 ) ,                       / * Slʑ* / 
 
 @ Y X _ C h a n n e l T y p e     i n t ,                                   / * S{|W* / 
 
 @ Y X _ C h a n n e l M o d e   i n t ,                                   / * SeHh* / 
 
 @ Y X _ C h a n n e l D i r   v a r c h a r ( 5 0 ) ,                 / * SeN9Y* / 
 
 @ Y X _ C h a n n e l S t a t   i n t ,                               / * Sr`* / 
 
 @ Y X _ C h a n n e l U r l   v a r c h a r ( 5 0 ) ,           / * Yޏc0W@W* / 
 
 @ Y X _ T e m p l a t e   i n t 
 
 a s 
 
 i n s e r t   i n t o   Y X _ C h a n n e l   ( Y X _ C h a n n e l N a m e , Y X _ C h a n n e l E x c , Y X _ C h a n n e l T y p e , Y X _ C h a n n e l M o d e , Y X _ C h a n n e l D i r , Y X _ C h a n n e l S t a t , Y X _ C h a n n e l U r l , Y X _ T e m p l a t e ) 
 
 v a l u e s   ( @ Y X _ C h a n n e l N a m e , @ Y X _ C h a n n e l E x c , @ Y X _ C h a n n e l T y p e , @ Y X _ C h a n n e l M o d e , @ Y X _ C h a n n e l D i r , @ Y X _ C h a n n e l S t a t , @ Y X _ C h a n n e l U r l , @ Y X _ T e m p l a t e ) 
 
 
 
 ~ 
 
 
 
 C R E A T E   P R O C E D U R E   p a g i n a t i o n 
 
 @ t b l N a m e   v a r c h a r ( 2 5 5 ) ,   - -   h
T  
 
 @ s t r G e t F i e l d s   v a r c h a r ( 1 0 0 0 )   =   ' * ' ,   - -    ԏVvR  
 
 @ f l d N a m e   v a r c h a r ( 2 5 5 ) = ' ' ,   - -   c^vW[k
T  
 
 @ P a g e S i z e   i n t   =   1 0 ,   - -   u:\[  
 
 @ P a g e I n d e x   i n t   =   1 ,   - -   ux  
 
 @ d o C o u n t   b i t   =   0 ,   - -   ԏVU_;`pe,   ^  0   <PRԏV  
 
 @ O r d e r T y p e   b i t   =   0 ,   - -   nc^{|W,   ^  0   <PRM^  
 
 @ s t r W h e r e   v a r c h a r ( 1 5 0 0 )   =   ' '   - -   gagN  ( la:   
NR  w h e r e )   
 
 A S   
 
 d e c l a r e   @ s t r S Q L   v a r c h a r ( 5 0 0 0 )   - -   ;NS  
 
 d e c l a r e   @ s t r T m p   v a r c h a r ( 1 1 0 )   - -   4NeSϑ  
 
 d e c l a r e   @ s t r O r d e r   v a r c h a r ( 4 0 0 )   - -   c^{|W  
 
 i f   @ d o C o u n t   ! =   0   
 
 b e g i n   
 
 i f   @ s t r W h e r e   ! = ' '   
 
 s e t   @ s t r S Q L   =   ' s e l e c t   c o u n t ( * )   a s   T o t a l   f r o m   [ '   +   @ t b l N a m e   +   ' ]   w h e r e   ' + @ s t r W h e r e   
 
 e l s e   
 
 s e t   @ s t r S Q L   =   ' s e l e c t   c o u n t ( * )   a s   T o t a l   f r o m   [ '   +   @ t b l N a m e   +   ' ] ' 
 
 e n d   
 
 - - N
NNxva`/fYg@ d o C o u n t  OǏegv
N/f0 1\gbL;`pe~0NNv@b	gNx/f@ d o C o u n t :N0 v`Q  
 
 e l s e   
 
 b e g i n   
 
 i f   @ O r d e r T y p e   ! =   0   
 
 b e g i n   
 
 s e t   @ s t r T m p   =   ' < ( s e l e c t   m i n '   
 
 s e t   @ s t r O r d e r   =   '   o r d e r   b y   [ '   +   @ f l d N a m e   + ' ]   d e s c '   
 
 - - Yg@ O r d e r T y p e 
N/f0 1\gbLM^ُS_͑  
 
 e n d   
 
 e l s e   
 
 b e g i n   
 
 s e t   @ s t r T m p   =   ' > ( s e l e c t   m a x '   
 
 s e t   @ s t r O r d e r   =   '   o r d e r   b y   [ '   +   @ f l d N a m e   + ' ]   a s c '   
 
 e n d   
 
 i f   @ P a g e I n d e x   =   1   
 
 b e g i n   
 
 i f   @ s t r W h e r e   ! =   ' '   
 
 s e t   @ s t r S Q L   =   ' s e l e c t   t o p   '   +   s t r ( @ P a g e S i z e )   + '   ' + @ s t r G e t F i e l d s +   '   f r o m   [ '   +   @ t b l N a m e   +   ' ]   w h e r e   '   +   @ s t r W h e r e   +   '   '   +   @ s t r O r d e r   
 
 e l s e   
 
 s e t   @ s t r S Q L   =   ' s e l e c t   t o p   '   +   s t r ( @ P a g e S i z e )   + '   ' + @ s t r G e t F i e l d s +   '   f r o m   [ ' +   @ t b l N a m e   +   ' ]   ' +   @ s t r O r d e r   
 
 - - Yg/f,{ Nu1\gbLN
NNxُ7hOR_gbL^  
 
 e n d   
 
 e l s e   
 
 b e g i n   
 
 - - NNNxKNN@ s t r S Q L NwckgbLvS Q L Nx  
 
 s e t   @ s t r S Q L   =   ' s e l e c t   t o p   '   +   s t r ( @ P a g e S i z e )   + '   ' + @ s t r G e t F i e l d s +   '   f r o m   [ '   
 
 +   @ t b l N a m e   +   ' ]   w h e r e   [ '   +   @ f l d N a m e   +   ' ] '   +   @ s t r T m p   +   ' ( [ ' +   @ f l d N a m e   +   ' ] )   f r o m   ( s e l e c t   t o p   '   +   s t r ( ( @ P a g e I n d e x - 1 ) * @ P a g e S i z e )   +   '   [ ' +   @ f l d N a m e   +   ' ]   f r o m   [ '   +   @ t b l N a m e   +   ' ] '   +   @ s t r O r d e r   +   ' )   a s   t b l T m p ) ' +   @ s t r O r d e r   
 
 i f   @ s t r W h e r e   ! =   ' '   
 
 s e t   @ s t r S Q L   =   ' s e l e c t   t o p   '   +   s t r ( @ P a g e S i z e )   + '   ' + @ s t r G e t F i e l d s +   '   f r o m   [ '   
 
 +   @ t b l N a m e   +   ' ]   w h e r e   [ '   +   @ f l d N a m e   +   ' ] '   +   @ s t r T m p   +   ' ( [ '   
 
 +   @ f l d N a m e   +   ' ] )   f r o m   ( s e l e c t   t o p   '   +   s t r ( ( @ P a g e I n d e x - 1 ) * @ P a g e S i z e )   +   '   [ '   
 
 +   @ f l d N a m e   +   ' ]   f r o m   [ '   +   @ t b l N a m e   +   ' ]   w h e r e   '   +   @ s t r W h e r e   +   '   '   
 
 +   @ s t r O r d e r   +   ' )   a s   t b l T m p )   a n d   '   +   @ s t r W h e r e   +   '   '   +   @ s t r O r d e r   
 
 e n d   
 
 e n d   
 
 e x e c   ( @ s t r S Q L ) 
 
 
 
 
 
 
 
 