這可能是我看起來很愚蠢的東西。在PL-SQL觸發器中創建一個臨時表
我在觸發器中有此代碼。完整的觸發是在這裏:(有更多的代碼上面這段代碼)http://pastebin.com/KcBZdEmt
CREATE TABLE ApprList AS
SELECT
U.*
FROM pmm$PmmReleaseRequest R
INNER JOIN dbo$ManagedEntity ME
ON ME.ManagedEntityID = R.ManagedSystemID
INNER JOIN dbo$SmartRuleAssetCache SRC
ON SRC.AssetID = ME.AssetID
INNER JOIN dbo$UserGroup_SmartRule_Role GSR
ON GSR.SmartRuleId = SRC.SmartRuleId
AND GSR.RoleId IN (2,3)
INNER JOIN dbo$AppUser_UserGroup UG
ON UG.GroupID = GSR.UserGroupId
AND UG.UserID <> R.UserID
INNER JOIN dbo$AppUser U ON UG.UserID = U.UserID
WHERE R.ReleaseRequestID = ReleaseRequestID
AND U.UserID <> RequestorUserID;
在folling行:
CREATE TABLE ApprList AS
我得到:
Error(111,1): PLS-00103: Encountered the symbol "CREATE" when expecting one of the following: (begin case declare end exception exit for goto if loop mod null pragma raise return select update while with <an identifier> <a double-quoted delimited-identifier> <a bind variable> << continue close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe purge
這可能是最好採取在pastebin文件處出現峯值。
在此先感謝。
無動態SQL不能創建內部觸發器表。你需要'執行立即'創建....'' – Tatiana
你甚至不能在觸發器內部動態執行它,因爲這會隱式提交,這是不允許的。你的標題還說你正在創建一個臨時表,但你的代碼是永久表。 Oracle沒有本地臨時表;正如kevinsky所示,您需要一個全局臨時表。 –
無論如何你爲什麼要這麼做? –