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

Procedure


أحمد السيد احمد

Recommended Posts

create or replace procedure count_space(x1 varchar2)
is 
x number(5);
y varchar2(1);
z number(20);
n number(10);
begin
select length(x1) into z from dual;
x:= 0; 
n :=1;
for i in 1..z loop
select substr(x1,n,1) into y from dual;
if y = ' ' then x := x+1; end if;
n:= n+1;
end loop;
dbms_output.put_line(x);
end count_space;



وللتنتفيذ مثلا :

exec  count_space('the first day in the work is the beast one');


والنتيجه

9

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

  • بعد 2 أسابيع...

السلام عليكم
------------------

مشكور اخى احمد

و هناك هذه الطريقة ايضا


SELECT   LENGTH ('Ellcome Every Body in Arab Oracle Group')
   - LENGTH (REPLACE ('Ellcome Every Body in Arab Oracle Group', ' ', '')) Space_count
 FROM DUAL

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

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

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

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

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

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

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

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