Код:
DECLARE
rid NUMBER := &rgnid;
datestart DATE := TO_DATE ('01.01.2006', 'DD.MM.YYYY');
dateend DATE := TO_DATE ('01.01.2007', 'DD.MM.YYYY');
vprocessid NUMBER;
BEGIN
FOR c_rec IN (SELECT ROWNUM, m.dbaseid rdb, l.ID storeloc, l.NAME storelocname
FROM smstorelocations l, smpostlocmap m
WHERE l.rgnid = rid AND l.accepted = 1 AND l.ID = m.storeloc)
LOOP
BEGIN
SELECT smprocessseq.NEXTVAL INTO vprocessid FROM DUAL;
INSERT INTO smprocess (processid, processtype, employee)
VALUES (vprocessid, 'SYCP', -1);
COMMIT;
INSERT INTO smpostsynchroprocess (processid, remotedb, objtype, condition, conditiondesc, state)
VALUES (vprocessid, c_rec.rdb, 'IW',
'SMDocuments' || CHR (10) || 'DocType' || CHR (10) || '1' || CHR (10) || 'IW' || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'LocationFrom' || CHR (10) || '1' || CHR (10) || c_rec.storeloc || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'CreatedAt' || CHR (10) || '4' || CHR (10) || TO_CHAR(datestart, 'YYYYMMDD') || CHR (10) || TO_CHAR(dateend, 'YYYYMMDD') || CHR (10) || CHR (10),
c_rec.storelocname || ', с ' || TO_CHAR(datestart, 'DD.MM.YYYY') || ' по ' || TO_CHAR(dateend, 'DD.MM.YYYY'), 0);
COMMIT;
SELECT smprocessseq.NEXTVAL INTO vprocessid FROM DUAL;
INSERT INTO smprocess (processid, processtype, employee)
VALUES (vprocessid, 'SYCP', -1);
COMMIT;
INSERT INTO smpostsynchroprocess (processid, remotedb, objtype, condition, conditiondesc, state)
VALUES (vprocessid, c_rec.rdb, 'IW',
'SMDocuments' || CHR (10) || 'DocType' || CHR (10) || '1' || CHR (10) || 'IW' || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'LocationTo' || CHR (10) || '1' || CHR (10) || c_rec.storeloc || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'CreatedAt' || CHR (10) || '4' || CHR (10) || TO_CHAR(datestart, 'YYYYMMDD') || CHR (10) || TO_CHAR(dateend, 'YYYYMMDD') || CHR (10) || CHR (10),
c_rec.storelocname || ', с ' || TO_CHAR(datestart, 'DD.MM.YYYY') || ' по ' || TO_CHAR(dateend, 'DD.MM.YYYY'), 0);
COMMIT;
SELECT smprocessseq.NEXTVAL INTO vprocessid FROM DUAL;
INSERT INTO smprocess (processid, processtype, employee)
VALUES (vprocessid, 'SYCP', -1);
COMMIT;
INSERT INTO smpostsynchroprocess (processid, remotedb, objtype, condition, conditiondesc, state)
VALUES (vprocessid, c_rec.rdb, 'WI',
'SMDocuments' || CHR (10) || 'DocType' || CHR (10) || '1' || CHR (10) || 'WI' || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'LocationTo' || CHR (10) || '1' || CHR (10) || c_rec.storeloc || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'CreatedAt' || CHR (10) || '4' || CHR (10) || TO_CHAR(datestart, 'YYYYMMDD') || CHR (10) || TO_CHAR(dateend, 'YYYYMMDD') || CHR (10) || CHR (10),
c_rec.storelocname || ', с ' || TO_CHAR(datestart, 'DD.MM.YYYY') || ' по ' || TO_CHAR(dateend, 'DD.MM.YYYY'), 0);
COMMIT;
SELECT smprocessseq.NEXTVAL INTO vprocessid FROM DUAL;
INSERT INTO smprocess (processid, processtype, employee)
VALUES (vprocessid, 'SYCP', -1);
COMMIT;
INSERT INTO smpostsynchroprocess (processid, remotedb, objtype, condition, conditiondesc, state)
VALUES (vprocessid, c_rec.rdb, 'WO',
'SMDocuments' || CHR (10) || 'DocType' || CHR (10) || '1' || CHR (10) || 'WO' || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'LocationFrom' || CHR (10) || '1' || CHR (10) || c_rec.storeloc || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'CreatedAt' || CHR (10) || '4' || CHR (10) || TO_CHAR(datestart, 'YYYYMMDD') || CHR (10) || TO_CHAR(dateend, 'YYYYMMDD') || CHR (10) || CHR (10),
c_rec.storelocname || ', с ' || TO_CHAR(datestart, 'DD.MM.YYYY') || ' по ' || TO_CHAR(dateend, 'DD.MM.YYYY'), 0);
COMMIT;
SELECT smprocessseq.NEXTVAL INTO vprocessid FROM DUAL;
INSERT INTO smprocess (processid, processtype, employee)
VALUES (vprocessid, 'SYCP', -1);
COMMIT;
INSERT INTO smpostsynchroprocess (processid, remotedb, objtype, condition, conditiondesc, state)
VALUES (vprocessid, c_rec.rdb, 'CS',
'SMDocuments' || CHR (10) || 'DocType' || CHR (10) || '1' || CHR (10) || 'CS' || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'LocationFrom' || CHR (10) || '1' || CHR (10) || c_rec.storeloc || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'CreatedAt' || CHR (10) || '4' || CHR (10) || TO_CHAR(datestart, 'YYYYMMDD') || CHR (10) || TO_CHAR(dateend, 'YYYYMMDD') || CHR (10) || CHR (10),
c_rec.storelocname || ', с ' || TO_CHAR(datestart, 'DD.MM.YYYY') || ' по ' || TO_CHAR(dateend, 'DD.MM.YYYY'), 0);
COMMIT;
SELECT smprocessseq.NEXTVAL INTO vprocessid FROM DUAL;
INSERT INTO smprocess (processid, processtype, employee)
VALUES (vprocessid, 'SYCP', -1);
COMMIT;
INSERT INTO smpostsynchroprocess (processid, remotedb, objtype, condition, conditiondesc, state)
VALUES (vprocessid, c_rec.rdb, 'CR',
'SMDocuments' || CHR (10) || 'DocType' || CHR (10) || '1' || CHR (10) || 'CR' || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'LocationTo' || CHR (10) || '1' || CHR (10) || c_rec.storeloc || CHR (10) || CHR (10) ||
'SMDocuments' || CHR (10) || 'CreatedAt' || CHR (10) || '4' || CHR (10) || TO_CHAR(datestart, 'YYYYMMDD') || CHR (10) || TO_CHAR(dateend, 'YYYYMMDD') || CHR (10) || CHR (10),
c_rec.storelocname || ', с ' || TO_CHAR(datestart, 'DD.MM.YYYY') || ' по ' || TO_CHAR(dateend, 'DD.MM.YYYY'), 0);
COMMIT;
END;
END LOOP;
END;
магазины у нас были в разных регионах, соотв. в СМ2000 также имели идентификаторы регионов.
Для какой версии скрипт уже не помню - одна из первых где появилась синхронизация.