当前位置:网站首页>There is a 'single quotation mark' problem in the string when Oracle inserts data
There is a 'single quotation mark' problem in the string when Oracle inserts data
2022-07-28 19:45:00 【Shallow sorrow remembers fleeting years】

In our turn Excel When inserting table data into the table , Often use splicing insert How statements work ;
When excel When table data encounters single quotation marks , final insert into as follows :
insert into test(id,name,age)values(sys_guid(),' Zhang ' 3、 ... and ','28');
At this time SQL The execution will report an error .
Solution :
Judge val1,val2 Whether it contains single quotation marks , If single quotation mark is included , Then use single quotation marks ’ Replace with two single quotes ’' The format of .
Here is a simple tool class :
public static String replaceStr(String sourceStr) {
if (StrUtil.isBlank(sourceStr)) {
return "";
}
String substring = sourceStr.substring(1, sourceStr.length() - 1);
if (substring.contains("'")) {
String replaceStr = substring.replace("'", "''");
return "'" + replaceStr + "'";
}
return sourceStr;
}
Finally processed SQL The statement is as follows :
insert into test(id,name,age)values(sys_guid(),' Zhang '' 3、 ... and ','28');
边栏推荐
- The peak rate exceeds 2gbps! Qualcomm first passed 5g millimeter wave MIMO OTA test in China
- 串口接收应用——环形缓冲buffer
- 美国将提供250亿美元补贴,鼓励英特尔等芯片制造商迁回产线
- 英文翻译阿拉伯语-批量英文翻译阿拉伯语工具免费
- STC12C5A60S2 function description (STC12C5A60S2 is triggered by default)
- Basic concept and essence of Architecture
- Scrapy Spider源码分析
- NetCoreAPI操作Excel表格
- Sword finger offer II 109. unlock the password lock
- What parameters should be passed in calling integer or character array functions
猜你喜欢
随机推荐
Rust Getting Started Guide (modules and engineering structures)
MySQL8 Encrypting InnoDB Tablespaces
This customized keyboard turns me on~
How does app automated testing achieve H5 testing
Huawei shares in Nanjing core vision, laying out the solid-state laser radar chip field
There are five certificates in the soft examination advanced examination, which is more worth taking?
为什么在telnet登入界面下没有日志输出?
彻底理解位运算——与(&)、非(~)、或(|)、异或(^)
芯片功耗性能验证:从困境到超越
STC12C5A60S2 function description (STC12C5A60S2 is triggered by default)
My second blog - C language
Saltstack system initialization
Implementation of markdown editor in editor.md
测试开发备忘
navicate修改数据库名的方式
leetcode day3 查找重复的电子邮箱
毕马威中国:证券基金经营机构信息技术审计项目发现洞察
Iclr21 (classification) - future classic "vit" an image is worth 16x16 words (including code analysis)
【笔记】《启示录》:产品经理的实践经验与反省清单
Business visualization - let your flowchart "run" (4. Actual business scenario test)









