Need assistance on a MySQL question:  Create a trigger named trg_line_prod that automatically updates the quantity on hand for each product sold after a new LINE row is added. My Query:  CREATE OR REPLACE TRIGGER trg_line_prod AFTER INSERT ON LINE FOR EACH ROW BEGIN UPDATE PRODUCT SET P_QOH= P_QOH - :NEW.LINE_UNITS WHERE PRODUCT.P_CODE = :NEW.P_CODE; END; Error Received:  ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER trg_line_prod AFTER INSERT ON LINE FOR EACH ROW BEGIN UPDATE ' at line 1

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Need assistance on a MySQL question: 

Create a trigger named trg_line_prod that automatically updates the quantity on hand for each product sold after a new LINE row is added.

My Query: 

CREATE OR REPLACE TRIGGER trg_line_prod AFTER INSERT ON LINE FOR EACH ROW
BEGIN
UPDATE PRODUCT
SET P_QOH= P_QOH - :NEW.LINE_UNITS
WHERE PRODUCT.P_CODE = :NEW.P_CODE;
END;

Error Received: 

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TRIGGER trg_line_prod AFTER INSERT ON LINE FOR EACH ROW BEGIN UPDATE ' at line 1

Table screenshot attached*

Database name: Ch08_SaleCo2
Table name: CUSTOMER
CUS CODE CUS_LNAME CUS_FNAME CUS_INITIAL CUS AREACODE CUS_PHONE CUS BALANCE|
Table name: INVOICE
INV_NUMBER CUS_CODE INV_DATE INV_SUBTOTAL INV_TAXNV_TOTAL
10010 Ramas
Alfed
615
844-2573
0.00
1001
10014
16-Jan-18
24.90
1.99
26.89
0.00
345.86
10011 Dunne
Leona
Kathy
Paul
K
713
894-1238
1002
10011
16-Jan-18
9.98
0.80
10.78
10012 Smith
10013 Olowski
615
894-2285
1003
10012
16-Jan-18
153.85
12.31
166.16
F
615
894-2180
536.75
1004
10011
17-Jan-18
34.97
2.80
37.77
10014 Orlande
10015 O'Brian
0.00
0.00
221. 19
760.93
Myron
Amy
615
222-1672
76.08
429.66
B
713
442-3381
1005
10018
17-Jan-18
70.44
5.64
10016 Brown
James
G
615
297-1228
1006
10014
17-Jan-18
397.83
31.83
10017 Will ams
George
615
290-2556
1007
10015
17-Jan-18
34.97
2.80
37.77
10018 Farice
Anne
713
382.7186
216.65
1008
10011
17-Jan-18
399.15
31.93
431.08
10019 Smith
Olete
K
615
297-3809
00
0
Table name: LINE
Table name: PRODUCT
| LINE_UNITS LINE_PRICE|
14.99
INV_NUMBER LINE_NUMBER P_CODE
1 13-02/P2
2 23109 HE
1 54778-21
LINE TOTAL
P_CODE
P_DESCRIPT
P_INDATE P_QOH P_MIN P_PRICE P_DISCOUNT V_CODE
1001
1001
14 99
995
11
9.96
11GER/31 Power painter, 15 psi., 3-nozzle
03-Nov-17
8
5
109.99
00
25595
1002
4.99
998
13-Dec-17
13-Q2P2 7.25-in. pwr. saw blade
14-Q1L3 9.00-in. pwr. saw blade
32
15
14.99
0.05
21344
1003
1 2238/CPD
1
38 95
38 95
13-Nov-17
18
12
17.49
0.00
21344
1003
2 1546-G02
3 13.02/P2
1 54778-2T
2 23109-HB
1
39.95
39 95
74.95
1546-Q02 Hrd. cloth, 14-in., 2x50
15-Jan-18
15
8
39.95
0.00
23119
1003
14.99
1558-GW Hrd. cioth, 1/2-in., 3x50
2232/QTY B&D jigsaw, 12-in. blade
2232/GME B8D jigsaw, 8-in. blade
2238/QPD B&D cordless drill, 1/2-in.
15-Jan-18
23
5
43.99
0.00
23119
1004
3
4.99
14.97
30-Dec-17
8
109.92
0.05
24288
1004
2
9.96
19 90
24-Dec-17
6
99.87
0.05
24288
1005
1 PVC23DRT
12
5.67
70.44
1 SM-18277
2 2232/OTY
3 23109-HO
4 89 WRE-Q
1 13-C2/P2
2 54778-2T
1 PVC23DRT
20-Jan-18
12
5
38.95
0.05
25595
1005
3
6.99
20.97
109 92
995
256 99
29 98
4.99
29 35
359 85
9 95
9.95
1006
109.90
23109-HB Claw hammer
20-Jan-18
23
10
0.10
21225
1
1005
1005
1
9.55
256.99
23114-AA Sledge hammer, 12 lb.
02-Jan-18
8
5
14.40
0.05
1
54778-2T Rat-tail file, 1/8-in. fine
15-Dec-17
43
20
4.99
0.00
21344
1007
2
14.99
89-WRE-Q Hicut chain saw, 16 in.
07-Feb-18
20-Feb-18
11
256.99
0.05
24288
11
1007
1009
4 99
PVC23DRT PVC pipe, 3.5-in., 8-ft
188
75
5.87
0.00
5
5.67
SM-18277 1.25-in. metal screw, 25
01-Mar-18
172
75
6.99
0.00
21225
1008
2 WRB/TT3
3
119.96
SW-23116 2.5-in. wd. screw, 50
24-Feb-18
237
100
8.45
0.00
21231
3 23103- HB
1008
1
WR3/TT3 Steel matting, 4'x8x1/6", 5" mesh
17-Jan-18
18
5
119.95
0.10
25595
Table name: VENDOR
V CODE V_NAME
21225 Bryson, Inc.
21226 SuperLoo, Inc.
21231 D&E Supply
21344 Gomez Bros.
22567 Dome Supply
23119 Randset s Lid.
| V_CONTACT | V AREACODE V_PHONE V_STATE V_CRDER
Smithson
615
223-3234
TN
Flushing
Singh
Crtega
904
215-8996
FL
N
615
228-3245
TN
615
889-2546
KY
Smith
901
678-1419
GA
N
Anderson
901
67B-398
GA
24004 Brackman Bros
815
Browning
Hakford
Smith
228-1410
TN
24288 OROVA, Inc.
26443 B&K, Ine
615
898-1234
TN
C04
227-00eG
FL
25501 Damal Supplies
Snythe
615
890-3529
TN
N
25595 Rubicon Systems Crton
904
456-0082
FL
Y
Transcribed Image Text:Database name: Ch08_SaleCo2 Table name: CUSTOMER CUS CODE CUS_LNAME CUS_FNAME CUS_INITIAL CUS AREACODE CUS_PHONE CUS BALANCE| Table name: INVOICE INV_NUMBER CUS_CODE INV_DATE INV_SUBTOTAL INV_TAXNV_TOTAL 10010 Ramas Alfed 615 844-2573 0.00 1001 10014 16-Jan-18 24.90 1.99 26.89 0.00 345.86 10011 Dunne Leona Kathy Paul K 713 894-1238 1002 10011 16-Jan-18 9.98 0.80 10.78 10012 Smith 10013 Olowski 615 894-2285 1003 10012 16-Jan-18 153.85 12.31 166.16 F 615 894-2180 536.75 1004 10011 17-Jan-18 34.97 2.80 37.77 10014 Orlande 10015 O'Brian 0.00 0.00 221. 19 760.93 Myron Amy 615 222-1672 76.08 429.66 B 713 442-3381 1005 10018 17-Jan-18 70.44 5.64 10016 Brown James G 615 297-1228 1006 10014 17-Jan-18 397.83 31.83 10017 Will ams George 615 290-2556 1007 10015 17-Jan-18 34.97 2.80 37.77 10018 Farice Anne 713 382.7186 216.65 1008 10011 17-Jan-18 399.15 31.93 431.08 10019 Smith Olete K 615 297-3809 00 0 Table name: LINE Table name: PRODUCT | LINE_UNITS LINE_PRICE| 14.99 INV_NUMBER LINE_NUMBER P_CODE 1 13-02/P2 2 23109 HE 1 54778-21 LINE TOTAL P_CODE P_DESCRIPT P_INDATE P_QOH P_MIN P_PRICE P_DISCOUNT V_CODE 1001 1001 14 99 995 11 9.96 11GER/31 Power painter, 15 psi., 3-nozzle 03-Nov-17 8 5 109.99 00 25595 1002 4.99 998 13-Dec-17 13-Q2P2 7.25-in. pwr. saw blade 14-Q1L3 9.00-in. pwr. saw blade 32 15 14.99 0.05 21344 1003 1 2238/CPD 1 38 95 38 95 13-Nov-17 18 12 17.49 0.00 21344 1003 2 1546-G02 3 13.02/P2 1 54778-2T 2 23109-HB 1 39.95 39 95 74.95 1546-Q02 Hrd. cloth, 14-in., 2x50 15-Jan-18 15 8 39.95 0.00 23119 1003 14.99 1558-GW Hrd. cioth, 1/2-in., 3x50 2232/QTY B&D jigsaw, 12-in. blade 2232/GME B8D jigsaw, 8-in. blade 2238/QPD B&D cordless drill, 1/2-in. 15-Jan-18 23 5 43.99 0.00 23119 1004 3 4.99 14.97 30-Dec-17 8 109.92 0.05 24288 1004 2 9.96 19 90 24-Dec-17 6 99.87 0.05 24288 1005 1 PVC23DRT 12 5.67 70.44 1 SM-18277 2 2232/OTY 3 23109-HO 4 89 WRE-Q 1 13-C2/P2 2 54778-2T 1 PVC23DRT 20-Jan-18 12 5 38.95 0.05 25595 1005 3 6.99 20.97 109 92 995 256 99 29 98 4.99 29 35 359 85 9 95 9.95 1006 109.90 23109-HB Claw hammer 20-Jan-18 23 10 0.10 21225 1 1005 1005 1 9.55 256.99 23114-AA Sledge hammer, 12 lb. 02-Jan-18 8 5 14.40 0.05 1 54778-2T Rat-tail file, 1/8-in. fine 15-Dec-17 43 20 4.99 0.00 21344 1007 2 14.99 89-WRE-Q Hicut chain saw, 16 in. 07-Feb-18 20-Feb-18 11 256.99 0.05 24288 11 1007 1009 4 99 PVC23DRT PVC pipe, 3.5-in., 8-ft 188 75 5.87 0.00 5 5.67 SM-18277 1.25-in. metal screw, 25 01-Mar-18 172 75 6.99 0.00 21225 1008 2 WRB/TT3 3 119.96 SW-23116 2.5-in. wd. screw, 50 24-Feb-18 237 100 8.45 0.00 21231 3 23103- HB 1008 1 WR3/TT3 Steel matting, 4'x8x1/6", 5" mesh 17-Jan-18 18 5 119.95 0.10 25595 Table name: VENDOR V CODE V_NAME 21225 Bryson, Inc. 21226 SuperLoo, Inc. 21231 D&E Supply 21344 Gomez Bros. 22567 Dome Supply 23119 Randset s Lid. | V_CONTACT | V AREACODE V_PHONE V_STATE V_CRDER Smithson 615 223-3234 TN Flushing Singh Crtega 904 215-8996 FL N 615 228-3245 TN 615 889-2546 KY Smith 901 678-1419 GA N Anderson 901 67B-398 GA 24004 Brackman Bros 815 Browning Hakford Smith 228-1410 TN 24288 OROVA, Inc. 26443 B&K, Ine 615 898-1234 TN C04 227-00eG FL 25501 Damal Supplies Snythe 615 890-3529 TN N 25595 Rubicon Systems Crton 904 456-0082 FL Y
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Query Syntax
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education