@
一,oracle中nvl()函数
NVL(表达式1,表达式2)
如果表达式1为空值,NVL返回值为表达式2的值,否则返回表达式1的值。该函数的目的是把一个空值(null)转换成一个实际的值。其表达式的值可以是数字型、字符型和日期型。但是表达式1和表达式2的数据类型必须为同一个类型。
二,oracle数据库中sql语句中with as 的用法
相当于建了个e临时表
with e as (select * from scott.emp e where e.empno=7499)
select * from e;
三,Oracle中的group by问题
这条查询语句最后的group by在oracle数据库中可以那样写,但是在gbase中不可以,因为上面已经把happen_time这个时间起了别名了,oracle数据库中,group by后面不能跟别名,gbase只能写别名,gbase只认识上面已经起了别名的名字。
适配gbase正确语句:
select to_char(happen_time,'yyyy-MM-dd') as happen_date,count(1) as cn from dy_work_reminder a
where a.dm_entry_person = '1'
and to_char(a.happen_time,'yyyy-MM')='2019-06'
and a.yxbz='Y' group by happen_date
四,trunc()的用法
在oracle中,trunc()的用法
1.select trunc(sysdate) from dual --2011-3-18 今天的日期为2011-3-18
2.select trunc(sysdate, 'mm') from dual --2011-3-1 返回当月第一天.
3.select trunc(sysdate,'yy') from dual --2011-1-1 返回当年第一天
4.select trunc(sysdate,'dd') from dual --2011-3-18 返回当前年月日
5.select trunc(sysdate,'yyyy') from dual --2011-1-1 返回当年第一天
6.select trunc(sysdate,'d') from dual --2011-3-13 (星期天)返回当前星期的第一天
7.select trunc(sysdate, 'hh') from dual --2011-3-18 14:00:00 当前时间为14:41
8.select trunc(sysdate, 'mi') from dual --2011-3-18 14:41:00 TRUNC()函数没有秒的精确
Oracle获取当前月份的第一天的sql语句
select trunc(sysdate, 'mm') from dual;
Gbase获取当前月份的第一天的sql语句
select trunc(current,'month') from sysmaster:sysdual;
注意:oracle中的dual是虚拟表,而gbase中的sysmaster:sysdual表同样是gbase的虚表。
五,批量插入
oracle批量插入
接口
int insterZqyjList(List zqyjList);
xml
insert into YZSYLGK_ZQYJ (YJ_ID, ID, YJ_NR,
TCR_NAME, TCRDW, CREATEDATE,
MODIFYDATE, USER_ID, ORG_ID
) select a.* from(
select #{item.yjId,jdbcType=VARCHAR}, #{item.id,jdbcType=VARCHAR}, #{item.yjNr,jdbcType=VARCHAR},
#{item.tcrName,jdbcType=VARCHAR}, #{item.tcrdw,jdbcType=VARCHAR}, #{item.createdate,jdbcType=TIMESTAMP},
#{item.modifydate,jdbcType=TIMESTAMP}, #{item.userId,jdbcType=VARCHAR}, #{item.orgId,jdbcType=VARCHAR} from dual
)a
适配GBase写法
insert into YZSYLGK_ZQYJ (YJ_ID, ID, YJ_NR,
TCR_NAME, TCRDW, CREATEDATE,
MODIFYDATE, USER_ID, ORG_ID
) select a.* from(
select '${item.yjId}' as YJ_ID, '${item.id}' as ID, '${item.yjNr}' as YJ_NR,
'${item.tcrName}'as TCR_NAME, '${item.tcrdw}' as TCRDW,
get_datetime('${item.createdate}