Advertisement
Guest User

Untitled

a guest
Dec 29th, 2015
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 5.42 KB | None | 0 0
  1. -------insert user date----------------------
  2. CREATE proc sp_user_register
  3. @name VARCHAR(20),
  4. @pass  VARCHAR(MAX),
  5. @mail  VARCHAR(140)
  6. AS
  7. BEGIN
  8. INSERT INTO [tbl_user] ([username],[password],[email])   VALUES  (@name,@pass,@mail);
  9. END
  10. GO
  11. sp_user_register 'Microsoft', 'micromicromicro', 'user@hotmail.com';
  12. GO
  13. sp_user_register 'google', 'gogogoole11ss', 'developer@google.com';
  14. GO
  15. sp_user_register 'mozilla', 'mozmoz115599', 'dev@mozilla.com';
  16. GO
  17. sp_user_register 'bebo_uwk', 'uwk910723', 'uwkbebo@hotmail.com';
  18. GO
  19. sp_user_register 'johnBA', 'jj_zz_2211', 'jjzz@gmail.com';
  20. GO
  21. sp_user_register 'Sofy_ZZZ', 'Sofy_ZZZ_!1!1', 'sof91@test.com';
  22. GO
  23. sp_user_register 'Jack', '8597145222', 'jck@ymail.com';
  24. GO
  25. sp_user_register 'Sallam', '11113333', 'sallam@null.com';
  26. GO
  27. sp_user_register 'Saed', 'n123n123', 'smsm@hotmail.com';
  28. GO
  29. sp_user_register 'Mike', '12345678', 'mike@gmail.com';
  30.  
  31. GO
  32. -------update user date----------------------
  33. CREATE proc sp_user_update
  34. @name VARCHAR(20),
  35. @newpass  VARCHAR(MAX),
  36. @newemail  VARCHAR(140)
  37. AS
  38. BEGIN
  39. UPDATE [tbl_user]
  40. SET [password] = @newpass,
  41.     email = @newemail
  42. WHERE [username] = @name
  43. END
  44. GO
  45. sp_user_update 'Mike', '1234567', 'mike@gmail.com'
  46.  
  47.  
  48. ------------------insert developer data-----------------
  49. GO
  50. CREATE proc sp_developer_register
  51. @x INT,
  52. @website text ,
  53. @phone_number VARCHAR(20),
  54. @address text
  55. AS
  56. BEGIN
  57. INSERT INTO  tbl_developer (developer_id,website,phone_number,[address])  
  58. VALUES  (@x,@website,@phone_number,@address);
  59. END
  60. GO
  61. sp_developer_register '10', 'microsoft.com', 'Silicon Valley, California, USA', '+1800-555-999'
  62. GO
  63. sp_developer_register '9', 'google.com', 'Silicon Valley, California, USA', '+1800-444-666'
  64. GO
  65. sp_developer_register '8', 'mozilla.com', 'USA', ''
  66. GO
  67. sp_developer_register '3', 'tanta.ga', '', ''
  68. GO
  69. sp_developer_register '1', '', 'Egypt', ''
  70. GO
  71.  
  72. ---------------------update developer data-----------
  73. GO
  74. CREATE proc sp_developer_update
  75. @x INT,-- the value of developer_id
  76. @newwebsite text ,
  77. @newphone_number VARCHAR(20),
  78. @newaddress text
  79. AS
  80. BEGIN
  81. UPDATE tbl_developer
  82. SET website = @newwebsite,
  83.     phone_number = @newphone_number,
  84.     [address] = @newaddress
  85. WHERE developer_id = @x
  86. END
  87. GO
  88. sp_developer_update '10', 'microsoft.com', 'Silicon Valley, California, USA', '+1800-555-999'
  89.  
  90. ---------------insert app data---------------
  91. GO
  92. CREATE proc sp_app_submit
  93. @app_name  VARCHAR(50),
  94. @category   INT,
  95. @version   VARCHAR(20),
  96. @discription  text,
  97. @icon text,
  98. @download_link text,
  99. @size_mb FLOAT
  100. AS
  101. BEGIN
  102. INSERT INTO [tbl_apps] ([app_name],category,[version],[description],icon,download_link,[size_mb],[download_count],[rating],[submit_date])
  103. VALUES(@app_name,@category,@version,@discription,@icon,@download_link,@size_mb,0,0,getdate())
  104. END
  105. GO
  106. sp_app_submit 'Firefox', '2', '43-stable', 'Open Source Web Broswer','http://test.mozilla.com/firefox-icon', 'http://firefox.com/download/43-stable',3.5;
  107.  
  108. GO
  109. ------------------update app data-----------
  110. CREATE proc sp_app_update
  111. @x INT,--the value of app_id
  112. @newapp_name  VARCHAR(50),
  113. @newcategory   INT,
  114. @newversion   VARCHAR(20),
  115. @newdiscription  text,
  116. @newicon text,
  117. @newdownload_link text
  118. AS
  119. BEGIN
  120. UPDATE [tbl_apps]
  121. SET [app_name] = @newapp_name,
  122.     [category] = @newcategory,
  123.     [version] = @newversion,
  124.     [description] = @newdiscription,
  125.     [icon] = @newicon,
  126.     [download_link] = @newdownload_link,
  127.     [submit_date] = getdate()
  128. WHERE app_id = @x
  129. END
  130. GO
  131. sp_app_update 7,'Firefox77', 2, '44-stable', ' Web Broswer','http://test.mozilla.com/firefox-icon', 'http://firefox.com/download/43-stable';
  132. GO
  133. -------------------insert category data--------------
  134. CREATE proc sp_category_insert
  135. @category_name  VARCHAR(20)
  136. AS
  137. BEGIN
  138. INSERT INTO tbl_category (category_name) VALUES (@category_name)
  139. END
  140. GO
  141. sp_category_insert 'Games';
  142. GO
  143. sp_category_insert 'Internet';
  144. GO
  145. sp_category_insert 'Productivity';
  146. GO
  147. sp_category_insert 'Network';
  148. GO
  149. sp_category_insert 'Security';
  150. GO
  151. sp_category_insert 'Programming';
  152. GO
  153. sp_category_insert 'Design';
  154. GO
  155. sp_category_insert 'Photography';
  156. GO
  157. sp_category_insert 'Scientific';
  158. GO
  159. sp_category_insert 'Engineering';
  160. GO
  161. sp_category_insert 'Medical';
  162.  
  163. GO
  164.  
  165. ------------------------update category data--------------------
  166. CREATE proc sp_category_update
  167. @x INT , --the value of the category
  168. @category_name  VARCHAR(20)
  169. AS
  170. BEGIN
  171. UPDATE tbl_category
  172. SET category_name= @category_name
  173. WHERE category_id= @x
  174. END
  175. GO
  176. sp_category_update  1 , 'games'
  177. GO
  178.  
  179. ------------------------list app for developer  x  ----------
  180. CREATE proc sp_apps_list_developer
  181. @x INT --developer id
  182. AS
  183. BEGIN
  184. SELECT [app_name] ,[category],[rating],[icon], developer FROM tbl_apps  a
  185. JOIN tbl_developer d
  186. ON a.developer = d.developer_id
  187. WHERE developer_id = @x
  188. END
  189. GO
  190. sp_apps_list_developer 1
  191. GO
  192.  
  193. ----------------------list app for category   x  ------------------
  194. CREATE proc sp_apps_list_category
  195. @x INT ---category id
  196. AS
  197. BEGIN
  198. SELECT [app_name] ,[rating],[icon], developer,[category] FROM tbl_apps  a
  199. JOIN tbl_category c
  200. ON a.[category] = c.category_id
  201. WHERE category_id = @x
  202.  
  203. END
  204. GO
  205. sp_apps_list_category 2
  206. GO
  207.  
  208. ------------------------------list app for os  x ----------------------
  209. CREATE proc sp_apps_for_os
  210. @x INT --os id
  211. AS
  212. BEGIN
  213.  
  214. SELECT [app_name] ,[rating],[icon], developer,[category] ,oa.os_id , oa.app_id FROM tbl_os_app  oa
  215. JOIN tbl_apps a
  216. ON oa.app_id = a.app_id
  217. WHERE os_id = @x
  218.  
  219. END
  220. GO
  221. sp_apps_for_os 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement