C:/lib/adodb/replicate/replicate-steps.php Quellcode

replicate-steps.php
gehe zur Dokumentation dieser Datei
1 <?php
2 
3 # CONFIG
4 
5 if (empty($USER)) {
6  $BA = "LOAN"; ## -- leave $BA as empty string to copy all BA. Otherwise enter 1 BA (no need to quote BA)
7  $STAGES = ""; ## $STAGES = "STGCAT1,STGCAT2" -- leave $STAGES as empty string to run all stages. No need to quote stgcats.
8 
9  $HOST='192.168.0.2';
10  $USER='JCOLLECT_BKRM';
11  $PWD='natsoft';
12  $DBASE='RAPTOR';
13 }
14 # =================================== INCLUDES
15 
16 include_once('../adodb.inc.php');
17 include_once('adodb-replicate.inc.php');
18 
19 # ==================================== CONNECTION
20 $DB = ADONewConnection('oci8');
21 $ok = $DB->Connect($HOST,$USER,$PWD,$DBASE);
22 if (!$ok) return;
23 
24 
25 #$DB->debug=1;
26 
27 $bkup = 'tmp'.date('ymd_His');
28 
29 
30 if ($BA) {
31  $QTY_BA = " and qu_bacode='$BA'";
32  if (1) $STP_BA = " and s_stagecat in (select stg_stagecat from kbstage where stg_bacode='$BA')"; # OLDER KBSTEP
33  else $STP_BA = " and s_bacode='$BA'"; # LATEST KBSTEP format
34  $STG_BA = " and stg_bacode='$BA'";
35 } else {
36  $QTY_BA = "";
37  $STP_BA = "";
38  $STG_BA = "";
39 }
40 
41 if ($STAGES) {
42 
43  $STAGES = explode(',',$STAGES);
44  $STAGES = "'".implode("','",$STAGES)."'";
45  $QTY_STG = " and qu_stagecat in ($STAGES)";
46  $STP_STG = " and s_stagecat in ($STAGES)";
47  $STG_STG = " and stg_stagecat in ($STAGES)";
48 } else {
49  $QTY_STG = "";
50  $STP_STG = "";
51  $STG_STG = "";
52 }
53 
54 echo "<pre>
55 
56 /******************************************************************************
57 <font color=green>
58  Migrate stages, steps and qtypes for the following
59 
60  business area: $BA
61  and stages: $STAGES
62 
63 
64  WARNING: DO NOT 'Ignore All Errors'.
65  If any error occurs, make sure you stop and check the reason and fix it.
66  Otherwise you could corrupt everything!!!
67 
68  Connected to $USER@$DBASE $HOST;
69 </font>
70 *******************************************************************************/
71 
72 -- BACKUP
73 create table kbstage_$bkup as select * from kbstage;
74 create table kbstep_$bkup as select * from kbstep;
75 create table kbqtype_$bkup as select * from kbqtype;
76 
77 
78 -- IF CODE FAILS, REMEMBER TO RENABLE ALL TRIGGERS and following CONSTRAINT
79 ALTER TABLE kbstage DISABLE all triggers;
80 ALTER TABLE kbstep DISABLE all triggers;
81 ALTER TABLE kbqtype DISABLE all triggers;
82 ALTER TABLE jqueue DISABLE CONSTRAINT QUEUE_MUST_HAVE_TYPE;
83 
84 
85 -- NOW DELETE OLD STEPS/STAGES/QUEUES
86 delete from kbqtype where qu_mode in ('STAGE','STEP') $QTY_BA $QTY_STG;
87 delete from kbstep where (1=1) $STP_BA$STP_STG;
88 delete from kbstage where (1=1)$STG_BA$STG_STG;
89 
90 
91 
92 SET DEFINE OFF; -- disable variable handling by sqlplus
93 /
94 /* Assume kbstrategy and business areas are compatible for steps and stages to be copied */
95 </pre>
96 
97 ";
98 
99 
101 $rep->execute = false;
102 $rep->deleteFirst = false;
103 
104  // src table name, dst table name, primary key, where condition
105 $rep->ReplicateData('KBSTAGE', 'KBSTAGE', array(), " where (1=1)$STG_BA$STG_STG");
106 $rep->ReplicateData('KBSTEP', 'KBSTEP', array(), " where (1=1)$STP_BA$STP_STG");
107 $rep->ReplicateData('KBQTYPE','KBQTYPE',array()," where qu_mode in ('STAGE','STEP')$QTY_BA$QTY_STG");
108 
109 echo "
110 
111 -- Check for QUEUES not in KBQTYPE and FIX by copying from kbqtype_$bkup
112 begin
113 for rec in (select distinct q_type from jqueue where q_type not in (select qu_code from kbqtype)) loop
114  insert into kbqtype select * from kbqtype_$bkup where qu_code = rec.q_type;
115  update kbqtype set qu_name=substr('MISSING.'||qu_name,1,64) where qu_code=rec.q_type;
116 end loop;
117 end;
118 /
119 
120 commit;
121 
122 
123 ALTER TABLE kbstage ENABLE all triggers;
124 ALTER TABLE kbstep ENABLE all triggers;
125 ALTER TABLE kbqtype ENABLE all triggers;
126 ALTER TABLE jqueue ENABLE CONSTRAINT QUEUE_MUST_HAVE_TYPE;
127 
128 /*
129 -- REMEMBER TO COMMIT
130  commit;
131  begin Juris.UpdateQCounts; end;
132 
133 -- To check for bad queues after conversion, run this
134  select * from kbqtype where qu_name like 'MISSING%'
135 */
136 /
137 ";
138 ?>




Korrekturen, Hinweise und Ergänzungen

Bitte scheuen Sie sich nicht und melden Sie, was auf dieser Seite sachlich falsch oder irreführend ist, was ergänzt werden sollte, was fehlt usw. Dazu bitte oben aus dem Menü Seite den Eintrag Support Forum wählen. Es ist eine kostenlose Anmeldung erforderlich, um Anmerkungen zu posten. Unpassende Postings, Spam usw. werden kommentarlos entfernt.