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

The esql compilation parameter of informix avoids the problem of SQL interrupt caused by / / comments

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

Share

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

In EXEC SQL, if the "/ /" symbol appears in the SQL statement, it causes the SQL statement from the end of ";" to be ignored, not just the current line. This often comes as a surprise to programmers.

For example, the following example program t1.ec.

Int main ()

{

EXEC SQL UPDATE vyktd

SET kahaoo= "1" / / comment 1 appears in SQL

WHERE kahaoo= "2"

/ / Note 2 appears in ordinary programs

Return 0

}

Normal compilation can be done by:

$esql-e t1.ec

$

In fact, the SQL executed will be UPDATE vyktd SET kahaoo= "1" without any conditions. Because the WHERE sentence is masked by note 1, it becomes a dangerous full table update!

In order to avoid this hidden trouble, you need to add the compilation parameter of esql-keepccomment, after which, if you write "/ /" in sql, it will compile the error.

$esql-keepccomment-e t1.ec

Esqlc: "t1.ec", line 4: Error-33051: Syntax error on identifier or symbol'/'.

1 error (s) found

$

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