-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Church/Church.SQL/Schemas/Core/Stored Procedures/PersonGet.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
CREATE PROCEDURE [Core].[PersonGet] | ||
@Ids dbo.big_integer_list_tbltype readonly | ||
AS | ||
|
||
SELECT | ||
p.Id, | ||
p.FirstName, | ||
p.MiddleName, | ||
p.LastName, | ||
p.DateOfBirthDay, | ||
p.DateOfBirthMonth, | ||
p.DateOfBirthYear, | ||
p.ChurchId, | ||
p.IsMale, | ||
p.Occupation, | ||
p.TimeZoneId | ||
|
||
FROM [Core].Person p JOIN @Ids i | ||
On p.Id = i.Id | ||
LEFT JOIN [Core].TimeZone tz | ||
ON tz.Id = p.Id | ||
|
16 changes: 16 additions & 0 deletions
16
src/Church/Church.SQL/Schemas/Core/Stored Procedures/PersonGetByChurchId.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CREATE PROCEDURE [Core].[PersonGetByChurchId] | ||
@ChurchId INT | ||
AS | ||
|
||
declare @ids dbo.big_integer_list_tbltype | ||
|
||
INSERT INTO @ids (Id) | ||
SELECT | ||
p.Id | ||
FROM [Core].Person p | ||
WHERE | ||
p.ChurchId = @ChurchId | ||
|
||
|
||
EXEC [Core].PersonGet @ids | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
CREATE TABLE [Core].[Person] | ||
( | ||
[Id] BIGINT IDENTITY(1,1) NOT NULL, | ||
[ChurchId] INT NOT NULL, | ||
[FirstName] NVARCHAR(100) NOT NULL, | ||
[MiddleName] NVARCHAR(100) NULL, | ||
[LastName] NVARCHAR(100) NOT NULL, | ||
[DateOfBirthDay] SMALLINT NULL, | ||
[DateOfBirthMonth] SMALLINT NULL, | ||
[DateOfBirthYear] SMALLINT NULL, | ||
[IsMale] BIT NOT NULL, | ||
[Occupation] NVARCHAR(255) NULL, | ||
[TimeZoneId] INT NULL, | ||
[IsArchived] BIT NOT NULL DEFAULT(0), | ||
|
||
CONSTRAINT PK_Person PRIMARY KEY (Id), | ||
CONSTRAINT FK_Person_TimeZone FOREIGN KEY (TimeZoneId) REFERENCES [Core].[TimeZone](Id), | ||
CONSTRAINT FK_Person_Church FOREIGN KEY (ChurchId) REFERENCES [Core].[Church](Id), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Church/Church.SQL/_PostDeployment/Core.Person.Populate.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
IF NOT EXISTS(SELECT 1 FROM [Core].Person p WHERE p.Id = 1) | ||
BEGIN | ||
INSERT INTO [Core].Person | ||
( | ||
[ChurchId], | ||
[FirstName], | ||
[MiddleName], | ||
[LastName] , | ||
[DateOfBirthDay], | ||
[DateOfBirthMonth], | ||
[DateOfBirthYear], | ||
[IsMale], | ||
[Occupation], | ||
[TimeZoneId], | ||
[IsArchived] | ||
) | ||
VALUES | ||
( | ||
1, | ||
'Dav', | ||
'Owen', | ||
'Evans', | ||
12, | ||
4, | ||
1981, | ||
1, | ||
'Developer', | ||
85, | ||
0 | ||
) | ||
END |