بتاريخ: 31 مارس 201213 سنة comment_222497 السادة / اعضاء المنتدى الكرام..............لدى قاعة بيانات صغيرة , وأود عمل trigger او sql statement تقوم بعمل حد اقصى للصفوف (Rows) داخل جدول معين. برجاء التكرم بالافادة للاهمية,,,,,,,, و شكرا,,,,,,, تقديم بلاغ
بتاريخ: 31 مارس 201213 سنة comment_222505 السلام عليكمبعيدا عن الهدف المطلوبفطبعا يمكن ذلك عن طريق plوذلك بعمل كود برمجى يقوم باحصاء عدد الصفوف وعند وصوله الى عدد معينفانه يرفض ادخال صف جديدمعكم ولكم نتواصل تقديم بلاغ
بتاريخ: 31 مارس 201213 سنة كاتب الموضوع comment_222506 الهدف ان الجدول المطلوب تحديد الصفوف له هو جدول الصلاحيات للمستخدمين , ولا اريد ان يزيد عدد المستخدمين عن الحد المسموح به. تقديم بلاغ
بتاريخ: 31 مارس 201213 سنة كاتب الموضوع comment_222512 اخى ahmedbb , هل يمكن ان تضع مثالا ل PL/SQL كود يقوم بعد الصفوف وفى حالة تجاوزها العدد المسموح , يتم رفض ادخال سجل جديد. تقديم بلاغ
بتاريخ: 31 مارس 201213 سنة comment_222515 السلام عليكم CREATE OR REPLACE TRIGGER --TRIGGER name BEFORE INSERT ON --table name REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW DECLARE v_count NUMBER; BEGIN IF INSERTING THEN ----- --select return count row IF /*count row */ >= 0 THEN RAISE_APPLICATION_ERROR(-20099,'YOU MSG '); END IF; -- EXCEPTION -- WHEN OTHERS THEN -- Consider logging the error and then re-raise --- RAISE; END ; تقديم بلاغ
بتاريخ: 31 مارس 201213 سنة comment_222532 السلام عليكم CREATE OR REPLACE TRIGGER --TRIGGER name BEFORE INSERT ON --table name REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW DECLARE v_count NUMBER; BEGIN IF INSERTING THEN ----- --select return count row IF /*count row */ >= 0 THEN RAISE_APPLICATION_ERROR(-20099,'YOU MSG '); END IF; -- EXCEPTION -- WHEN OTHERS THEN -- Consider logging the error and then re-raise --- RAISE; END ; You should add below code to declaration section to avoid mutual exception pragma autonomous_transaction تقديم بلاغ
بتاريخ: 1 أبريل 201213 سنة comment_222540 The best solution to do this to create materialized view and create check constraint on materialize view assume that your table as below CREATE TABLE USERS_TABLE (USER_ID VARCHAR2 (50), USER_NAME VARCHAR2 (100)); then create below materialize view CREATE MATERIALIZED VIEW LOG ON USERS_TABLE WITH ROWID(USER_ID) INCLUDING NEW VALUES; CREATE MATERIALIZED VIEW mv REFRESH FAST ON COMMIT AS SELECT 1 dummy, COUNT(1) no_of_rows FROM USERS_TABLE GROUP BY 1; Now add check constraint to materialize view ALTER TABLE MV ADD CONSTRAINT CHECK_MAX_USERS CHECK(no_of_rows<=3); Now if you insert more than 3 rows in USERS_TABLE, you will face exception تم تعديل 1 أبريل 201213 سنة بواسطة Mahmoud Ahmed El-Sayed تقديم بلاغ
بتاريخ: 1 أبريل 201213 سنة comment_222541 declarev numberbeginselect count(id) into vif v>3 thenRAISE Form_Trigger_Failure;end if تقديم بلاغ
بتاريخ: 1 أبريل 201213 سنة comment_222542 declarev numberbeginselect count(id) into vif v>3 thenRAISE Form_Trigger_Failure;end if The questioner ask how to do it from database(trigger) not from oracle forms تقديم بلاغ
بتاريخ: 1 أبريل 201213 سنة comment_222549 declarev numberbeginselect count(id) into vif v>3 thenRAISE Form_Trigger_Failure;end if The questioner ask how to do it from database(trigger) not from oracle forms he did not determain to use it in sql or in forms تقديم بلاغ
بتاريخ: 1 أبريل 201213 سنة comment_222556 السادة / اعضاء المنتدى الكرام..............لدى قاعة بيانات صغيرة , وأود عمل trigger او sql statement تقوم بعمل حد اقصى للصفوف (Rows) داخل جدول معين. برجاء التكرم بالافادة للاهمية,,,,,,,, و شكرا,,,,,,, The best solution to do this to create materialized view and create check constraint on materialize view assume that your table as below CREATE TABLE USERS_TABLE (USER_ID VARCHAR2 (50), USER_NAME VARCHAR2 (100)); then create below materialize view CREATE MATERIALIZED VIEW LOG ON USERS_TABLE WITH ROWID(USER_ID) INCLUDING NEW VALUES; CREATE MATERIALIZED VIEW mv REFRESH FAST ON COMMIT AS SELECT 1 dummy, COUNT(1) no_of_rows FROM USERS_TABLE GROUP BY 1; Now add check constraint to materialize view ALTER TABLE MV ADD CONSTRAINT CHECK_MAX_USERS CHECK(no_of_rows<=3); Now if you insert more than 3 rows in USERS_TABLE, you will face exception declarev numberbeginselect count(id) into vif v>3 thenRAISE Form_Trigger_Failure;end if The questioner ask how to do it from database(trigger) not from oracle forms he did not determain to use it in sql or in forms Please read #1 in post وأود عمل trigger او sql statement تقوم بعمل حد اقصى للصفوف (Rows) داخل جدول معين تقديم بلاغ
انضم إلى المناقشة
يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.