Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Hugo Hörnquist
Stupan
Commits
db889ed2
Commit
db889ed2
authored
Apr 08, 2018
by
Hugo Hörnquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated diff_view transfer trigger
parent
29b12338
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
create-db.sql
create-db.sql
+14
-2
No files found.
create-db.sql
View file @
db889ed2
...
...
@@ -408,12 +408,24 @@ INNER JOIN diff_help d ON p.id = d.product_id;
-- WHERE p.sale_status = 0 OR s.active != 0;
-- where p.sale_status in (0, 1);
/*
* delete from the view to transfer,
* delete from the underlying table (diff_help) if
* a transfer is not desired.
*/
CREATE
TRIGGER
diff_view_transfer
INSTEAD
OF
DELETE
ON
diff_view
BEGIN
UPDATE
stock
SET
active
=
OLD
.
amount
WHERE
product_id
=
OLD
.
product_id
;
UPDATE
stock
SET
active
=
OLD
.
actual
WHERE
OLD
.
actual
IS
NOT
NULL
AND
product_id
=
OLD
.
product_id
;
INSERT
INTO
stock_diff
(
product_id
,
expected
,
actual
)
SELECT
OLD
.
product_id
,
OLD
.
expected
,
OLD
.
actual
;
SELECT
OLD
.
product_id
,
OLD
.
expected
,
OLD
.
actual
WHERE
OLD
.
actual
IS
NOT
NULL
;
DELETE
FROM
diff_help
WHERE
id
=
OLD
.
id
;
END
;
CREATE
TRIGGER
update_view_trigger
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment