Do we always have to update or insert? Why can't we just relate?




Many times when dealing with database updates I find myself
writing something like this:

Update .... set .. where ...
If (no update was done) then
Insert .....
end if

Or also:

If (Record not in database) then
Insert .....
Else
Update .... set .. where ...
End if

Should there be a command that does both. Maybe RELATE. This
sounds more assertive instead of the sequential implication of insert
or update. Now if such command existed would the other two even be
necessary. If we inserted a relation of items that were already related
wouldn't that be a duplicate record?

So I tried to come up with situations where two "identical"
inserts would make sense. If there was a table that had identical
records but for their primary keys. I would argue that foreign keys in
other tables somehow make them different. Then some version of RELATE
would do the work. In the ideal case that there were no foreign keys
pointing to that table. If for some reason we had missing information
that prevented us from distinguishing these records. Couldn't we change
the schema to count how many of this "identical" records did we find.
And therefore RELATE to the number of instances?

This is far from being a formal description. But I have a feeling
that this issue has been raised before. Does tutorial-D deal with this?


Arturo Hernandez

.



Relevant Pages

  • Re: ADO AddNew Method creates TWO Records
    ... The first command is the command that is created if you add a command ... opened the table to get the Primary Key for the last entry for use as ... foreign keys in other tables. ... ' Get the primary key of the record just added ...
    (microsoft.public.access.modulesdaovba)
  • Pg v Mysql & primary_key_info() & foreign_key_info()
    ... At http://savage.net.au/Perl/list-indexes.pl you can download a demo program. ... Give the program 1 table name of an existing database on the command line, ... Primary keys found: 1 ... Foreign keys found: 4 ...
    (perl.dbi.users)