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

محتاج مساعدة في جملة Insert


ledow2007

Recommended Posts

إلى أعضاء المنتدي الكرام

محتاج مساعدة في شرح هذا الكود


Copy specific columns (and rows) from one table to another:

Insert into postables
 (postable_id, postable_name, dept, auth_name) 
VALUES( 
 (Select postables_seq.nextval),
 (Select 'some static text' postable_name),
 (Select dept      From cost_centres Where cc_code = 123), 
 (Select auth_name From authorisers Where auth_code = 'Z5f')
)
[b]
-- The same as above written to select alias names:[/b]

insert into postables
 (postable_id, postable_name, dept, auth_name)
 (select AA,BB,CC,DD 
 from (Select postables_seq.nextval AA), 
   (Select 'some static text'    BB),
   (Select dept                  CC From cost_centres Where cc_code = 123),
   (Select auth_name             DD From authorisers Where auth_code = 'Z5f'));

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

معقول الكود صعب لدرجة دي
بس أعتقد انه مش بالصعوبة على محترفي أوركل بالموقع ولكن أعتقد أنهم مشغولين........... منتظر الردود

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

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

1- First the insert statements must be wrote as next to run successfully:

INSERT INTO postables
           (postable_id,
            postable_name,
            dept, auth_name
           )
    VALUES ((SELECT postables_seq.NEXTVAL
               FROM DUAL),
            (SELECT 'some static text' postable_name
               FROM DUAL),
            (SELECT dept
               FROM cost_centres WHERE cc_code = 123), (SELECT auth_name
                                       FROM authorisers WHERE auth_code = 'Z5f')
           );

INSERT INTO postables
           (postable_id, postable_name, dept, auth_name)
  (SELECT aa, bb, cc, dd
     FROM (SELECT postables_seq.NEXTVAL aa
             FROM DUAL),
          (SELECT 'some static text' bb
             FROM DUAL),
          (SELECT dept cc
             FROM cost_centres WHERE cc_code = 123),
          (SELECT auth_name dd
             FROM authorisers WHERE auth_code = 'Z5f'));



2-It is no difference between the 2 statements, their job is one and its inserting rows into a table.

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

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

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

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

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

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

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

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