这可能是我看起来很傻的东西。
我在触发器中有这个代码。完整触发器位于:(此代码上方有更多代码)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;
在下线:
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文件中取一个峰值。
提前致谢。
答案 0 :(得分:3)
如果不使用EXECUTE IMMEDIATE,则无法将DDL和DML语句混合在一起。但是,在SQL Server中创建一个触发器表而在SQL Server中完全正常的想法并不是Oracle中的最佳实践。请改用全局临时表。 创建此表,然后从触发器插入其中。像这样的样本
CREATE GLOBAL TEMPORARY TABLE YourSchema.Yourtable
-- Create table
(
pk_id NUMBER(9) NOT NULL,
company VARCHAR2(20 VARCHAR2) not null,
voucher_type VARCHAR2(3 VARCHAR2) not null,
voucher_no NUMBER(10) not null,
year_period_key NUMBER not null
)
on commit PRESERVE rows;