SQL Excel 的 Invantive Control 错误

SQL error in Invantive Control for Excel

这是 Excel 的 Invantive Control。

第二次 CREATE TABLE 时可能导致错误的原因是什么?

CREATE TABLE niveau1@inmemorystorage
AS
SELECT ID
,      Code
,      AddressLine1
,      Name
,      Parent
FROM   Accounts
WHERE  ID=$P{P_ACCOUNTID}

CREATE TABLE niveau2@inmemorystorage
AS
SELECT ID
,      Code
,      AddressLine1
,      Name
,      Parent
FROM   Accounts
WHERE  Parent IN (SELECT ID FROM niveau1@inmemorystorage)

CREATE TABLE niveau3@inmemorystorage
AS
SELECT ID
,      Code 
,      AddressLine1
,      Name
,      Parent
FROM   Accounts
WHERE  Parent IN (SELECT ID FROM niveau2@inmemorystorage)

SELECT * FROM niveau1@inmemorystorage
UNION ALL
SELECT * FROM niveau2@inmemorystorage
UNION ALL
SELECT * FROM niveau3@inmemorystorage

您可能收到错误消息:"The identifier 'Accounts' is ambiguous."。您可以在必要时添加标识符。

Exact Online 帐户的工作 SQL 如下所示。请注意使用 create or replace table 而不是 create table,权限不会改变(如果有的话)但在必要时首先删除 table。

CREATE OR REPLACE TABLE niveau1@inmemorystorage
AS
SELECT act.ID
,      act.Code
,      act.AddressLine1
,      act.Name
,      act.Parent
FROM   exactonlinerest..Accounts act


CREATE OR REPLACE TABLE niveau2@inmemorystorage
AS
SELECT act.ID
,      act.Code
,      act.AddressLine1
,      act.Name
,      act.Parent
FROM   exactonlinerest..Accounts act
join   niveau1@inmemorystorage n1
on     n1.id = act.Parent

CREATE OR REPLACE TABLE niveau3@inmemorystorage
AS
SELECT act.ID
,      act.Code 
,      act.AddressLine1
,      act.Name
,      act.Parent
FROM   exactonlinerest..Accounts act
join   niveau2@inmemorystorage n2
on     n2.id = act.Parent

SELECT * FROM niveau1@inmemorystorage
UNION ALL
SELECT * FROM niveau2@inmemorystorage
UNION ALL
SELECT * FROM niveau3@inmemorystorage