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

Write a PL-SQL to display and insert numbers from 20 to 30


أحساس غالي

Recommended Posts


السلام عليكم
لمن لديه الخبره في loop
الموضوع في المرفقات

Write a PL-SQL block to display and insert numbers from 20 to 30 in the table ODD_EVEN. Repeat the step using all 3 loop structures in PL-SQL

.[/size

بيانات الجدول من 20_ 30..... ODD-EVEN


CREATE TABLE ODD_EVEN(GIVEN_no number(8) primary key, description char(8) not null)

Gaven no description
20 EVEN
21 ODD
22 even

تم تعديل بواسطة أحساس غالي
رابط هذا التعليق
شارك

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

النوع الاول Basic Loop

Declare 
I number := 20; 
Begin 

   Loop
   Dbms_output.put_line(I||' is even'); 
    I := I + 1; 
    Dbms_output.put_line(I||' is odd');  
     Exit when i = 30 ;
     end loop;   
 End;



النوع الثانى While Loop


Declare 
I number := 20; 
Begin 

  while(I <=29) Loop 
   Dbms_output.put_line(I||' is even'); 
    I := I + 1; 
    Dbms_output.put_line(I||' is odd');  
     End Loop; 
        
 End; 



النوع الثالث For Loop


 Declare 
I number := 0; 
Begin 
 For I in 20..30 loop 
  If MOD(1,2) =0 then 
   Dbms_output.put_line(I||' is even'); 
    else
    Dbms_output.put_line(I||' is odd'); 
       end if;
     End Loop;         
 End; 



بالتوفيق ان شاء الله فى هذا الاختبار B) .... و بعدين مفيش اى مرفقات بس الاجابه دى بناءا على فهمى اتمنى ان تكون هو ما قصدته ...

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

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

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

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

×   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.

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

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

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