用SQL脚本 生成INSERT SQL语句

配置表B 中的数据,可以从A表中查询到,在实际配置时,通过sql脚本生成B表的insert脚本,最多用到的是sql中连接符【||】,以及双引号【''''】

 

例1:电销系统中地区出单机构关系表配置数据生成sql

select
'insert into tbl_area_org_code (area_code,area_name,parent_area_code ,yc_area_code,dept_code,dept_name,area_short_name ,quan_pin,dept_flag, id)
values ( '''',' ||
''''||substr(t.dept_abbr,0,2) ||'''' || ','||
''''|| '' ||'''' || ','||
''''||substr(t.dept_code,0,2) ||'''' || ','||
''''||t.dept_code ||'''' || ','||
''''||t.dept_abbr ||'''' || ',' ||
''''||'简称' ||'''' || ',' ||
''''|| fn_getpy(t.dept_abbr) ||'''' || ',' ||
''''||'1' ||'''' || ',' ||
''''|| AREA_ORG_CODE_SEQUENCE2.NEXTVAL ||'''' ||
');'
from tbl_cs_organization t where t.dept_code in(
'33047702');

 

注意:脚本中用到一个中文转拼音函数,详见:http://blog.youkuaiyun.com/stevendbaguo/article/details/22047811

转载于:https://www.cnblogs.com/liuyitan/p/7543292.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值