seo网站优化方案书,六安市建设网站市场信息价,孝感市最新消息,小程序开发入门教程trim标记是一个格式化的标记#xff0c;可以完成select#xff0c;update#xff0c;insert语句的格式化操作。trim元素的主要功能有四个#xff1a; #xff08;1#xff09;可以在包含的内容前加上某些前缀#xff0c;与之对应的属性是prefix#xff1b; #xff08… trim标记是一个格式化的标记可以完成selectupdateinsert语句的格式化操作。trim元素的主要功能有四个 1可以在包含的内容前加上某些前缀与之对应的属性是prefix 2也可以在包含的内容后加上某写后缀与之对应的属性是suffix 3可以把包含内容的首部某些内容覆盖即忽略对应的属性是prefixOverrides 4也可以把包含内容的尾部的某些内容覆盖对应的属性是suffixOverrides。 以下举例说明一下trim元素的应用场景
例子1
select * from user
trim prefixWHERE prefixoverrideAND|ORif testname ! null and name.length()0 AND name#{name}/ifif testgender ! null and gender.length()0 AND gender#{gender}/if
/trim 假如说name和gender的值都不为null的话打印的SQL为 select * from user where name xx and gender xx where后不存在and这是因为prefixOverridesAND|OR代表去掉第一个and或者是or。 例子2
update user
trim prefixset suffixoverride, suffix where id #{id} if testname ! null and name.length()0 name#{name} , /ifif testgender ! null and gender.length()0 gender#{gender} , /if
/trim 假如说name和gender的值都不为null的话打印的SQL为 update user set namexx, genderxx where idx 在genderxx后面不存在逗号而且自动加了一个set前缀和where后缀。 例子3
INSERT INTO S_NOTICE
trim prefix( suffix) suffixOverrides,ID,if testtitle ! nullTITLE,/ifif testcontent ! nullCONTENT,/ifif testnoticeStatus ! nullNOTICE_STATUS,/ifif testcreatedBy ! nullCREATED_BY,/ifCREATED_TS,if testlastUpdBy ! nullLAST_UPD_BY,/ifLAST_UPD_TS,
/trim
trim prefixvalues ( suffix) suffixOverrides,SYS_GUID(),if testtitle ! null#{title,jdbcTypeVARCHAR},/ifif testcontent ! null#{content,jdbcTypeVARCHAR},/ifif testnoticeStatus ! null#{noticeStatus,jdbcTypeVARCHAR},/ifif testcreatedBy ! null#{createdBy,jdbcTypeVARCHAR},/ifsystimestamp,if testlastUpdBy ! null#{lastUpdBy,jdbcTypeVARCHAR},/ifsystimestamp,
/trim