Home > database >  The fuzzy query in the process of storage
The fuzzy query in the process of storage

Time:12-12

Table table_1
Area
36101
3610101
36102
3610201
.

Table table_2
Regional barcode time
36101 111111 2000-01-01
36101, 111122,
3610101, 111112,
36102, 222222,
3610201, 333333,
.

Table table_3
Regional barcode time
36101 111111 2000-01-01
36101 111122 1988-01-01
3610101 111112 1998-01-01
36102 222222 2022-01-01
3610201 333333 1999-01-01
.

- bar code is a unique identifier
Because the actual amount of data is very large, and it is across the DBlink, sometimes disconnected, I want to update cycle according to each area, which is 36101%, 36102%... Such, because actually I write is the stored procedure, I think in the USING of variables M fuzzy query, don't know how to add, for big help!! (that is, the USING conditions of b. below areas like m. area %)

Direct substrc (b. area, 1, 5)=m. area, this I tried it on, efficiency seems not LIKE to fast;
M. b. areas like ' ' ' 'regional' % '"' it is useless;
Want to learn how to use in the storage process of fuzzy query a variable;
Or bosses have any better ideas, please grant instruction!!!!!!!!!!
]

The FOR M IN
(SELECT substrc (area, 1, 5) as area FROM table_1)
LOOP
The MERGE INTO table_2 A
USING (select barcode, b. b. time from table_2 a, table_3 b where a. barcode=b. barcode and b. areas like m. area %) C
ON (a. barcode=C)
The WHEN MATCHED THEN
UPDATE the SET A. Time=c. time;
COMMIT;
END LOOP;
  • Related