Oracle 拼接字符串

语法

  1. 使用||拼接
  2. 如果内容中有单引号,则可在该单引号前面再加一个单引号进行转义

例子

比如有一个业务是根据需要生成多条插入语句

sql 复制代码
select 'insert into des_account_des_role(des_account_id, roles_id) values(''' || id || ''', ''' || (select id from des_role where workflowgroup = 'cor.client') || ''');' from des_account
where id in (
	select des_account_id from des_account_des_role 
	where roles_id in (select id from des_role where workflowgroup in ('chm.client', 'mch.client', 'phy.client'))
);
相关推荐
船神丿男人4 小时前
Redis 缓存击穿与雪崩实测:同键合并、TTL 错峰与迟到回填
数据库·redis·缓存
富贵儿9986 小时前
NL2SQL 实践手记 04:多表查询为什么更难——让模型找对表、连对关系
数据库·sql·ai·自然语言处理·langchain
Decay__6 小时前
PostgreSQL 索引与 SQL 优化 —— B-tree、GiST、GIN、BRIN、执行计划与索引设计实战
运维·数据库·sql·postgresql
Decay__11 小时前
PostgreSQL 内存与锁调优 —— shared_buffers、work_mem、MVCC 与锁等待排查
运维·数据库·sql·postgresql
30955666620 小时前
股票接口重试怎么分类:正常、空数组与错误响应的幂等处理
java·大数据·开发语言·数据库·php·api接口·股票数据api接口
城北徐宫1 天前
MySQL基础与库、表操作
数据库·mysql
码完就睡1 天前
Redis——初识 Redis
数据库·redis·缓存
飞花漫卷,情随岁迁1 天前
网络数据包转发与内核机制:小白概念科普
linux·运维·网络·数据库·mysql·oracle·智能路由器
wangxiaoxuan2171 天前
大模型怎样调用机器人能力:目标落地、工具调用与执行反馈
数据库·机器人·php