Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of determining whether the record type in the database is not empty?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what is the method of judging non-empty record types in the database". Interested friends may wish to take a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what is the method of judging non-empty record types in the database?"

I created the following package:

CREATE OR REPLACE PACKAGE plch_pkgIS TYPE info_rt IS RECORD (name VARCHAR2, dob DATE); TYPE info_plus_rt IS RECORD (group_name VARCHAR2, group_total NUMBER, more_info info_rt); END;/

Which options will display "NOT NULL" after execution?

(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: line 7, column 7: PLS-00306: incorrect number or type of parameters when calling'IS NOT NULL' ORA-06550: line 7, column 4: PL/SQL: Statement ignoredSQL >

(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: line 9, column 10: PLS-00306: incorrect number or type of parameters when calling'IS NOT NULL' ORA-06550: line 7, column 4: PL/SQL: Statement ignoredSQL >

(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 NULLPL/SQL procedure successfully completedSQL >

(D)

CREATE OR REPLACE FUNCTION plch_not_null_rec (rec_in IN plch_pkg.info_plus_rt) RETURN BOOLEANISBEGIN 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 createdSQL > 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 NULLPL/SQL procedure successfully completedSQL > answer CD cannot use IS NOT NULL to determine the record type, otherwise it will appear: PLS-00306: wrong number or types of arguments in call to'IS NOT NULL', which causes an exception in AB. Steven Feuerstein recommends that you adopt the D approach to facilitate code reuse. At this point, I believe you have a deeper understanding of "what is the way to judge the non-empty type of records in the database". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report