-- AllFactsWidthTestGenerate.sql
/* 2014-08-22 Tom Holden ve3meo
Generates a series of SQL commands to insert a fact of each type
from the FactTypeTable into the EventTable 
for Person 1 and Family 1 in a database. Each fact's Description
field (EventTable.Details) is filled with a BLOBbed 256 character
metric.

Copy the results into the editor of your SQLite manager and run it
as a query. When the script below is run in SQLite Expert Personal, 
its results do not paste as text and are unusable; SQLiteSpy's results 
do paste as text. Other SQLite managers may vary.
*/ 


SELECT 'BEGIN TRANSACTION;' AS SQLcmd
UNION ALL
-- Individual FactTypes
SELECT
'INSERT INTO EventTable (EventType, OwnerType, OwnerID, Details)
VALUES
(
'|| FactTypeID ||', 0, 1, CAST(''........10........20........30........40........50........60........70........80........90.......100.......110.......120.......130.......140.......150.......160.......170.......180.......190.......200.......210.......220.......230.......240.......250......''  AS BLOB)  
);'
AS SQLcmd
FROM FactTypeTable FT 
WHERE FT.OwnerType = 0 AND FT.FactTypeID <> 901 -- exclude DNA fact as it causes access violation


UNION ALL
-- Family FactTypes
SELECT
'INSERT INTO EventTable (EventType, OwnerType, OwnerID, Details)
VALUES
(
'|| FactTypeID ||', 1, 1, CAST(''........10........20........30........40........50........60........70........80........90.......100.......110.......120.......130.......140.......150.......160.......170.......180.......190.......200.......210.......220.......230.......240.......250......''  AS BLOB)  
);'
AS SQLcmd
FROM FactTypeTable FT 
WHERE FT.OwnerType = 1

UNION ALL
SELECT 'COMMIT TRANSACTION;' 