ssm oracle mysql_ssm 项目mysql 数据库迁移oracle

1.用在xml文件中,避免出现不必要的错误

2.mysql 用format(n1,2),函数返回类型是字符串,满三位会加一个逗号.在这里保留两位, 会四舍五入

针对数字类型转换建议使用 convert或者cast函数,用法如下:

format(param, 2) (不建议)

convert(param, decimal(12,2))(建议)

cast(param as decimal(12,2))(建议)

oracle 中 使用to_char(number,'FM999,999,999,999,990.99')代替  会四舍五入

3.mysql date_format(变量,‘yyyy-MM-dd’)

oracle  to_char(变量,‘yyyy-MM-dd’)转换成字符串,一般用于从数据库读取时间时,转换成字符串,

或者转换成日期类型比较to_date(变量,‘yyyy-MM-dd’),一般用于存储到数据库,将字符串转换成时间类型

4分页

mysql 用limit #{offset},#{limit}

oracle  列子:下面标红的是一个分页模板,不管有没有order by 语句 通用

select * from(

SELECT ROWNUM AS rowno,r.*FROM (

select

id ,

invoice_type invoiceType,

invoice_code invoiceCode,

invoice_no invoiceNo,

invoice_date invoiceDate,

gf_name gfName,

xf_name xfName,

invoice_amount invoiceAmount,

tax_amount taxAmount,

(select n.dictname from t_ac_dictdeta n where n.dicttype=1569 and n.dictcode=t.qs_status) qsStatus,

qs_date qsDate,

(select m.dictname from t_ac_dictdeta m where m.dicttype=1130 and m.dictcode=t.qs_type) qsType

from t_dx_record_invoice t

where1=1AND (SELECT c.current_tax_period FROM t_dx_tax_current c WHERE c.taxno=t.gf_tax_no)>=to_char(invoice_date,'%Y%m')

and invoice_type IN (1, 3, 14)

AND gf_tax_no in (SELECT taxno FROM t_ac_org where orgid in(SELECT orgid FROM t_ac_user_taxno where userid=#{map.userId}))and invoice_no like concat('%',concat(#{map.invoiceNo},'%'))

and qs_status=#{map.qsStatus}

and qs_type=#{map.qsType}

= #{map.qsDate1} ]]>

and invoice_type=#{map.invoiceType}

and gf_tax_no=#{map.gfName}

and xf_name like concat('%',concat(#{map.xfName},'%'))

= #{map.invoiceDate1} ]]>

and rzh_yesorno=0and invoice_status=0and invoice_amount>0and CASE WHEN= '2017-07-01 00:00:00'THEN

invoice_date+359ELSE

invoice_date+179END>= sysdate ]]>and tax_amount>=0and auth_status in (0,5)

order by invoice_date desc, id

) r

) table_alias

= #{map.offset} ]]>

5: 注意字段是date类型的时间可以直接加减,加减的是天数;

6: mysql 的now()函数在oracle 可以直接使用sysdate 直接赋值;

7:在mysql  和oracle 中通用的模糊查询 :like concat( '%', concat(#{map.name} , '%'))  这样写主要是因为在oracle中concat函数只有两个参数;

8: mysql 的ifnull(expr1 ,expr2)如果 expr1 不是 NULL,IFNULL() 返回 expr1,否则它返回 expr2

oracle nvl(expr1 ,expr2)  代替, 效果一样

9:mysql  TRUNCATE(X,Y)       TRUNCATE(x,y)返回数值x保留到小数点后y位的值(与ROUND最大的区别是不会进行四舍五入)

oracle   truc(X,Y)  代替

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值