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

MySQL Foundation: how to control when sql executes errors when setting up a bc website

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

Share

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

The normal execution of line sentences

Set up bc website Q

For example, to execute multiple normally executed statements, the example command is as follows:

Select version ()

Select "Hello LiuMiao" as "Greetings"

Select 20: 22 as Result

Using the HereDocument method, do the following:

Liumiaocn:~ liumiao$ mysql-uroot-proot select "Hello LiuMiao" as "Greetings"

> select 20: 22 as Result

> EOF

Mysql: [Warning] Using a password on the command line interface can be insecure.

Version ()

8.0.11

Greetings

Hello LiuMiao

Result

forty-two

Liumiaocn:~ liumiao$

The default action when an error occurs in the middle of a multiline statement

Oracle multiline statements continue to execute in sqlplus when there is an error, but what happens in the mysql console? We can add an incorrect syntax or command to the above statement to verify:

Mysql-uroot-proot select 20: 22 as Result

> EOF

Mysql: [Warning] Using a password on the command line interface can be insecure.

Version ()

8.0.11

ERROR 1064 (42000) at line 2: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'errorcommand' at line 1

Liumiaocn:~ liumiao$

As you can see, it stops by default when it encounters an error.

WHENEVER SQLERROR

It is controlled by WHENEVER SQLERROR in oracle. The syntax is as follows

WHENEVER SQLERROR {EXIT [SUCCESS | FAILURE | WARNING | n | variable |: BindVariable] [COMMIT | ROLLBACK] | CONTINUE [COMMIT | ROLLBACK | NONE]}

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