الانتقال إلى المحتوى

شرح Plsql


Fabled Warrior

Recommended Posts

بسم الله الرحمن الرحيم

سوف ابدا سلسله شرح لل plsql
الدرس الاول

PL/SQL STRUCTURE

-	Block Structure

Pl SQL program are divided up into structures know as blocks, with each block containing Pl SQL and SQL statements 
The typical PL SQL block has the following structure.

Declare         -- optional
           Declaration_statements – [ variables , constant , user defined exceptions , cursors ] 

Begin -- mandatory
          [sql statements , PL SQL statements ]

Exception    -- optional    
               [ Actions to perform when errors occur ]

End ;           -- mandatory

Every statement is terminated by a semicolon ; And block is terminated using the END keyword

-	Type of variables 

PL SQL Variables:

Scalar 
Such as [ number , varchar2 , Boolean , date ]

Composite 
Record that contain variables such as [ number , date ]

Reference

Large objects lob

Non-PL SQL Variables:

[ Bind variables , Host variables ]

-	Identifier variables in PL SQL

Identifier ( constant ) data type ( not null ) [ : = / default expression ] Or Using  % type attributes

-	Block Structure Types:

Anonymous block  -- Dose not have a name 
Subprograms 
Such as [ procedure , Function , trigger ]

-	Anonymous block examples 

1-	Display and Retrieve data
 
Select  Column Names
Into [ variables , records name ]
From table name
Where [ condition ]

Example:    

    Declare 
               V_ID              emp.empno%type;
               V_Name      emp.ename%type;
               V_Sal             emp.sal%type;
   Begin Select  Empno,Ename,Sal
   Into v_Id,V_Name,V_sal From       EMP
   Where Empno=7788;
   dbms_output.put_line(v_id||' ' ||v_Name|| ' ' ||To_Char(V_Sal));
   End;

2-	Insert case 

Begin Insert Into Emp ( empno , Ename)
Values ( 200,'islam');
End; Or Declare 
            V_empno     emp.empno%type:=&no;
            V_ename    emp.ename%type:='&name';
Begin Insert Into Emp ( empno , Ename)
Values (v_empno,V_ename);
End;

3-	Update case

Declare 
           V_sal_increase    emp.sal%type:=&sal;
Begin Update emp
Set sal=sal+v_sal_increase
Where empno=7788;
End;

4-	Delete case 

Declare 
         V_id    emp.empno%type:=&no;
Begin Delete from emp Where empno=v_id;
End;

رابط هذا التعليق
شارك

  • بعد 2 أسابيع...
  • بعد 1 شهر...

مشكور يا أخي على المعلومات القيمة
وإلى الأمام يا أخي .........

رابط هذا التعليق
شارك

  • بعد 1 شهر...
  • بعد 3 أسابيع...

جزاك الله خيرا ........................
جزاك الله خيرا ........................
جزاك الله خيرا ........................
جزاك الله خيرا ........................
جزاك الله خيرا ........................
جزاك الله خيرا ........................

رابط هذا التعليق
شارك

  • بعد 8 شهور...

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   تمت استعادة المحتوى السابق الخاص بك.   مسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

جاري التحميل
×
×
  • أضف...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية