Forum

Please or Register to create posts and topics.

SQL code to enter data into a fact based on a colour code.

I have colour coded my family tree and have a fact called Family.

I would like a sqlite code so that I can enter the family surname into the fact for records that have a certain colour.

For example - all records that have colour code 9 would have the surname "Purves" entered into the Family fact.

Is this possible?  Thanks in advance.  I do have some knowledge of writing sql code.

  1. Your "Family" fact is presumably a custom, individual-type fact type. While a query could work from its name to get its FactTypeID, it's simpler if you encode it in the query.
  2. Does everyone who is to receive "Purves" already have that fact type?
  3. Is it the Description field that is to receive "Purves"?
  4. What Color code set number is your color code in?
Nampara has reacted to this post.
Nampara

Hi

Thanks for your reply

1 - yes it is a custon individual-type fact - Fact type id is 1051

2 - yes everyone in my database has this fact

3 - yes the description field is to receive the surname

4 - color code set 1

Thanks again

 

This should do what you ask for. If, however, your fact type is to append "Purves" to pre-existing values, you would need to revise it.

UPDATE EventTable SET Details='Purves'
WHERE EventType=1051
AND
(SELECT P.Color=9 FROM PersonTable P
WHERE EventTable.OwnerID=P.PersonID
)
;

Hi Tom

Thanks very much for this - worked perfectly.

Thanks