我想将此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;
答案 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;
UPDATE
和FROM
中)g.hierarchy
字符串的末尾开始倒计数看看是否有帮助。