Ibatis Dynamic Column caching; Oracle row-to-column conversion; Oracle uses numbers or special characters as column aliases

Source: Internet
Author: User

1. ibatis automatically caches the column name ing of each query statement. If you dynamically generate a column name, it may cause invalid column names.

Ibaits caches the meta information to be queried. When generating dynamic columns, you must add
Remapresults = "true ".

2. When you want to use numbers or special characters as column aliases in Oracle SQL queries, you can use.

3. for Oracle row-to-column conversion, you must determine the queried column information in advance and use the sum and decode functions to summarize the column information.

For example:



<select id="queryZjhHzByRq" parameterClass="com.athena.paicjh.entity.paiczjhjs.Paiczjhjs" resultClass="java.util.HashMap" remapResults="true">select zcwlh || '(' || sum(sl) || ')' zcwlh<iterate property="beanList"> ,sum(decode(rksj, #beanList[].rksj#, sl, 0)) "$beanList[].rksj$" </iterate>  from (select to_char(jz.rksj, 'yyyy-mm-dd') rksj,               jz.zcwlh,               sum(nvl(jz.sl, 0)) sl,               jz.ptbz          from jh_zjh jz         where jz.usercenter = #usercenter#           and jz.rksj >= to_date(#start#, 'yyyy-mm-dd')           and jz.rksj <![CDATA[<=]]> to_date(#end#, 'yyyy-mm-dd')           <isNotEmpty prepend="and" property="zcwlh">zcwlh like $zcwlh$</isNotEmpty>         group by jz.rksj, jz.zcwlh, jz.ptbz        union all        select to_char(to_date(rksj, 'yyyymm'), 'yyyy-mm') rksj,               zcwlh,               sum(nvl(sl, 0)) sl,               '2' ptbz          from jh_yzjh         where usercenter = #usercenter#           and drbz = '0'           and to_date(rksj || '01', 'yyyymmdd') >= to_date(#start#, 'yyyy-mm-dd')           and to_date(rksj || '01', 'yyyymmdd') <![CDATA[<=]]> to_date(#end#, 'yyyy-mm-dd')           <isNotEmpty prepend="and" property="zcwlh">zcwlh like $zcwlh$</isNotEmpty>         group by rksj, zcwlh) t group by zcwlh order by zcwlh</select>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.