求助:两个 t-sql转plsql语句
第一个:
select max(convert(int,TargetCode)) from tbTargetInfo
注:报错信息为“int标识符无效”。TargetCode类型为VARCHAR2(4)
第二个
select * from
(select * from tbTargetInfo where TargetCode = '0001') as A
left join
(select ManageDeptCode,ManageDeptName as ManageDeptNameC from tbManageDept) as B
on A.AuditDeptCode = B.ManageDeptCode
注:报错信息为“sql命令未正确结束”
TargetCode类型为VARCHAR2(4)
A表AuditDeptCode 和B表ManageDeptCode 的类型均为VARCHAR2(4)
------解决方案--------------------第一个
select max(to_number(TargetCode)) from tbTargetInfo
第二个
select *
from (select * from tbTargetInfo where TargetCode = '0001') A
left join (select ManageDeptCode, ManageDeptName as ManageDeptNameC
from tbManageDept) B on A.AuditDeptCode = B.ManageDeptCode
------解决方案--------------------select max(to_number(TargetCode)) from tbTargetInfo;
select * from
(select * from tbTargetInfo where TargetCode = '0001') A
left join
(select ManageDeptCode,ManageDeptName as ManageDeptNameC from tbManageDept) B
on A.AuditDeptCode = B.ManageDeptCode;
------解决方案--------------------
--1、oracle中转换类型有专门的函数 常用的有
to_char --转成字符串
to_mumber --转成数字
to_date --转成日期
--你这个用 to_number
--2、oracle里面和sqlserver里面的语法有点区别,在给子查询起别名的时候不能加 AS
--你写的sql,在子查询里后面 把AS 去掉,sqlserver也不会报错
--这样oracle和sqlserver就可以通用了
select * from
(select * from tbTargetInfo where TargetCode = '0001') A
left join
(select ManageDeptCode,ManageDeptName as ManageDeptNameC from tbManageDept) B
on A.AuditDeptCode = B.ManageDeptCode
------解决方案--------------------一 convert这不是oracle中的函数
二 as 不能给表起别名