1
+ --
2
+ -- Copyright 2016 SAP Mentors
3
+ --
4
+ -- Licensed under the Apache License, Version 2.0 (the "License");
5
+ -- you may not use this file except in compliance with the License.
6
+ -- You may obtain a copy of the License at
7
+ --
8
+ -- http://www.apache.org/licenses/LICENSE-2.0
9
+ --
10
+ -- Unless required by applicable law or agreed to in writing, software
11
+ -- distributed under the License is distributed on an "AS IS" BASIS,
12
+ -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ -- See the License for the specific language governing permissions and
14
+ -- limitations under the License.
15
+ --
16
+ PROCEDURE "SITREG"."com.sap.sapmentors.sitreg.odatareceptionist.procedures::PrintQueueUpdate" (
17
+ IN inrow "SITREG"."com.sap.sapmentors.sitreg.data::SITreg.PrintQueue",
18
+ IN oldrow "SITREG"."com.sap.sapmentors.sitreg.data::SITreg.PrintQueue",
19
+ OUT error "SITREG"."com.sap.sapmentors.sitreg.data::SITreg.error"
20
+ )
21
+ LANGUAGE SQLSCRIPT
22
+ SQL SECURITY DEFINER
23
+ DEFAULT SCHEMA SITREG
24
+ AS
25
+ BEGIN
26
+
27
+ DECLARE lv_Count INT;
28
+
29
+ DECLARE lv_ParticipantID STRING;
30
+ DECLARE lv_EventID STRING;
31
+ DECLARE lv_FirstName STRING;
32
+ DECLARE lv_LastName STRING;
33
+ DECLARE lv_Twitter STRING;
34
+ DECLARE lv_PrintStatus STRING; -- Q = queued, S = sent, P = printed
35
+ DECLARE lv_CreatedBy STRING;
36
+ DECLARE lv_CreatedAt STRING;
37
+ DECLARE lv_ChangedBy STRING;
38
+ DECLARE lv_ChangedAt STRING;
39
+
40
+ DECLARE lv_PrintStatus_tmp STRING;
41
+
42
+ DECLARE lv_msg STRING;
43
+
44
+ SELECT * INTO lv_ParticipantID
45
+ , lv_EventID
46
+ , lv_FirstName
47
+ , lv_LastName
48
+ , lv_Twitter
49
+ , lv_PrintStatus
50
+ , lv_CreatedBy
51
+ , lv_CreatedAt
52
+ , lv_ChangedBy
53
+ , lv_ChangedAt
54
+ FROM :inrow;
55
+
56
+ SELECT "PrintStatus"
57
+ INTO lv_PrintStatus_tmp
58
+ FROM "com.sap.sapmentors.sitreg.data::SITreg.PrintQueue"
59
+ WHERE "ParticipantID" = lv_ParticipantID;
60
+
61
+ IF lv_PrintStatus_tmp <> '' THEN
62
+ IF lv_PrintStatus_tmp = 'S' THEN
63
+ IF lv_PrintStatus = 'P' THEN
64
+ UPDATE "com.sap.sapmentors.sitreg.data::SITreg.PrintQueue"
65
+ SET "PrintStatus" = lv_PrintStatus
66
+ , "History.ChangedBy" = CURRENT_USER
67
+ , "History.ChangedAt" = CURRENT_TIMESTAMP
68
+ WHERE "ParticipantID" = lv_ParticipantID;
69
+ ELSE
70
+ error = select 400 as http_status_code,
71
+ 'Update failed' error_message,
72
+ 'Status can only be set to printed' detail from dummy;
73
+ END IF;
74
+ ELSE
75
+ error = select 400 as http_status_code,
76
+ 'Update failed' error_message,
77
+ 'Entry is not is status sent' detail from dummy;
78
+ END IF;
79
+ ELSE
80
+ error = select 400 as http_status_code,
81
+ 'Update failed' error_message,
82
+ 'Entry does not exist' detail from dummy;
83
+ END IF;
84
+ END
0 commit comments