Oracle 到 Netezza 的迁移 - Connect Prior ...开始在 Netezza 中等效

Posted

技术标签:

【中文标题】Oracle 到 Netezza 的迁移 - Connect Prior ...开始在 Netezza 中等效【英文标题】:Oracle to Netezza Migration - Connect Prior ...START WITH Equivalent in Netezza 【发布时间】:2015-04-20 03:40:08 【问题描述】:

有人可以帮我获得 Oracle 11g CONNECT PRIOR ...START WITH 等价物

Netezza 中的 SQL

下面的 SQL 在 Netezza 中不起作用

CREATE TABLE Employees

(

  empid   int         NOT NULL,

  mgrid   int         NULL,

  empname varchar(25) NOT NULL,

  salary  DECIMAL(12,2)       NOT NULL

);


INSERT INTO Employees VALUES(1 , NULL, 'Nancy'   , 10000.00);

INSERT INTO Employees VALUES(2 , 1   , 'Andrew'  , 5000.00);

INSERT INTO Employees VALUES(3 , 1   , 'Janet'   , 5000.00);

INSERT INTO Employees VALUES(4 , 1   , 'Margaret', 5000.00) ;

INSERT INTO Employees VALUES(5 , 2   , 'Steven'  , 2500.00);

INSERT INTO Employees VALUES(6 , 2   , 'Michael' , 2500.00);

INSERT INTO Employees VALUES(7 , 3   , 'Robert'  , 2500.00);

INSERT INTO Employees VALUES(8 , 3   , 'Laura'   , 2500.00);

INSERT INTO Employees VALUES(9 , 3   , 'Ann'     , 2500.00);

INSERT INTO Employees VALUES(10, 4   , 'Ina'     , 2500.00);

INSERT INTO Employees VALUES(11, 7   , 'David'   , 2000.00);

INSERT INTO Employees VALUES(12, 7   , 'Ron'     , 2000.00);

INSERT INTO Employees VALUES(13, 7   , 'Dan'     , 2000.00);

INSERT INTO Employees VALUES(14, 11  , 'James'   , 1500.00);


  insert into employees values (17, 12, 'Sai11', 4500.00);

   insert into employees values (18, 12, 'SSV11', 4500.00);


  insert into employees values (19, 13, 'SB11', 4500.00);
  insert into employees values (20, 13, 'SB11', 4500.00);


WITH EmpCTE(empid, empname, mgrid, lvl)
AS
( 

  -- Anchor Member (AM)
  SELECT empid, empname, mgrid, 0
  FROM Employees
  WHERE empid = 7
  UNION ALL

  -- Recursive Member (RM)
  SELECT E.empid, E.empname, E.mgrid, M.lvl+1
  FROM Employees AS E
    JOIN EmpCTE AS M
      ON E.mgrid = M.empid
)
SELECT * FROM EmpCTE e order by e.empid  

【问题讨论】:

【参考方案1】:

我认为您要做的就是删除字段定义,并且在定义之前不要引用已建立的。

WITH EmpCTE AS ( 
  -- Anchor Member (AM)
  SELECT empid, empname, mgrid, 0
  FROM Employees
  WHERE empid = 7
), EmpCTERecursive as (
  select *
  from EmpCTE
  union all
  -- Recursive Member (RM)
  SELECT E.empid, E.empname, E.mgrid, M.lvl+1
  FROM Employees AS E
  JOIN EmpCTE AS M
  ON E.mgrid = M.empid
)
SELECT * FROM EmpCTERecursive e order by e.empid  

【讨论】:

以上是关于Oracle 到 Netezza 的迁移 - Connect Prior ...开始在 Netezza 中等效的主要内容,如果未能解决你的问题,请参考以下文章

Db2 到 Netezza 的迁移

来自多个表的 Postgres/netezza 多重连接

如何将此代码从 netezza 迁移到 db2?

从 Oracle 迁移 VARCHAR2 数据时的列长度

使用 Netezza 数据源处理 SSAS 维度时出错

Netezza 中的配置文件