本篇內(nèi)容主要講解“數(shù)據(jù)庫(kù)中的記錄類型判斷非空的辦法是什么”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“數(shù)據(jù)庫(kù)中的記錄類型判斷非空的辦法是什么”吧!
網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站介紹好的網(wǎng)站是理念、設(shè)計(jì)和技術(shù)的結(jié)合。創(chuàng)新互聯(lián)建站擁有的網(wǎng)站設(shè)計(jì)理念、多方位的設(shè)計(jì)風(fēng)格、經(jīng)驗(yàn)豐富的設(shè)計(jì)團(tuán)隊(duì)。提供PC端+手機(jī)端網(wǎng)站建設(shè),用營(yíng)銷思維進(jìn)行網(wǎng)站設(shè)計(jì)、采用先進(jìn)技術(shù)開源代碼、注重用戶體驗(yàn)與SEO基礎(chǔ),將技術(shù)與創(chuàng)意整合到網(wǎng)站之中,以契合客戶的方式做到創(chuàng)意性的視覺(jué)化效果。
我創(chuàng)建了如下的包:
CREATE OR REPLACE PACKAGE plch_pkg IS TYPE info_rt IS RECORD ( name VARCHAR2 (100) , dob DATE ); TYPE info_plus_rt IS RECORD ( group_name VARCHAR2 (100) , group_total NUMBER , more_info info_rt ); END; /
哪些選項(xiàng)在執(zhí)行后將會(huì)顯示 "NOT NULL"?
(A)
DECLARE l_my_record plch_pkg.info_plus_rt; BEGIN l_my_record.group_name := 'Oracle Bloggers'; l_my_record.more_info.dob := SYSDATE; IF l_my_record IS NOT NULL THEN DBMS_OUTPUT.put_line ('NOT NULL'); ELSE DBMS_OUTPUT.put_line ('NULL'); END IF; END; /
SQL> DECLARE 2 l_my_record plch_pkg.info_plus_rt; 3 BEGIN 4 l_my_record.group_name := 'Oracle Bloggers'; 5 l_my_record.more_info.dob := SYSDATE; 6 7 IF l_my_record IS NOT NULL 8 THEN 9 DBMS_OUTPUT.put_line ('NOT NULL'); 10 ELSE 11 DBMS_OUTPUT.put_line ('NULL'); 12 END IF; 13 END; 14 / DECLARE l_my_record plch_pkg.info_plus_rt; BEGIN l_my_record.group_name := 'Oracle Bloggers'; l_my_record.more_info.dob := SYSDATE; IF l_my_record IS NOT NULL THEN DBMS_OUTPUT.put_line ('NOT NULL'); ELSE DBMS_OUTPUT.put_line ('NULL'); END IF; END; ORA-06550: 第 7 行, 第 7 列: PLS-00306: 調(diào)用 'IS NOT NULL' 時(shí)參數(shù)個(gè)數(shù)或類型錯(cuò)誤 ORA-06550: 第 7 行, 第 4 列: PL/SQL: Statement ignored SQL>
(B)
DECLARE l_my_record plch_pkg.info_plus_rt; BEGIN l_my_record.group_name := 'Oracle Bloggers'; l_my_record.more_info.dob := SYSDATE; IF l_my_record.group_name IS NOT NULL OR l_my_record.group_total IS NOT NULL OR l_my_record.more_info IS NOT NULL THEN DBMS_OUTPUT.put_line ('NOT NULL'); ELSE DBMS_OUTPUT.put_line ('NULL'); END IF; END; /
SQL> DECLARE 2 l_my_record plch_pkg.info_plus_rt; 3 BEGIN 4 l_my_record.group_name := 'Oracle Bloggers'; 5 l_my_record.more_info.dob := SYSDATE; 6 7 IF l_my_record.group_name IS NOT NULL 8 OR l_my_record.group_total IS NOT NULL 9 OR l_my_record.more_info IS NOT NULL 10 THEN 11 DBMS_OUTPUT.put_line ('NOT NULL'); 12 ELSE 13 DBMS_OUTPUT.put_line ('NULL'); 14 END IF; 15 END; 16 / DECLARE l_my_record plch_pkg.info_plus_rt; BEGIN l_my_record.group_name := 'Oracle Bloggers'; l_my_record.more_info.dob := SYSDATE; IF l_my_record.group_name IS NOT NULL OR l_my_record.group_total IS NOT NULL OR l_my_record.more_info IS NOT NULL THEN DBMS_OUTPUT.put_line ('NOT NULL'); ELSE DBMS_OUTPUT.put_line ('NULL'); END IF; END; ORA-06550: 第 9 行, 第 10 列: PLS-00306: 調(diào)用 'IS NOT NULL' 時(shí)參數(shù)個(gè)數(shù)或類型錯(cuò)誤 ORA-06550: 第 7 行, 第 4 列: PL/SQL: Statement ignored SQL>
(C)
DECLARE l_my_record plch_pkg.info_plus_rt; BEGIN l_my_record.group_name := 'Oracle Bloggers'; l_my_record.more_info.dob := SYSDATE; IF l_my_record.group_name IS NOT NULL OR l_my_record.group_total IS NOT NULL OR l_my_record.more_info.name IS NOT NULL OR l_my_record.more_info.dob IS NOT NULL THEN DBMS_OUTPUT.put_line ('NOT NULL'); ELSE DBMS_OUTPUT.put_line ('NULL'); END IF; END; /
SQL> DECLARE 2 l_my_record plch_pkg.info_plus_rt; 3 BEGIN 4 l_my_record.group_name := 'Oracle Bloggers'; 5 l_my_record.more_info.dob := SYSDATE; 6 7 IF l_my_record.group_name IS NOT NULL 8 OR l_my_record.group_total IS NOT NULL 9 OR l_my_record.more_info.name IS NOT NULL 10 OR l_my_record.more_info.dob IS NOT NULL 11 THEN 12 DBMS_OUTPUT.put_line ('NOT NULL'); 13 ELSE 14 DBMS_OUTPUT.put_line ('NULL'); 15 END IF; 16 END; 17 / NOT NULL PL/SQL procedure successfully completed SQL>
(D)
CREATE OR REPLACE FUNCTION plch_not_null_rec (rec_in IN plch_pkg.info_plus_rt) RETURN BOOLEAN IS BEGIN RETURN rec_in.group_name IS NOT NULL OR rec_in.group_total IS NOT NULL OR rec_in.more_info.name IS NOT NULL OR rec_in.more_info.dob IS NOT NULL; END; / DECLARE l_my_record plch_pkg.info_plus_rt; BEGIN l_my_record.group_name := 'Oracle Bloggers'; l_my_record.more_info.dob := SYSDATE; IF plch_not_null_rec (l_my_record) THEN DBMS_OUTPUT.put_line ('NOT NULL'); ELSE DBMS_OUTPUT.put_line ('NULL'); END IF; END; /
SQL> CREATE OR REPLACE FUNCTION plch_not_null_rec (rec_in IN plch_pkg.info_plus_rt) 2 RETURN BOOLEAN 3 IS 4 BEGIN 5 RETURN rec_in.group_name IS NOT NULL 6 OR rec_in.group_total IS NOT NULL 7 OR rec_in.more_info.name IS NOT NULL 8 OR rec_in.more_info.dob IS NOT NULL; 9 END; 10 / Function created SQL> DECLARE 2 l_my_record plch_pkg.info_plus_rt; 3 BEGIN 4 l_my_record.group_name := 'Oracle Bloggers'; 5 l_my_record.more_info.dob := SYSDATE; 6 7 IF plch_not_null_rec (l_my_record) 8 THEN 9 DBMS_OUTPUT.put_line ('NOT NULL'); 10 ELSE 11 DBMS_OUTPUT.put_line ('NULL'); 12 END IF; 13 END; 14 / NOT NULL PL/SQL procedure successfully completed SQL>
答案 CD 對(duì)記錄類型不能使用IS NOT NULL判斷,否則會(huì)出現(xiàn): PLS-00306: wrong number or types of arguments in call to 'IS NOT NULL' 這導(dǎo)致AB出現(xiàn)異常。 Steven Feuerstein建議你采用D的做法以便于重用代碼。
到此,相信大家對(duì)“數(shù)據(jù)庫(kù)中的記錄類型判斷非空的辦法是什么”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!
文章名稱:數(shù)據(jù)庫(kù)中的記錄類型判斷非空的辦法是什么
網(wǎng)站路徑:http://m.newbst.com/article28/jedgcp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、營(yíng)銷型網(wǎng)站建設(shè)、虛擬主機(jī)、靜態(tài)網(wǎng)站、關(guān)鍵詞優(yōu)化、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)