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

Wildcards in 2011-10-28 LIKE conditions

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Http://www.itpub.net/thread-1499223-10-1.html

93rd floor

I created this table and filled in the data:

CREATE TABLE plch_new_parts (partnum NUMBER, partname VARCHAR2 (50)) / BEGIN INSERT INTO plch_new_parts (partnum, partname) VALUES (1,'MY PART NUMBER 1'); INSERT INTO plch_new_parts (partnum, partname) VALUES (2, 'MY_PART_NUMBER_2'); INSERT INTO plch_new_parts (partnum, partname) VALUES (3,' MY_PART NUMBER_3'); COMMIT;END;/

What will appear on the screen when I execute the following code?

DECLARE l_counts DBMS_SQL.number_table;BEGIN l_counts (1): = 0; l_counts (2): = 0; l_counts (3): = 0; l_counts (4): = 0 FOR rec IN (SELECT partname FROM plch_new_parts ORDER BY partnum) LOOP IF rec.partname LIKE'MY PART NUMBER% 'THEN l_counts (1): = l_counts (1) + 1; END IF; IF rec.partname LIKE' MY_PART_NUMBER_%' THEN l_counts (2): = l_counts (2) + 1; END IF IF rec.partname LIKE 'MY_PART NUMBER_%' THEN l_counts (3): = l_counts (3) + 1; END IF; IF rec.partname LIKE' MY?PART?NUMBER?*' THEN l_counts (4): = l_counts (4) + 1; END IF; END LOOP; FOR indx IN 1. L_counts.COUNT LOOP DBMS_OUTPUT.put_line (l_counts (indx)); END LOOP;END;/

(A)

1110

(B)

1320

(C)

0 0 0 3

(D)

3333

(E)

1323

The running result is as follows

SQL > DECLARE 2 l_counts DBMS_SQL.number_table; 3 4 BEGIN 5 l_counts (1): = 0; 6 l_counts (2): = 0; 7 l_counts (3): = 0; 8 l_counts (4): = 0 9 10 FOR rec IN (SELECT partname 11 FROM plch_new_parts 12 ORDER BY partnum) 13 LOOP 14 IF rec.partname LIKE'MY PART NUMBER%'15 THEN 16 l_counts (1): = l_counts (1) + 1; 17 END IF 18 19 IF rec.partname LIKE 'MY_PART_NUMBER_%' 20 THEN 21 l_counts (2): = l_counts (2) + 1; 22 END IF; 23 24 IF rec.partname LIKE' MY_PART NUMBER_%' 25 THEN 26 l_counts (3): = l_counts (3) + 1; 27 END IF 28 29 IF rec.partname LIKE 'MY?PART?NUMBER?*' 30 THEN 31 l_counts (4): = l_counts (4) + 1; 32 END IF; 33 END LOOP; 34 35 FOR indx IN 1. L_counts.COUNT 36 LOOP 37 DBMS_OUTPUT.put_line (l_counts (indx)); 38 END LOOP; 39 END; 40 / 132PL/SQL procedure successfully completedSQL >

Answer B

The answer is on the 96th floor

2011-10-28 answer B. _ matches a single character,% matches any character, * and? It's a lie.

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