SqlServer存储过程转换成Oracle储存过程语法常见问题
2016-10-27 10:20
555 查看
1. top order by 转换成 rownum order by 的问题 (子查询实现)
2. 已有数据的字段类型不匹配,通过下列语句修改。
3. 多个cast问题
4. if exists问题
5. SqlServer: with index()语法问题
6. nvl(date,0) 问题
7. top 赋值问题
8. declare的变量只能跟在后面的begin end 语句块使用
9. 字符串拼接问题
10. Oracle异常信息打印
11. SqlServer:select into 语法问题
同级情况下的优先处理顺序: sqlserver: 先order by 再top oracle: 先rownum 再 order by
2. 已有数据的字段类型不匹配,通过下列语句修改。
alter table css_sed rename column action to myaction; alter table css_sed add (action varchar2(20)); update css_sed set action = myaction; alter table css_sed drop column myaction;
3. 多个cast问题
isnull(cast(cast(GR_WT as int) as varchar),'') sqlserver nvl(cast(trunc(cntr_row.GR_WT) as varchar2),'') plsql
4. if exists问题
oracle 没有这个语法 解决方法: 拿一个临时变量储存结果来判断 begin select count(*) into V_CNT from all_tables where table_name = 'CUST_BC_ONLINE'; if(V_CNT > 0) then execute immediate 'truncate table CUST_BC_ONLINE'; end if; end;
5. SqlServer: with index()语法问题
Oracle: 使用index hints实现 eg: select /*+ index(t i_t) */ * from t where use b29b rname='EYGLE';
6. nvl(date,0) 问题
isnull(MCS_SHPT_INFO.LAST_MOD_DT,0) < b.LAST_MOD_DT nvl(MCS_SHPT_INFO.LAST_MOD_DT,to_date('1900-01-01','yyyy-mm-dd'))) < b.LAST_MOD_DT
7. top 赋值问题
select top(5) @param = column from table sqlserver默认会把最后一条数据的字段赋值给指定参数,oracle会报错,就是选择出来的行数不匹配。
8. declare的变量只能跟在后面的begin end 语句块使用
9. 字符串拼接问题
oracle: null跟字符串拼接,会把null当成空字符串处理 sqlserver: null跟字符串拼接,会把整个字符串设置为一个空格
10. Oracle异常信息打印
dbms_output.put_line(dbms_utility.format_error_stack()); dbms_output.put_line('----------------------------------------------------------------'); dbms_output.put_line(dbms_utility.format_call_stack()); dbms_output.put_line('----------------------------------------------------------------'); dbms_output.put_line(dbms_utility.format_error_backtrace()); dbms_output.put_line('----------------------------------------------------------------'); dbms_output.put_line(sqlcode); dbms_output.put_line(sqlerrm);
11. SqlServer:select into 语法问题
SqlServer: select into table2 from table1 备注:table2可以不存在 Oracle: insert into table2 select * from table1 备注:要求table2必须存在
相关文章推荐
- Oracle面试过程中常见的二十个问题
- 学习 Oracle过程中几个常见问题的总结
- 讲解Oracle面试过程中常见的二十个问题
- [转载]讲解Oracle面试过程中常见的二十个问题
- Oracle面试过程中常见的二十个问题
- SQL Server vs Oracle 存储过程语法转换
- oracle安装常见问题-安装过程中遇到网络配置需求检查失败
- 讲解Oracle面试过程中常见的二十个问题
- 讲解Oracle面试过程中常见的二十个问题
- Oracle转到mysql遇到的常见问题和Oracle与MySQL语法区别。
- 讲解Oracle面试过程中常见的二十个问题
- 讲解Oracle面试过程中常见的二十个问题
- 讲解Oracle面试过程中常见的二十个问题
- oracle群集安装过程中的一些常见问题
- 讲解Oracle面试过程中常见的二十个问题
- 启动Oracle常见疑难问题分析
- 这周一个ORACLE问题的解决过程(ORA-12560:TNS:协议适配器错误! )
- Asp.net连接Oracle的常见问题?
- ORACLE应用中常见的傻瓜问题1000问
- [转载]补丁安装过程中常见问题