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

dynamic sql


kamel220371

Recommended Posts

essalam this is my first participation in this famous web-sit ,
i'd like write with arabic language but my system doesn't recognized it
well, i want describe this method
forexample: select count(*) from emp
result only filed of this table 'EMP'
execute this line for some tables,
so, you need to create procedure or function for execute them,
but there is another method, here it is..


DECLARE
CURSOR cur_tab ( v_param1 varchar2 ) IS
SELECT table_name,column_name
FROM user_tab_columns
WHERE table_name IN (SELECT table_name FROM tabs)
AND column_name LIKE v_param1||'%' ;
SQL_ORDER VARCHAR2(400);
vl_param1 VARCHAR2(50):=('&1');
vl_param2 VARCHAR2(50):=('&2');
vl_count NUMBER;
BEGIN
OPEN cur_tab( v_param1 => vl_param1);
LOOP
FETCH cur_tab INTO vl_table,vl_column;
EXIT WHEN cur_tab%notfound;
SQL_ORDER := ' SELECT COUNT(*) FROM ' || vl_table || ' WHERE '||vl_column||'= '||''''||vl_param2||'''';
execute IMMEDIATE vl_ordre_sql INTO vl_count ;
dbms_output.put_line (vl_count);
END LOOP;
CLOSE cur_tab;
END
--------------------------------------------------------
this my e_mail
[email protected]
i'm here i can help you





;

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

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

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

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

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

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

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

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