1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
| --------------
SET AUTOCOMMIT = 0
--------------
--------------
START TRANSACTION
--------------
--------------
DROP DATABASE IF EXISTS `base`
--------------
--------------
CREATE DATABASE `base`
DEFAULT CHARACTER SET `latin1`
DEFAULT COLLATE `latin1_general_ci`
--------------
--------------
DROP TABLE IF EXISTS `tmp`
--------------
--------------
CREATE TABLE `tmp`
( `idfam` integer unsigned not null primary key,
`active` tinyint not null,
`ref` varchar(255) not null,
`desi` varchar(255) not null,
`ean` decimal(15,3) not null,
`poids` decimal(15,3) not null,
`prix` decimal(15,3) not null,
`quantite` integer unsigned not null,
`minqty` integer unsigned not null,
`idtva` integer unsigned not null,
`link_rewrite` varchar(255) not null
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
LOAD DATA LOCAL INFILE 'maj_produits_from_wave.txt'
INTO TABLE `TMP`
CHARACTER SET LATIN1
FIELDS TERMINATED BY ';'
OPTIONALLY ENCLOSED BY '\"'
ESCAPED BY '\\'
LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(@F01,@F02,@F03,@F04,@F05,@F06,@F07,@F08,@F09,@F10,@F11)
SET `active` = trim(@F01),
`ref` = trim(REPLACE(@F02, '"', '')),
`idfam` = trim(@F03),
`desi` = trim(REPLACE(@F04, '"', '')),
`ean` = trim(@F05),
`poids` = trim(@F06),
`prix` = trim(@F07),
`quantite` = trim(@F08),
`minqty` = trim(@F09),
`idtva` = trim(@F10),
`link_rewrite` = trim(REPLACE(@F11, '"', ''))
--------------
--------------
select * from tmp
--------------
+-------+--------+--------+----------------+--------+---------+--------+----------+--------+-------+--------------+
| idfam | active | ref | desi | ean | poids | prix | quantite | minqty | idtva | link_rewrite |
+-------+--------+--------+----------------+--------+---------+--------+----------+--------+-------+--------------+
| 10 | 1 | un | designation 01 | 10.010 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
| 20 | 0 | deux | designation 02 | 11.020 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
| 30 | 1 | trois | designation 03 | 12.030 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
| 40 | 0 | quatre | designation 04 | 13.040 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
| 50 | 1 | cinq | designation 05 | 14.050 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
| 60 | 0 | six | designation 06 | 15.060 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
| 70 | 1 | sept | designation 07 | 16.070 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
| 80 | 0 | huit | designation 08 | 17.080 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
| 90 | 1 | neuf | designation 09 | 18.090 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
| 100 | 0 | dix | designation 10 | 19.100 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
| 110 | 1 | onze | designation 11 | 20.110 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
| 120 | 0 | douze | designation 12 | 21.120 | 125.000 | 33.330 | 1 | 1 | 15 | bla bla bla |
+-------+--------+--------+----------------+--------+---------+--------+----------+--------+-------+--------------+
--------------
DROP TABLE IF EXISTS `pre5181_product`
--------------
--------------
CREATE TABLE `pre5181_product`
( `id_category_default` integer unsigned not null primary key,
`id_tax_rules_group` integer unsigned not null,
`ean13` decimal(15,3) not null,
`minimal_quantity` integer unsigned not null,
`price` decimal(15,3) not null,
`reference` varchar(255) not null,
`weight` decimal(15,3) not null,
`active` tinyint not null,
`create_date` TIMESTAMP(6) DEFAULT current_timestamp(6),
`update_date` TIMESTAMP(6) DEFAULT current_timestamp(6) ON UPDATE CURRENT_TIMESTAMP(6)
) ENGINE=InnoDB
DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
ROW_FORMAT=COMPRESSED
--------------
--------------
INSERT INTO `pre5181_product` (`id_category_default`,`id_tax_rules_group`,`ean13`,`minimal_quantity`,`price`,`reference`,`weight`,`active`,`create_date`,`update_date`) values
(10, 12, 10.01, 2, 120.00, 'seize', 10, 1, '2013-11-10 15:00:00', '2013-11-10 15:00:00'),
(20, 12, 10.01, 2, 120.00, 'seize', 10, 1, '2013-11-10 15:00:00', '2013-11-10 15:00:00'),
(30, 12, 10.01, 2, 120.00, 'seize', 10, 1, '2013-11-10 15:00:00', '2013-11-10 15:00:00')
--------------
--------------
INSERT INTO `pre5181_product` (`id_category_default`,`id_tax_rules_group`,`ean13`,`minimal_quantity`,`price`,`reference`,`weight`,`active`)
SELECT t.idfam AS id_category_default,
t.idtva AS id_tax_rules_group,
t.ean AS ean13,
t.minqty AS minimal_quantity,
t.prix AS price,
t.ref AS reference,
t.poids AS weight,
t.active AS active
FROM TMP as t
WHERE active = 1
ON DUPLICATE KEY UPDATE id_category_default = t.idfam,
id_tax_rules_group = t.idtva,
ean13 = t.ean,
minimal_quantity = t.minqty,
price = t.prix,
reference = t.ref,
weight = t.poids,
active = t.active
--------------
--------------
select * from pre5181_product
--------------
+---------------------+--------------------+--------+------------------+---------+-----------+---------+--------+----------------------------+----------------------------+
| id_category_default | id_tax_rules_group | ean13 | minimal_quantity | price | reference | weight | active | create_date | update_date |
+---------------------+--------------------+--------+------------------+---------+-----------+---------+--------+----------------------------+----------------------------+
| 10 | 15 | 10.010 | 1 | 33.330 | un | 125.000 | 1 | 2013-11-10 15:00:00.000000 | 2016-11-12 02:54:10.651555 |
| 20 | 12 | 10.010 | 2 | 120.000 | seize | 10.000 | 1 | 2013-11-10 15:00:00.000000 | 2013-11-10 15:00:00.000000 |
| 30 | 15 | 12.030 | 1 | 33.330 | trois | 125.000 | 1 | 2013-11-10 15:00:00.000000 | 2016-11-12 02:54:10.651555 |
| 50 | 15 | 14.050 | 1 | 33.330 | cinq | 125.000 | 1 | 2016-11-12 02:54:10.651555 | 2016-11-12 02:54:10.651555 |
| 70 | 15 | 16.070 | 1 | 33.330 | sept | 125.000 | 1 | 2016-11-12 02:54:10.651555 | 2016-11-12 02:54:10.651555 |
| 90 | 15 | 18.090 | 1 | 33.330 | neuf | 125.000 | 1 | 2016-11-12 02:54:10.651555 | 2016-11-12 02:54:10.651555 |
| 110 | 15 | 20.110 | 1 | 33.330 | onze | 125.000 | 1 | 2016-11-12 02:54:10.651555 | 2016-11-12 02:54:10.651555 |
+---------------------+--------------------+--------+------------------+---------+-----------+---------+--------+----------------------------+----------------------------+
--------------
TRUNCATE TABLE `pre5181_product`
--------------
--------------
INSERT INTO `pre5181_product` (`id_category_default`,`id_tax_rules_group`,`ean13`,`minimal_quantity`,`price`,`reference`,`weight`,`active`,`create_date`,`update_date`) values
(10, 12, 10.01, 2, 120.00, 'seize', 10, 1, '2013-11-10 15:00:00', '2013-11-10 15:00:00'),
(20, 12, 10.01, 2, 120.00, 'seize', 10, 1, '2013-11-10 15:00:00', '2013-11-10 15:00:00'),
(30, 12, 10.01, 2, 120.00, 'seize', 10, 1, '2013-11-10 15:00:00', '2013-11-10 15:00:00')
--------------
--------------
REPLACE INTO `pre5181_product` (`id_category_default`,`id_tax_rules_group`,`ean13`,`minimal_quantity`,`price`,`reference`,`weight`,`active`)
SELECT t.idfam AS id_category_default,
t.idtva AS id_tax_rules_group,
t.ean AS ean13,
t.minqty AS minimal_quantity,
t.prix AS price,
t.ref AS reference,
t.poids AS weight,
t.active AS active
FROM TMP as t
WHERE active = 1
--------------
--------------
select * from pre5181_product
--------------
+---------------------+--------------------+--------+------------------+---------+-----------+---------+--------+----------------------------+----------------------------+
| id_category_default | id_tax_rules_group | ean13 | minimal_quantity | price | reference | weight | active | create_date | update_date |
+---------------------+--------------------+--------+------------------+---------+-----------+---------+--------+----------------------------+----------------------------+
| 10 | 15 | 10.010 | 1 | 33.330 | un | 125.000 | 1 | 2016-11-12 02:54:10.936702 | 2016-11-12 02:54:10.936702 |
| 20 | 12 | 10.010 | 2 | 120.000 | seize | 10.000 | 1 | 2013-11-10 15:00:00.000000 | 2013-11-10 15:00:00.000000 |
| 30 | 15 | 12.030 | 1 | 33.330 | trois | 125.000 | 1 | 2016-11-12 02:54:10.936702 | 2016-11-12 02:54:10.936702 |
| 50 | 15 | 14.050 | 1 | 33.330 | cinq | 125.000 | 1 | 2016-11-12 02:54:10.936702 | 2016-11-12 02:54:10.936702 |
| 70 | 15 | 16.070 | 1 | 33.330 | sept | 125.000 | 1 | 2016-11-12 02:54:10.936702 | 2016-11-12 02:54:10.936702 |
| 90 | 15 | 18.090 | 1 | 33.330 | neuf | 125.000 | 1 | 2016-11-12 02:54:10.936702 | 2016-11-12 02:54:10.936702 |
| 110 | 15 | 20.110 | 1 | 33.330 | onze | 125.000 | 1 | 2016-11-12 02:54:10.936702 | 2016-11-12 02:54:10.936702 |
+---------------------+--------------------+--------+------------------+---------+-----------+---------+--------+----------------------------+----------------------------+
--------------
TRUNCATE TABLE `pre5181_product`
--------------
--------------
INSERT INTO `pre5181_product` (`id_category_default`,`id_tax_rules_group`,`ean13`,`minimal_quantity`,`price`,`reference`,`weight`,`active`,`create_date`,`update_date`) values
(10, 12, 10.01, 2, 120.00, 'seize', 10, 1, '2013-11-10 15:00:00', '2013-11-10 15:00:00'),
(20, 12, 10.01, 2, 120.00, 'seize', 10, 1, '2013-11-10 15:00:00', '2013-11-10 15:00:00'),
(30, 12, 10.01, 2, 120.00, 'seize', 10, 1, '2013-11-10 15:00:00', '2013-11-10 15:00:00')
--------------
--------------
UPDATE `pre5181_product` as t1
INNER JOIN `tmp` as t2
ON t2.idfam = t1.id_category_default
SET t1.id_tax_rules_group = t2.idtva,
t1.ean13 = t2.ean,
t1.minimal_quantity = t2.minqty,
t1.price = t2.prix,
t1.reference = t2.ref,
t1.weight = t2.poids,
t1.active = t2.active
--------------
--------------
select * from pre5181_product
--------------
+---------------------+--------------------+--------+------------------+--------+-----------+---------+--------+----------------------------+----------------------------+
| id_category_default | id_tax_rules_group | ean13 | minimal_quantity | price | reference | weight | active | create_date | update_date |
+---------------------+--------------------+--------+------------------+--------+-----------+---------+--------+----------------------------+----------------------------+
| 10 | 15 | 10.010 | 1 | 33.330 | un | 125.000 | 1 | 2013-11-10 15:00:00.000000 | 2016-11-12 02:54:11.235245 |
| 20 | 15 | 11.020 | 1 | 33.330 | deux | 125.000 | 0 | 2013-11-10 15:00:00.000000 | 2016-11-12 02:54:11.235245 |
| 30 | 15 | 12.030 | 1 | 33.330 | trois | 125.000 | 1 | 2013-11-10 15:00:00.000000 | 2016-11-12 02:54:11.235245 |
+---------------------+--------------------+--------+------------------+--------+-----------+---------+--------+----------------------------+----------------------------+
--------------
COMMIT
--------------
--------------
SET AUTOCOMMIT = 1
--------------
Appuyez sur une touche pour continuer... |
Partager