الانتقال إلى المحتوى
View in the app

A better way to browse. Learn more.

مجموعة مستخدمي أوراكل العربية

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

المساعدة فى دالة Decode

Featured Replies

بتاريخ:

السلام عليكم ورحمة الله وبركاته

كنت اود ان اعرف هل يمكن ان استخدم IN condition داخل الدالة decode

فهل هذا ممكن واذا كان ممكن برجاء توضيح كيفية كتابة الجملة

                   

بتاريخ:

السلام عليكم ورحمة الله وبركاته

 

الكتاب  Oracle PL/SQL Programming

Is It Null, or Is It Not?

A null collection is not the same thing as an initialized collection with zero elements. Image 100003 has no keywords, but the object view is mistakenly returning an empty but initialized collection. To get a true NULL instead, I can use a DECODE to test the number of keywords:

    CREATE OR REPLACE VIEW images_v       OF image_t       WITH OBJECT IDENTIFIER (image_id)    AS       SELECT i.image_id, BFILENAME('ROOTDIR', i.file_name),              i.file_type, i.bytes,              DECODE((SELECT COUNT(*)                        FROM keywords k2                      WHERE k2.image_id = i.image_id),                   0, NULL,                   CAST (MULTISET (SELECT keyword                                     FROM keywords k                                  WHERE k.image_id = i.image_id)                     AS keyword_tab_t))       FROM images i;

 

In other words, if there are no keywords, return NULL; otherwise, return the CAST/MULTISET expression. From this view, "SELECT ... WHERE image_id=100003" properly yields the following:

      IMAGE_ID KEYWORDS    ---------- -------------------------------------------------------        100003

 

But you might conclude that this amount of conceptual purity is not worth the extra I/O (or having to look at the convoluted SELECT statement).

 

5_تقرير لطباعة الحركات الشهرية لجميع الحسابات خلال السنة المحددة REP1005

الكود المكتوب داخل تصميم التقرير

select  act.ac_num , act.ac_nam ,  sum(vd-vc)

, sum(decode(to_char(dat,'mm'),'01', (vd-vc),0)) "mon  1"
, sum(decode(to_char(dat,'mm'),'02', (vd-vc),0)) "mon  2"
, sum(decode(to_char(dat,'mm'),'03', (vd-vc),0)) "mon  3"
, sum(decode(to_char(dat,'mm'),'04', (vd-vc),0)) "mon  4"
, sum(decode(to_char(dat,'mm'),'05', (vd-vc),0)) "mon  5"
, sum(decode(to_char(dat,'mm'),'06', (vd-vc),0)) "mon  6"
, sum(decode(to_char(dat,'mm'),'07', (vd-vc),0)) "mon  7"
, sum(decode(to_char(dat,'mm'),'08', (vd-vc),0)) "mon  8"
, sum(decode(to_char(dat,'mm'),'09', (vd-vc),0)) "mon  9"
, sum(decode(to_char(dat,'mm'),'10', (vd-vc),0)) "mon  10"
, sum(decode(to_char(dat,'mm'),'11', (vd-vc),0)) "mon  11"
, sum(decode(to_char(dat,'mm'),'12', (vd-vc),0)) "mon  12"
from act , v_ent_act

where  ac_num = d_c_num and to_number(to_char(dat,'YYYY')) = :P_year

group by   act.ac_num , act.ac_nam

order by act.ac_num ;

 

جزاك الله كل خير

بتاريخ:
  • كاتب الموضوع

اخى الكريم

الرد اللى حضرتك كاتبته انا مش فاهمة منه اى حاجة

انا كان سؤالى اذا كان ممكن استخدم  ال IN condition داخل ال decode function

مثلا

decode (side_code  in (2,4) ,sum(item_value),0)

يعنى الحقل اللى عايزة اسال عليه فى الدالة  عاوزة حالة اذا كان هذا المتغير ياخد اكتر من قيمة  وعاوزة احدد

تلك القيم من خلال الشرط in

بتاريخ:

لا مينفعش , استخدم CASE

SELECT CASE WHEN JOB IN ('CLERK','PRESIDENT') THEN SAL+7 FORM EMP ;

تم تعديل بواسطة eslam elbyaly

بتاريخ:

السلام عليكم ورحمة الله وبركاته

 

اخي الكريم

 

يمكنك وضع الشرط الذي تريده كما في الكود التالي

 

Select empno , ename , deptno , decode( deptno , 10 , 'ACCOUNTING',

20, 'RESEARCH',

30, 'SALES',

40, 'OPERATIONS',

'Non domestic') "departments employ"

from emp ;

 

Select empno , ename , deptno , decode( deptno , 10 , 'ACCOUNTING',

20, 'RESEARCH',

30, 'SALES',

40, 'OPERATIONS',

'Non domestic') "departments employ"

from emp

where deptno in( 10, 30 ) ;

 

جزاك الله كل خير

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

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

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

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

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

Account

Navigation

البحث

إعداد إشعارات المتصفح الفورية

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.