Skip to content

Commit

Permalink
Add reference data for the Exchange and Security
Browse files Browse the repository at this point in the history
  • Loading branch information
koistya committed Dec 9, 2012
1 parent b1ad5fe commit cdf6f11
Show file tree
Hide file tree
Showing 10 changed files with 567 additions and 146 deletions.
41 changes: 0 additions & 41 deletions src/Bootstrapper/Bootstrapper.wixproj

This file was deleted.

11 changes: 0 additions & 11 deletions src/Bootstrapper/Bundle.wxs

This file was deleted.

8 changes: 8 additions & 0 deletions src/Database/Database.sqlproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<Folder Include="Properties" />
<Folder Include="dbo\" />
<Folder Include="dbo\Tables\" />
<Folder Include="Scripts" />
</ItemGroup>
<ItemGroup>
<Build Include="dbo\Tables\Tick.sql" />
Expand All @@ -114,4 +115,11 @@
<Build Include="dbo\Tables\Exchange.sql" />
<Build Include="dbo\Tables\Version.sql" />
</ItemGroup>
<ItemGroup>
<PostDeploy Include="Scripts\PostDeployment.sql" />
</ItemGroup>
<ItemGroup>
<None Include="Scripts\ReferenceData.Exchange.sql" />
<None Include="Scripts\ReferenceData.Security.sql" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions src/Database/Scripts/PostDeployment.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:r .\ReferenceData.Exchange.sql
:r .\ReferenceData.Security.sql
26 changes: 26 additions & 0 deletions src/Database/Scripts/ReferenceData.Exchange.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
SET IDENTITY_INSERT [dbo].[Exchange] ON;
GO

MERGE INTO [dbo].[Exchange] AS Target
USING (VALUES
( 1, N'NYSE', N'NYSE Euronext', N'US,EU', N'New York City', 14242, 20161),
( 2, N'NASDAQ', N'NASDAQ OMX', N'US,EU', N'New York City', 4687, 13552),
( 3, N'TSE', N'Tokyo Stock Exchange', N'JP', N'Tokyo', 3325, 3972),
(17, N'MICEX', N'Moscow Exchange', N'RU', N'Moscow', 800, 514)
)
AS Source ([ExchangeID], [Code], [Name], [Economy], [Headquarters], [MarketCap], [TradeValue])
ON Target.[ExchangeID] = Source.[ExchangeID]
-- update matched rows
WHEN MATCHED THEN
UPDATE SET [Code] = Source.[Code], [Name] = Source.[Name], [Economy] = Source.[Economy], [Headquarters] = Source.[Headquarters], [MarketCap] = Source.[MarketCap], [TradeValue] = Source.[TradeValue]
-- insert new rows
WHEN NOT MATCHED BY TARGET THEN
INSERT ([ExchangeID], [Code], [Name], [Economy], [Headquarters], [MarketCap], [TradeValue])
VALUES ([ExchangeID], [Code], [Name], [Economy], [Headquarters], [MarketCap], [TradeValue])
-- delete rows that are in the target but not the source
WHEN NOT MATCHED BY SOURCE THEN
DELETE;
GO

SET IDENTITY_INSERT [dbo].[Exchange] OFF;
GO
Loading

0 comments on commit cdf6f11

Please sign in to comment.