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

عداد لعدد الخانات التى تم ادخالها فىقاعدة البيانات


ayman_tamim

Recommended Posts

rem -----------------------------------------------------------------------
rem Filename:   countall.sql
rem Purpose:    Count the number of rows for ALL tables in current schema
rem             using PL/SQL
rem Date:       15-Apr-2000
rem Author:     Eberhardt, Roberto (Bolton) ([email protected])
rem -----------------------------------------------------------------------

set serveroutput on size 1000000

DECLARE
 t_c1_tname      user_tables.table_name%TYPE;
 t_command       varchar2(200);
 t_cid           integer;
 t_total_records number(10);
 stat            integer;
 row_count       integer;
 t_limit         integer := 0;    -- Only show tables with more rows
 cursor c1 is select table_name from user_tables order by table_name;
BEGIN t_limit := 0;
 open c1;
 loop
       fetch c1 into t_c1_tname; exit when c1%NOTFOUND;
       t_command := 'SELECT COUNT(0) FROM '||t_c1_tname; t_cid := DBMS_SQL.OPEN_CURSOR;
       DBMS_SQL.PARSE(t_cid,t_command,dbms_sql.native);
       DBMS_SQL.DEFINE_COLUMN(t_cid,1,t_total_records);
       stat := DBMS_SQL.EXECUTE(t_cid);
       row_count := DBMS_SQL.FETCH_ROWS(t_cid);
       DBMS_SQL.COLUMN_VALUE(t_cid,1,t_total_records);
       if t_total_records > t_limit then
               DBMS_OUTPUT.PUT_LINE(rpad(t_c1_tname,55,' ')||
                       to_char(t_total_records,'99999999')||' record(s)');

       end if;
       DBMS_SQL.CLOSE_CURSOR(t_cid);
 end loop;
 close c1;
END;
/

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

ألف شكر أخونا المهندس أيمن ،،
لقد قمت بتجربة ال procedure
وجزاك الله خيرا،،
ولكن هل هناك إمكانية لشرحه خاصة وظيفة الإجراءات التالية:
DBMS_SQL.PARSE
و DBMS_SQL.DEFINE_COLUMN
و DBMS_SQL.COLUMN_VALUE
و
DBMS_SQL.CLOSE_CURSOr
من حيث المعاملات التى يتم تمريرها إليها .... فلقد بحثت فى oem ووجدت أنها جميعا جزء من الحزمة DBMS للمستخدم SYS لكن ما تؤديه من دور ليس واضحا بالنسبة لى ...
أرجو الإفادة إن أمكن
ومشكور مرة أخرى

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

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

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

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

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

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

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

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