[Tfug] Database file import/consolidation
Choprboy
choprboy at dakotacom.net
Thu Jul 15 18:15:28 MST 2004
On Thursday 15 July 2004 16:41, Terence Rudkin wrote:
> First, Paul's suggestion may be the easiest to implement. But what you
> are doing sounds like an UPSERT. A feature new to SQL and in some
> current db. The SQL command is MERGE and has two branches one for the
> insert of new the other for update of existing records. A simplefied
> versio of the syntax is
>
> MERGE INTO TABLE USING table/subquery ON ( condition )
> WHEN MATCHED update stmt
> WHEN NOT MATCH insert stmt
>
Unfortunately, I don;t have a MERGE function in MySQL (actually I do, but it's
something different). I had thought about manually handling it with command
line tools, again unfortunately though, the current people only know that
they give such-and-such file to the web front end and it does it. So I'd have
to do some more work and save/rename old files.
> have the old table called REALDATA. Load the new data into STAGE. The
> do
>
> INSERT INTO realdata
> ( SELECT * FROM stage
> MINUS
> SELECT * FROM realdata )
>
That's pretty much what I want to do. But 1) I do have the problem you
mentioned, my DB contains records that are no longer in the update file (I
have to kep them around for archival, checking against old records) and 2) I
don't have a MINUS function... details....
Adrian
More information about the tfug
mailing list