- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 liquibase 部署以下 SQL 代码:
-- updated Record Permissions trigger
USE [ITAM]
GO
/****** Object: Trigger [dbo].[tr_tblRecordPermissions] Script Date: 03/04/2016 22:10:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER TRIGGER [dbo].[tr_tblRecordPermissions] ON [dbo].[tblRecordPermissions] INSTEAD OF UPDATE, DELETE AS
BEGIN
SET NOCOUNT ON
--
-- Use a variable to capture current date/time and re-use
-- We don't want to repeatedly call getDate() as the time will drift
-- and it'll look like we updated different records at different times
-- depending on how long it takes to execute the portion of the trigger
-- that records changes in the audit table
--
DECLARE @now AS DATETIME
SET @now = getDate()
-- Determine what action invoked the trigger
-- Depending on the action, we'll need to evaluate records in inserted, deleted, or both
DECLARE @actionType CHAR(1)
IF ( EXISTS ( SELECT * FROM inserted ) )
IF ( EXISTS ( SELECT * FROM deleted ) )
SET @actionType = 'U' -- Update
ELSE
SET @actionType = 'I' -- Insert
ELSE
SET @actionType = 'D' -- Delete
-- Prepare a temp table of changed data, to be used for audit and for record-level security checks
-- CONVERT all values into the same data type (nvarchar(255)) in preparation for capturing changes in the audit table
-- Also, CONVERT ID values into text strings
SELECT source,
ID,
userId,
ug.shortName AS userGroup,
CAST(canEdit AS NVARCHAR(255)) canEdit,
CAST(canAdministerPermissions AS NVARCHAR(255)) canAdministerPermissions,
CAST(canAdministerBusinessManaged AS NVARCHAR(255)) canAdministerBusinessManaged,
CAST(rp.comments AS NVARCHAR(255)) comments
INTO #tmpDataToInspectForChanges
FROM (
SELECT 'old' AS source,
old.*
FROM deleted old /* handling the new & old at once, simply to avoid a lot of copy/paste code */
UNION ALL
SELECT 'new' AS source,
new.*
FROM inserted new
) rp
LEFT JOIN tblUserGroups ug
ON ug.groupId = rp.groupId
-- Pivot the data. Each field value will become a separate record
-- ITAM uses a single generic audit table that captures field level changes. Other processes can easily check
-- to see if individual field values have changed (e.g. check for changes to record ownership for any type of record, etc)
SELECT source,
ID,
field,
value
INTO #pivotData
FROM #tmpDataToInspectForChanges
UNPIVOT(value FOR field IN (
userId,
userGroup,
canEdit,
canAdministerPermissions,
canAdministerBusinessManaged,
comments
)) AS up;
--
-- Determine what specific field values have changed
--
SELECT @now AS DATETIME,
dbo.getCurrentUser() AS userName,
'tblRecordPermissions' AS formName,
CASE @actionType
WHEN 'U' THEN 'EDIT'
WHEN 'I' THEN 'INSERT'
ELSE 'DELETE'
END AS action,
IsNULL(old.ID, new.ID) AS recordId,
IsNULL(old.field, new.field) AS fieldName,
old.value AS oldValue,
new.value AS newValue,
NULL AS comments
INTO #tmpAuditTrail
FROM (
SELECT *
FROM #pivotData
WHERE source = 'old'
) old
FULL JOIN (
SELECT *
FROM #pivotData
WHERE source = 'new'
) new
ON old.ID = new.ID
AND
old.field = new.field
WHERE IsNULL(old.value, '') <> IsNULL(new.value, '')
OR @actionType = 'D'
--
-- Now that we know what is changing we need to verify permissions for the affected records
-- special case: if the recordOwner field changes, consider entitlements based on the 'old' recordOwnerId
-- special case: Members of the SA team are entitled to change server records whereManagedBy = IBM or SA, regardless of recordOwnerId
-- special case: Members of the SD team are entitled to change server records whereManagedBy = SD, regardless of recordOwnerId
--
-- The record-level entitlements values we need to check are found in...
-- a) deleted, for records to be removed or for records that are being updated/modified (because we need to consider permissions based on original values)
-- b) inserted, for new records
--
DECLARE @isInsert TINYINT
SET @isInsert = (CASE @actionType WHEN 'I' THEN 1 ELSE 0 END)
SELECT
(CASE @isInsert WHEN 1 THEN i.groupId ELSE d.groupId END) AS groupId
INTO #tmpRecordPermissionsToCheck
FROM inserted i
FULL JOIN deleted d
ON i.userId = d.userId
AND
i.groupId = d.groupId
-- Stop everything if the user is attempting to edit something they're not entitled to...
-- special case(s): refer above for additional tblServer-specific checks required here
DECLARE @errMsg VARCHAR(255)
SELECT @errMsg = 'You do not have permission to edit permissions for group ' + IsNULL(ug.shortName, '')
FROM #tmpRecordPermissionsToCheck tmp
LEFT JOIN tblUserGroups ug
ON ug.groupId = tmp.groupId
WHERE dbo.hasAdministrativePermissionsForGroup(tmp.groupId, dbo.getCurrentUser()) = 0
IF (@errMsg IS NOT NULL)
BEGIN
RAISERROR ( @errMsg, 16, 1 )
ROLLBACK TRANSACTION
RETURN
END
-- At this point the user has permissions on tblRecordPermissions so we can commit the transactions
IF (@actionType = 'I')
INSERT INTO
tblRecordPermissions
(
userId,
groupId,
canEdit,
canAdministerPermissions,
canAdministerBusinessManaged,
comments,
lastModifiedDate,
lastModifiedBy
)
SELECT
userId,
groupId,
canEdit,
canAdministerPermissions,
canAdministerBusinessManaged,
comments,
lastModifiedDate,
lastModifiedBy
FROM
inserted
ELSE
IF (@actionType = 'D')
DELETE tblRecordPermissions WHERE ID IN (SELECT ID FROM deleted)
ELSE
BEGIN
--remove old records
DELETE tblRecordPermissions WHERE ID IN (SELECT ID FROM deleted)
-- Update with new records
INSERT INTO
tblRecordPermissions
(
userId,
groupId,
canEdit,
canAdministerPermissions,
canAdministerBusinessManaged,
comments,
lastModifiedDate,
lastModifiedBy
)
SELECT
userId,
groupId,
canEdit,
canAdministerPermissions,
canAdministerBusinessManaged,
comments,
lastModifiedDate,
lastModifiedBy
FROM
inserted
END
IF (
EXISTS (
SELECT *
FROM #tmpAuditTrail
)
)
BEGIN
INSERT INTO tblAuditTrail (
DATETIME,
userName,
formName,
action,
recordId,
fieldName,
oldValue,
newValue,
comments
)
SELECT *
FROM #tmpAuditTrail
-- Auto-set the lastModifiedBy, lastModifiedDate, regardless of what the user specified
UPDATE tblRecordPermissions
SET lastModifiedBy = dbo.getCurrentUser(),
lastModifiedDate = @now
FROM tblRecordPermissions
INNER JOIN inserted
ON inserted.userId = tblRecordPermissions.userId
AND
inserted.groupId = tblRecordPermissions.groupId
END
END
Unexpected error running Liquibase: Incorrect syntax near 'up'.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<changeSet id="16" author="name">
<sqlFile path="sql/db.changelog-1.16.sql" relativeToChangelogFile="true" />
<rollback>
<sqlFile path="sql/rollback/rollback_db.changelog-1.16.sql" relativeToChangelogFile="true" />
</rollback>
<comment>Alter Record Permissions trigger</comment>
</changeSet>
</databaseChangeLog>
splitStatements="false" endDelimiter="GO"
Unexpected error running Liquibase: Incorrect syntax near 'GO'.
最佳答案
这个问题是通过两种方式解决的。
;
在 SQL 文件中触发逻辑的末尾 splitStatements="false" endDelimiter=";"
到 sqlFile 参数 关于liquibase - 运行 Liquibase : Incorrect syntax near 'up' 时出现意外错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35989586/
我的应用程序从一个有 5 个选项卡的选项卡栏 Controller 开始。一开始,第一个出现了它的名字,但其他四个没有名字,直到我点击它们。然后根据用户使用的语言显示名称。如何在选项卡栏出现之前设置选
我有嵌套数组 json 对象(第 1 层、第 2 层和第 3 层)。我的问题是数据表没有出现。任何相关的 CDN 均已导入。该表仅显示部分。我引用了很多网站,但都没有解决我的问题。 之前我使用标准表来
我正在尝试设置要显示的 Parse PFLoginViewController。这是我的一个 View Controller 的类。 import UIKit import Parse import
我遇到了这个问题,我绘制的对象没有出现在 GUI 中。我知道它正在被处理,因为数据被推送到日志文件。但是,图形没有出现。 这是我的一些代码: public static void main(Strin
我有一个树状图,其中包含出现这样的词...... TreeMap occurrence = new TreeMap (); 字符串 = 单词 整数 = 出现次数。 我如何获得最大出现次数 - 整数,
因此,我提示用户输入变量。如果变量小于 0 且大于 10。如果用户输入 10,我想要求用户再次输入数字。我问时间的时候输入4,它说你输入错误。但在第二次尝试时效果很好。例如:如果我输入 25,它会打印
我已经用 css overflow 属性做了一个例子。在这个例子中我遇到了一个溢出滚动的问题。滚动条出现了,但没有工作意味着每当将光标移动到滚动条时,在这个滚动条不活动的时间。我对此一无所知,所以请帮
我现在正在做一个元素。当您单击一个元素时,会出现以下信息,我想知道如何在您单击下一个元素而不重新单击同一元素时使其消失....例如,我的元素中有披萨,我想单击肉披萨看到浇头然后点击奶酪披萨看到浇头和肉
我有一个路由器模块,它将主题与正则表达式进行比较,并将出现的事件与一致的键掩码链接起来。 (它是一个简单的 url 路由过滤,如 symfony http://symfony.com/doc/curr
这个问题在这里已经有了答案: 9年前关闭。 Possible Duplicate: mysql_fetch_array() expects parameter 1 to be resource, bo
我在底部有一个带有工具栏的 View ,我正在使用 NavigationLink 导航到该 View 。但是当 View 出现时,工具栏显示得有点太低了。大约半秒钟后,它突然跳到位。它只会在应用程序启
我试图在我的应用程序上为背景音乐添加一个 AVAudioPlayer,我正在主屏幕上启动播放器,尝试在应用程序打开时开始播放但出现意外行为... 它播放并立即不断创建新玩家并播放这些玩家,因此同时播放
这是获取一个数字,获取其阶乘并将其加倍,但是由于基本情况,如果您输入 0,它会给出 2 作为答案,因此为了绕过它,我使用了 if 语句,但收到错误输入“if”时解析错误。如果你们能提供帮助,我真的很感
暂停期间抛出异常 android.os.DeadObjectException 在 android.os.BinderProxy.transactNative( native 方法) 在 androi
我已经为猜词游戏编写了一些代码。它从用户输入中读取字符并在单词中搜索该字符;根据字符是否在单词中,程序返回并控制一些变量。 代码如下: import java.util.Random; import
我是自动化领域的新手。这是我的简单 TestNG 登录代码,当我以 TestNG 身份运行该代码时,它会出现 java.lang.NullPointerException,双击它会突出显示我导航到 U
我是c#程序员,我习惯了c#的封装语法和其他东西。但是现在,由于某些原因,我应该用java写一些东西,我现在正在练习java一天!我要创建一个为我自己创建一个虚拟项目,以便让自己更熟悉 Java 的
我正在使用 Intellij,我的源类是 main.com.coding,我的资源文件是 main.com.testing。我将 spring.xml 文件放入资源文件中。 我的测试类位于 test.
我想要我的tests folder separate到我的应用程序代码。我的项目结构是这样的 myproject/ myproject/ myproject.py moduleon
这个问题已经有答案了: What is a NullPointerException, and how do I fix it? (12 个回答) 已关闭 6 年前。 因此,我尝试比较 2 个值,一个
我是一名优秀的程序员,十分优秀!