رفتار NULL در شرط های اوراکل
رفتار NULL را در عملگرهای مختلف را در Oracle مشاهده می کنیم:
مثال اول: همانطور که مشاهده می کنید NULL = NULL در اوراکل هیچ رکوردی بر نمیگردد.
select '1=0' as test from dual where 1 = 0
Union
select '1=1' as test from dual where 1 = 1
Union
select '1=NULL' as test from dual where 1 = NULL
Union
select 'NULL=NULL' as test from dual where NULL = NULL
Union
select '1=1' as test from dual where 1 = 1
Union
select '1=NULL' as test from dual where 1 = NULL
Union
select 'NULL=NULL' as test from dual where NULL = NULL
Result:
1=1
Result:
1=1
مثال دوم: همانطور که مشاهده می کنید NULL != NULL در اوراکل هیچ رکوردی بر نمیگردد.
select '1!=1' as test from dual where 1!= 1
Union
select '1!=NULL' as test from dual where 1 != NULL
Union
select 'NULL=NULL' as test from dual where NULL != NULL
Union
select '1!=NULL' as test from dual where 1 != NULL
Union
select 'NULL=NULL' as test from dual where NULL != NULL
Result:
---
---
مثال سوم: همانطور که مشاهده می کنید هر موقع از IS در اوراکل برای NULL استفاده کنیم رکورد بر میگرداند.
select '1 IS NULL' as test from dual where 1 IS NULL
Union
select 'NULL IS NULL' as test from dual where NULL IS NULL
Union
select 'NULL IS NOT NULL' as test from dual where NULL IS NOT NULL
Union
select '1 IS NOT NULL' as test from dual where 1 IS NOT NULL
Union
select 'NULL IS NULL' as test from dual where NULL IS NULL
Union
select 'NULL IS NOT NULL' as test from dual where NULL IS NOT NULL
Union
select '1 IS NOT NULL' as test from dual where 1 IS NOT NULL
Result:
1 IS NOT NULL
NULL IS NULL
1 IS NOT NULL
NULL IS NULL
مثال چهارم:
select 'True and NULL' as test from dual where ((1=1) and (NULL=NULL))
Union
select 'False and NULL' as test from dual where ((1=2) and (NULL=NULL))
Union
select 'True or NULL' as test from dual where ((1=1) or (NULL=NULL))
Union
select 'False and NULL' as test from dual where ((1=2) or (NULL=NULL))
Union
select 'False and NULL' as test from dual where ((1=2) and (NULL=NULL))
Union
select 'True or NULL' as test from dual where ((1=1) or (NULL=NULL))
Union
select 'False and NULL' as test from dual where ((1=2) or (NULL=NULL))
Result:
True or NULL
True or NULL
Rate this post
جستجو
مطالب اخیر
نظرات اخیر
- محمد در تبدیل تاریخ ها در اوراکل
- مجتبی خالقداد در پلاگین کد امنیتی اوراکل اپکس(ای پکس)
- سعید حسن پور در تبدیل تاریخ ها در اوراکل
- حسین در تبدیل تاریخ ها در اوراکل
- مهرسا سعادت در نقشه راه اوراکل APEX برای نسخه بعدی
برچسبها
AOP
APEX
apexrad
captcha
CDN
constraint
ebs
epg
forms
index
injection
iran
iranoug
longtype
Materialized-view
Oracle Application Express
orclapex
performance
Persian Sort
plsql
session
sql
standalone
variable scope
XE
امنیت
اوراکل
اپکس
ایران
ایندکس
ایپکس
بنبست
بهینه ساز
تاریخ شمسی
ترجمه
ترفند
حروف فارسی
داکیومنت
داینامیک
شمسی
مرتب سازی فارسی
نصب
نکته
پلاگین
یونیک