Skip to main content

الجزء ال18: الأجراء المخزن مع أخراج قيمة معينة Stored Procedure with Output Parameter

الجزء ال18: الأجراء المخزن مع أخراج قيمة معينة

Stored Procedure with Output Parameter

في الجزء ال17 تعلمنا كيفية انشاء اجراء وتنفيذه واعطاءه قيمة له, وفي هذا الجزء سنتعلم كيفية استرجاع قيمة منه, بالأضافة الى تعلم بعض اجراءات النظام المخزونة,
ربما يدور في بالك: في الجزء ال17 قمنا بأنشاء جمل استعلام داخل الأجراء وهي بالأساس تعمل على استرجاع بيانات؟! فما الفرق بينها وبين القيم المسترجعة في هذا الجزء؟! الجواب القيم المسترجعة عبر الSELECT لا يمكن استخدامها عبر اجراء اخر او داخل عملية معينة!, بينما في هذا الجزء سنتعلم كيفية استرجاع قيمة معينة وتخزينها في متغير واستعمال هذا المتغير في اجراء اخر كقيمة مدخلة, او لأستعمال تلك القيمة في عملية ما!.

مثال: اريد عمل اجراء معين لأسترجاع عدد الموظفين الكلي وتخزين ذلك العدد في متغير؟!
CREATE PROC spGetEmployeeCount
@emp_total int OUTPUT
AS
BEGIN
SELECT @emp_total = COUNT([ID])
FROM tblEmployees
END
في الأجراء اعلاه, المتغير @emp_total نوعه عدد, وتم تحديده كقيمة مخرجة عن طريق كلمة OUTPUT , وفي داخل هذا المتغير سيحتوي على عدد الموظفين الكلي.

الأن لتنفيذ ذلك الأجراء يتوجب اعلان متغير ونوعه , وبعدها استخدامه في تنفيذ الأجراء, وطبع ذلك المتغير:
DECLARE @emp_count INT
EXEC spGetEmployeeCount @emp_count OUTPUT
PRINT @emp_count




 والأن اذا كانت الميزانية للموظفين ثمان ملايين واريد توزيع تلك القيمة لكل موظف؟!
الحل:
 اول شيء معرفة عدد الموظفين الكلي : سبق وفعلنا ذلك في المثال اعلاه,
ثاني شيء: تقسيم الميزانية على عدد الموظفين وبعدها طبع القيمة كالأتي:
بعض اجراءات النظام المخزنة:
·       sp_help : يستخدم هذا الأجراء لأظهار تفاصيل الكائن المحدد ك(Table,trigger,stored procedure,view) كالأتي:

·       helptext : يستخدم هذا الأجراء لأظهار نص الأجراء المخزن(stored procedure) كالأتي:

·       sp_depends : يستخدم هذا الأجراء لتحقق ما اذا كان الكائن المحدد له صلة بكائن اخر كالأتي:

Comments

Popular posts from this blog

How To Play .srt Subtitles File in Windows Media Player

How To Play .srt Subtitles File in Windows Media Player links: https://sourceforge.net/projects/wmpsub/ wmp,.srt Subtitles File in Windows Media Player,How To Play .srt Subtitles File in Windows Media Player,How To,Safaa Al-Hayali,saf3al2a,srt subtitle in WMP,Windows,Windows Media Player,media,.ass,local subtitles

How to fix the disk is write protected

in this video tutorial, I'll show you how to remove/solve/fix the disk is write protected from USB flash drive. To download the necessary 2 files: Download >  SAFAA_ALHAYALI.IMG  - 1.18 MB Download >  Win32DiskImager-0.9.5-install.exe - 11.7 MB write protection,remove write protection,write protected,How to fix the disk is write protected,how to solve the disk is write protected,how to remove the disk is write protected,USB write protected,fix USB write protected,fix HDD write protected,how to,windows,USB flash drive ERROR,fix USB flash drive write protected,USB flash drive write protected

How To Connect PS4 Controller To a Laptop / PC

How To Connect PS4 Controller To a Laptop / PC Learn how easy it is to connect PS4 wireless controller to your computer (Laptop or PC) either by using Blutooth to pair your controller with the computer or using MicroUSB to USB male cable, but, you have to download a software to change the layout or to map the keys of PS4 to act as XBOX controller........ good luck and enjoy.......... Download the software to map the keys: CLICK HERE TO DOWNLOAD PS4,PS4 Controller,PC,Laptop,saf3al2a,How to,connect ps4 to laptop,ps4 controller to PC,playstation,playstation 4,Safaa Al-Hayali,games on PC