有没有一种方法可以将SQL Server的脚本转换为Oracle的脚本

时间:2019-06-14 15:22:13

标签: oracle oracle12c

我想将此SQL脚本运行到oracle中。我试图使用MSSQL脚本转换器。这是结果,但不起作用。

Update c
SET `c.SOURCE BLOCK LEVEL` = CONCAT('B',SUBSTR(g.HIERARCHY, GREATEST(-LENGTH(g.HIERARCHY),-LENGTH(RTRIM(g.HIERARCHY)) - 12)))
FROM mshist>dbo<CYCLE AS c
INNER JOIN `msmodel.dbo.GRADEBLOCK` AS g
ON `c.SOURCE BLOCK` IS NOT NULL AND
`c.SOURCE BLOCK LEVEL` IS NULL AND 
g.HIERARCHY LIKE 'root:Blocks:%' AND
`c.SOURCE BLOCK` = g.GRADEBLOCK_OID;


UPDATE C
SET `c.SOURCE BLOCK LEVEL` = CONCAT('S',SUBSTR(g.HIERARCHY, GREATEST(-LENGTH(g.HIERARCHY),-LENGTH(RTRIM(g.HIERARCHY)) - 16)))
FROM mshist.dbo AS c
INNER JOIN msmodel.dbo.GRADEBLOCK AS g
ON `c.SOURCE BLOCK` IS NOT NULL AND
`c.SOURCE BLOCK LEVEL` IS NULL AND
g.HIERARCHY LIKE 'root:Stockpiles:%' AND
`c.SOURCE BLOCK` = g.GRADEBLOCK_OID;

1 个答案:

答案 0 :(得分:0)

正确;您获得的代码将无法在Oracle中使用,但是类似这样的事情可能会发生:

update cycle c set
  c.source block level = 
   (select concat('B', substr(g.hierarchy, 
                              greatest(-length(g.hierarchy), -length(rtrim(g.hierarchy)) - 12)
                             )
                 )
    from gradeblock g
    where c.source block = g.gradeblock_oid
      and g.hierarchy like 'root:Blocks:%'
   )
where c.source block is not null
  and c.source block level is null;
  • 您可能需要调整表名(在UPDATEFROM中)
  • 子字符串的起始位置看起来可疑;看来这是一个负数的数字。是吗?如果是这样,那不是错误-只是意味着它将从g.hierarchy字符串的末尾开始倒计数

看看是否有帮助。