2017-01-03 74 views
-1

執行以下查詢時出現以上異常。執行oracle查詢時出錯ORA-00907:缺少右括號

SELECT CONSUMER_KEY, AUTHZ_USER, 
    ACCESS_TOKEN_TABLE.TENANT_ID, USER_DOMAIN, 
    TOKEN_SCOPE, TIME_CREATED, 
    REFRESH_TOKEN_TIME_CREATED, VALIDITY_PERIOD, 
    REFRESH_TOKEN_VALIDITY_PERIOD, USER_TYPE, 
    REFRESH_TOKEN, ACCESS_TOKEN_TABLE.TOKEN_ID, 
    GRANT_TYPE, SUBJECT_IDENTIFIER 
FROM 
    (SELECT TOKEN_ID, CONSUMER_KEY, 
    AUTHZ_USER,IDN_OAUTH2_ACCESS_TOKEN.TENANT_ID AS TENANT_ID, 
    IDN_OAUTH2_ACCESS_TOKEN.USER_DOMAIN AS USER_DOMAIN, 
    TIME_CREATED, REFRESH_TOKEN_TIME_CREATED, 
    VALIDITY_PERIOD, REFRESH_TOKEN_VALIDITY_PERIOD, 
    USER_TYPE,REFRESH_TOKEN, 
    IDN_OAUTH2_ACCESS_TOKEN.GRANT_TYPE AS GRANT_TYPE, 
    SUBJECT_IDENTIFIER 
    FROM 
    (SELECT * 
    FROM IDN_OAUTH2_ACCESS_TOKEN 
    WHERE ACCESS_TOKEN='xyz' 
    AND TOKEN_STATE ='ACTIVE' 
    ) AS IDN_OAUTH2_ACCESS_TOKEN 
    JOIN IDN_OAUTH_CONSUMER_APPS 
    ON CONSUMER_KEY_ID = ID 
) AS ACCESS_TOKEN_TABLE 
LEFT JOIN IDN_OAUTH2_ACCESS_TOKEN_SCOPE 
ON ACCESS_TOKEN_TABLE.TOKEN_ID = IDN_OAUTH2_ACCESS_TOKEN_SCOPE.TOKEN_ID; 

感謝您的幫助以找出此查詢中的錯誤。

例外: ORA-00907:缺少右括號

回答

4

您使用AS關鍵字,它是給這個錯誤走樣選擇的結果。只需在下面兩行刪除AS,您的查詢就可以正常工作。

- AS IDN_OAUTH2_ACCESS_TOKEN 
- AS ACCESS_TOKEN_TABLE 
0
SELECT CONSUMER_KEY, AUTHZ_USER, ACCESS_TOKEN_TABLE.TENANT_ID, USER_DOMAIN, TOKEN_SCOPE, TIME_CREATED, REFRESH_TOKEN_TIME_CREATED, VALIDITY_PERIOD, REFRESH_TOKEN_VALIDITY_PERIOD, USER_TYPE, REFRESH_TOKEN, ACCESS_TOKEN_TABLE.TOKEN_ID, GRANT_TYPE, SUBJECT_IDENTIFIER FROM (SELECT TOKEN_ID, CONSUMER_KEY, AUTHZ_USER, IDN_OAUTH2_ACCESS_TOKEN.TENANT_ID AS TENANT_ID, IDN_OAUTH2_ACCESS_TOKEN.USER_DOMAIN AS USER_DOMAIN,TIME_CREATED,REFRESH_TOKEN_TIME_CREATED, VALIDITY_PERIOD, REFRESH_TOKEN_VALIDITY_PERIOD, USER_TYPE, REFRESH_TOKEN, IDN_OAUTH2_ACCESS_TOKEN.GRANT_TYPE AS GRANT_TYPE,SUBJECT_IDENTIFIER FROM (SELECT * FROM IDN_OAUTH2_ACCESS_TOKEN WHERE ACCESS_TOKEN='xyz' AND TOKEN_STATE='ACTIVE') AS IDN_OAUTH2_ACCESS_TOKEN JOIN IDN_OAUTH_CONSUMER_APPS as c ON IDN_OAUTH2_ACCESS_TOKEN.CONSUMER_KEY_ID = c.ID) AS ACCESS_TOKEN_TABLE LEFT JOIN IDN_OAUTH2_ACCESS_TOKEN_SCOPE ON ACCESS_TOKEN_TABLE.TOKEN_ID = IDN_OAUTH2_ACCESS_TOKEN_SCOPE.TOKEN_ID; 

你給了別名的表,但在不使用上加入的條款。

0

你給所述14個列被顯示在外部的選擇查詢:

​​

和從僅13列中檢索數據:

FROM (SELECT TOKEN_ID, 
      CONSUMER_KEY, 
      AUTHZ_USER, 
      IDN_OAUTH2_ACCESS_TOKEN.TENANT_ID AS TENANT_ID, 
      IDN_OAUTH2_ACCESS_TOKEN.USER_DOMAIN AS USER_DOMAIN, 
      TIME_CREATED, 
      REFRESH_TOKEN_TIME_CREATED, 
      VALIDITY_PERIOD, 
      REFRESH_TOKEN_VALIDITY_PERIOD, 
      USER_TYPE, 
      REFRESH_TOKEN, 
      IDN_OAUTH2_ACCESS_TOKEN.GRANT_TYPE AS GRANT_TYPE, 
      SUBJECT_IDENTIFIER 

和別名來檢索數據(從),你已經給出了這個!

AS IDN_OAUTH2_ACCESS_TOKEN 
AS ACCESS_TOKEN_TABLE 

這就是所有的變化,你準備好去!