当前位置:网站首页>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');
边栏推荐
- Amazon launched Amazon one palm payment system, and the contactless palm vein recognition market is expected to explode
- WPF implements MessageBox message prompt box with mask
- Servlet learning notes
- [网络]跨区域网络的通信学习路由表的工作原理
- 英语文章翻译-英语文章翻译软件-免费批量翻译
- 宝塔面板搭建小说CMS管理系统源码实测 - ThinkPHP6.0
- Saltstack system initialization
- How does app automated testing achieve H5 testing
- 第一次写博客
- 【笔记】《启示录》:产品经理的实践经验与反省清单
猜你喜欢

Question bank and answers of the latest national fire-fighting facility operators (intermediate fire-fighting facility operators) in 2022

彻底理解位运算——左移、右移

基于C语言的信息管理系统和小游戏

How navicate modifies the database name

企业级分布式爬虫框架入门

并发程序设计,你真的懂吗?

High beam software has obtained Alibaba cloud product ecological integration certification, and is working with Alibaba cloud to build new cooperation

English article translation - English article translation software - free batch translation

Pytoch: implementation of crossentropyloss and labelsmoothing

shared_ PTR and make_ Use of shared
随机推荐
Rust Getting Started Guide (rustup, cargo)
Report redirect after authorized login on wechat official account_ The problem of wrong URI parameters
navicate修改数据库名的方式
英文翻译葡萄牙语-批量英文转换葡萄牙语-各种语言免费互译转换
BeanFactory not initialized or already closed - call ‘refresh‘ before accessing beans via the Applic
Investment of 3.545 billion yuan! Gree Group participates in Xiaomi industry fund
How navicate modifies the database name
并发程序设计,你真的懂吗?
开盘暴涨215%!国产信号链芯片企业芯海科技登陆科创板
The mystery of ID number
Pagoda panel construction novel CMS management system source code measurement - thinkphp6.0
串口接收应用——环形缓冲buffer
Huawei shares in Nanjing core vision, laying out the solid-state laser radar chip field
远光软件获得阿里云产品生态集成认证,携手阿里云共建新合作
Search problems and technologies
How does app automated testing achieve H5 testing
Redis master-slave architecture (how to calculate sizeof function)
NPM installing and uninstalling global packages
WPF 实现带蒙版的 MessageBox 消息提示框
Leetcode day3 employees who exceed the manager's income