الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Transfer Data From Db To Other Db

مغلق
بدأه shayma'a في 16 ديسمبر 2002 · 12 رد · 998 مشاهدة · في قواعد بيانات Oracle
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السيد عمر باعقيل /السني/السادة الكرام مشرفي المنتدى

اتمنى منكم افادتي في كيفية عمل TUNNING للموضوع التالي:

أتعامل مع 2 DATABASES

1)الألية ان المستخدم يقرر تحديث معلومات من ANOTHER DB

بالتالي اريد عمل FORM خاص لذلك كي يستطيع هو القيام بالعملية

2)المعلومات المراد تحديثها عبارة عن MASTER-DETAIL

اريد نقلها بنفس DESIGHN TABLES AS MASTER -DETAIL IN MY OWN DB

3) يفترض ان المعلومات المحدثة لا تتعارض بالتكرار مع الEXISTING RECORD

4)قمت من خلال الFORM باستدعاء الDB PROCEDURE كما هو مرفق .

5)ثم عرفت IN MY OWN DATABASE

AFTER INSERT DATABASE TRIGGER ON THE MASTER TABLE TO GET IT'S DETAIL FROM THE DIFFERENT HOST DATABASE

الكود مرفق .

6) العملية ناجحة 100% لكنها تأخذ وقت كبير //لذلك انا ابحث عن طريقة مثلى تخدم الألية وبنفس الوقت لا تستغرق وقت من المستخدم .

لذلك اتمنى عليكم وانا اعلم انكم لن تخذلوني ان تساعدوني للوصول لأفضل طريقة

insert_trigger.txt

#2

الكود الخاص DB PROCEDURE

proc.txt

#3

السلام عليكم

اخت شيماء

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

والافضل في هذا الموضوع جزاه الله خيرا .

انا عندي اقتراح وهو ان تقومي بإنشاء Snapshot للجدول

الموجود في قاعدة البيانات الاولي ويتم انشاء هذا الSnapshot

في قاعدة البيانات التى لديكي - وهكذا يتم اخذ نسخه من بيانات الجدول

المطلوب " الموجود في قاعدة البيانات الرئيسيه " لل Snapshot الموجود

في قاعدة البيانات التى لديكي بشكل دوري - طبعا يمكنك جعل عمليه

الUpdate للSnapshot تتم يوميا او كل ساعه مثلا .

والله اعلم

عمر باعقيل

كندا - مونتريال

baaqeel@msn.com

#4

الأخت شيماء، لا أرى سببا لذلك، ولكن لدي شك في عمليه ال Indexing بالنسبة للجدولين، لذا أرجو ان توضحي لنا اللآتي:-

  • مكونات الجدولين، وهل هما متطابقين 100% ؟
  • ماهي الفهارس التي لديك في كل من الجدولين INDEXES؟
  • هل يوجد لديك constrains في هذه الجداول؟ وما هي؟

يعني باختصار تفصيل عن الجدولين وسأرد عليك بعدها ان شاء الله

#5

اشكركم جزيل الشكر على تعاونكم و تفاعلكم مع موضوعي .

ردا على أخي السيد عمر باعقيل ،، فكرة الsnapshots هي فكره جيدة

ولكن الصلاحيات المعطاة لي على dbatabase هي صلاحية select فقط

وهذا أمر اداري لا أستطيع تعديله .

أما الأخ السني ،،أود أن افهم منه ماذا يعني لا أرى سببا لذلك ،،هل يقصد بطء

العملية أم طريقتي لنقل البيانات ، عموما :

1) الملفان متطابقان 100% نفس الtable structures in the master&detail

2) اتمنى أن تكون قرأت الملف المرفق proc.txt

الذي به select the master records that match certain critiria in the host database and not in my own database& then insert it in my db

the critiria is

FROM SAD_GEN@ASY_ARCHIVE

WHERE

LST_OPE<> 'D'

AND SAD_NUM=0

AND ( SAD_ASMT_DATE IS NOT NULL )

AND ( SAD_RCPT_DATE IS NOT NULL OR SAD_TOTAL_TAXES=0)

AND ( SAD_ASMT_DATE BETWEEN B_DATE AND E_DATE)

AND (KEY_YEAR,KEY_CUO,KEY_DEC,KEY_NBER) NOT IN (

SELECT KEY_YEAR,KEY_CUO,KEY_DEC,KEY_NBER

FROM SAD_GEN)

);

4) insert-trigger.txt الملف المرفق أوضح به ان يقوم بعملية

select details records from the host db that match the critria of

the relation betwen master & detail

insert into my-db.sad_item

from sad_itm@asy_Archive a

where

A.SAD_NUM=0

AND A.KEY_YEAR=:NEW.KEY_YEAR

AND A.KEY_CUO=:NEW.KEY_CUO

AND A.KEY_DEC=:NEW.KEY_DEC

AND A.KEY_NBER=:NEW.KEY_NBER

5) الجزء الأيمن من العلاقة هو قيمة الحقل في الmaster بعد عملية insert in the master وهو pk in the master والرابط بين master&detail

in both hosts

6 ) الحزء الأيسر من العلاقة ، fk in the host db is an index on the table also

7) ملاحظة كرر ت عملية after insert triger

with the detail of the detail table

وراعيت عملية الjoin between تكون مبنية على indexes items

8) أتمنى ان اكون قد وضحت لك ماتريد ،، وشكرا لتعاونكم أيها الأفاضل .

9) قد وضحت سابقا أنني أود الانضمام الى مجموعتكم الرائعة من خلال التواصل مع أي فكرة في المنتدى .

#6

here is the answer

Dear shayma

Look at this file I wrot the answer inside this file!

Please reply to this forum if it works for you if not let us know!!!

thanks

--Muawia

#7

Dear Sister

Dont forget to drop the triger after you install my procedure...if you dont drop it you will have the same problem

make thisDROP

TRIGGER "TRIG_SAD_GEN_A_INSERT

Salam

"

#8

I forgot to add the file link sorry

shyama.txt

#9

سيدي الكريم //

قبل أن أٌقرأ ردك الوافي والذي سأجربه إن شاء الله ,,

جربت طريقة اخرى

قمت بانشاء داخل الform

cursor to select the master record from the host @asy_archive

and the inseert it on my database

after he complete the cursor loop ,make the commit command

وابقيت على database trigeer after insert on the master record to select his detail from the host @ asy_Archive

ولأن ال detail له أيضا detail

عملت after insert trigger on the first detail to select his details from the host also

لا تستطيع أن تتخيل الوقت القليل جدا الذي استغرقة خلال run the form

it takes only 5 minutes for a hUge data of master about (10000) record

and the detail maybe (60000)

لا أدري هل طريقتي لا زالت ليست الحل الأمثل ..

لكن لدي ملاحظة اولية على طريقتك

وهي أنك تفتح cursor بكل الملف وليس only the inserted master record

so you might insert in the detail records alredy exists which might make error cuze the detail record hs unique pk violate duplicates

شكرا يا سيدي الفاضل

#10

The only Think I did is I REMOVED the triger and i used cursor instad of that triger...CURSORS are FASTER than trigers all the time.

Try this method BUT pleaseI want to know if it worked for you or not..or if it is faster or not...THANKS

(DONT FORGET TO DROP THE TRIGER)

Salam

#11

dear sir,,i did exe the form with the new proc

infact it almost die,,infact i knew that this will happen

becuse in the insertion of the detail he compare all the master records

to get it's details from the host wehter they alredy inserted or fetched now,,besides i wrote in the insert of the detail not in part so that not to duplicate pk in the details

i'm very thankful for ur help,,& interset ,,i mean it,,and as i told u before

i wrote in the form cusrsor to get the master record

and enable the detail triggers to get it's detail once he insert in the master and the time comparing to the count of transfered data good

if you have anything to add ,plz do

thanks a lot

#12

Could you please type in arabic..Shyma..I canot do so because I have english system in here Iam in USA..So it will be appreciated to type in arabic here..

Second what did you mean by the proc. die?

did you dop the triger you already created?

And what did you mean execute the proc in the form?

this procedure MUST be executed in the database server side

please explain I am intersted to know what did happen..

Thank you

--Muawia

#13

سيدي الكريم /Muawia

اشكرك جزيل الشكر لتواصلك و اهتمامك ,,,

لقد نفذت ال proc على مستوى ال db بنفس الطريقة التي وضحتها مشكورا لي !!! وجدت ان الوقت المستغرق بالتنفيذ طويل جدا !! die

مع الملاحظة انني طبعا عملت drop for the triggers or it 'll cause an error

سبب long exe time

انه على ما تذكر

CURSOR shyma_cursor IS

SELECT KEY_YEAR,KEY_CUO ,KEY_DEC,KEY_NBER

FROM STAT.SAD_GEN

الذي تم تعريفه في بداية الproc

يستخدم لاجراء الinsert in the detail table

هذا الملف كبير جدا يجري المقارنة مع كل الملف ،، لاحضار تفصيلاتة وادخالها في ال detail table

المفروض ان الاضافات الجديدة on the master فقط هي التي يحضر لها التفصيلات والا كما قلت لك سيستغرق وقت كبير

بالاضافة انه يجب وضع شرط ان inserted detail record not alredy inserted

حسب طريقتك المقارنة مع كل master file not only the new inserted

والا سيحصل duplicate pk in the detail table

لذلك اضطريت لوضع not in restriction

ما قصدته بتنفيذ الproc في الفورم ،،هو استدعاؤه على أساس انه program unit

و بناء cursor to select the master records that match the critiriaو

and inserted in the masetr record

اتمنى ان اكون وضحت لك كل ما تحتاجه

هذا الموضوع مغلق.

مواضيع مشابهة