We need to copy gl accounts from one company to another... this would be pretty simple if accounts did not already exist in the destination company... which we want to keep... but consider this sql statement:
insert into THREE..GL00100
select ACTINDX, ACTNUMBR_1, ACTNUMBR_2, ACTNUMBR_3, ACTNUMBR_4, ACTNUMBR_5, ACTNUMBR_6, ACTNUMBR_7,
ACTNUMBR_8, ACTNUMBR_9, ACTNUMBR_10, ACTALIAS, MNACSGMT, ACCTTYPE, ACTDESCR, PSTNGTYP, ACCATNUM, ACTIVE,
TPCLBLNC, DECPLACS, FXDORVAR, BALFRCLC, DSPLKUPS, CNVRMTHD, HSTRCLRT, NOTEINDX, CREATDDT, MODIFDT, USERDEF1,
USERDEF2, PostSlsIn, PostIvIn, PostPurchIn, PostPRIn, ADJINFL, INFLAREV, INFLAEQU, ACCTENTR, USRDEFS1,
USRDEFS2
from TWO..GL00100
where TWO..GL00100.ACTNUMBR_1 not in (select ACTNUMBR_1 from THREE..GL00100)
Basically, if we leave the ACTINDX column in the script, it won't run since there may already be a row with that value in it...
If we leave that column out, then the script will fail since a blank ACTINDX will fail, either because it's the key, or because the 2nd row with a blank index will match the first row with a blank index... hence a failure...
I guess I could turn off the Key to the table while I insert, but that seems a little dangerous....
any thoughts on the best way to proceed?
insert into THREE..GL00100
select ACTINDX, ACTNUMBR_1, ACTNUMBR_2, ACTNUMBR_3, ACTNUMBR_4, ACTNUMBR_5, ACTNUMBR_6, ACTNUMBR_7,
ACTNUMBR_8, ACTNUMBR_9, ACTNUMBR_10, ACTALIAS, MNACSGMT, ACCTTYPE, ACTDESCR, PSTNGTYP, ACCATNUM, ACTIVE,
TPCLBLNC, DECPLACS, FXDORVAR, BALFRCLC, DSPLKUPS, CNVRMTHD, HSTRCLRT, NOTEINDX, CREATDDT, MODIFDT, USERDEF1,
USERDEF2, PostSlsIn, PostIvIn, PostPurchIn, PostPRIn, ADJINFL, INFLAREV, INFLAEQU, ACCTENTR, USRDEFS1,
USRDEFS2
from TWO..GL00100
where TWO..GL00100.ACTNUMBR_1 not in (select ACTNUMBR_1 from THREE..GL00100)
Basically, if we leave the ACTINDX column in the script, it won't run since there may already be a row with that value in it...
If we leave that column out, then the script will fail since a blank ACTINDX will fail, either because it's the key, or because the 2nd row with a blank index will match the first row with a blank index... hence a failure...
I guess I could turn off the Key to the table while I insert, but that seems a little dangerous....
any thoughts on the best way to proceed?