Skip to content

Commit

Permalink
Check for existing event not needed #5
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorwolf authored Aug 19, 2016
1 parent ae661bd commit 5f7fa36
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions odataparticipant/procedures/RegisterAsOrganizerCreate.hdbprocedure
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ BEGIN
DECLARE lv_CreatedAt string;
DECLARE lv_ChangedBy string;
DECLARE lv_ChangedAt string;

DECLARE lv_now string;

SELECT * INTO
lv_UserName,
Expand Down Expand Up @@ -66,35 +66,28 @@ BEGIN
lv_CreatedBy = lv_UserName;
lv_ChangedBy = lv_UserName;

-- Check if provided Event ID belongs to the User
SELECT COUNT(*) INTO lv_Count
FROM "com.sap.sapmentors.sitreg.odataparticipant.procedures::RegisterAsOrganizerRead"
WHERE "History.CreatedBy" = lv_CreatedBy;

IF lv_Count = 0 THEN
DECLARE lv_now string;
lv_now = CURRENT_TIMESTAMP;

INSERT INTO "com.sap.sapmentors.sitreg.data::SITreg.Organizer"
VALUES(
UCASE( lv_UserName ),
lv_FirstName,
lv_LastName,
lv_Email,
lv_MobilePhone,
UCASE( lv_Status ),
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP,
lv_CreatedBy,
CURRENT_TIMESTAMP,
lv_ChangedBy,
lv_now
);
ELSE
lv_now = CURRENT_TIMESTAMP;

INSERT INTO "com.sap.sapmentors.sitreg.data::SITreg.Organizer"
VALUES(
UCASE( lv_UserName ),
lv_FirstName,
lv_LastName,
lv_Email,
lv_MobilePhone,
UCASE( lv_Status ),
CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP,
lv_CreatedBy,
CURRENT_TIMESTAMP,
lv_ChangedBy,
lv_now
);
IF 1 = 2 THEN
error = SELECT 400 AS http_status_code,
'Event does not belong to you' AS error_message,
'An error occured' AS error_message,
'' AS detail
FROM dummy;
END IF;

END;
END;

0 comments on commit 5f7fa36

Please # to comment.