Update the prefix of a field

0

I need to change the prefix of one field to another for all records before a date.

UPDATE tabla
SET campo1 LIKE 'YYYYYYY%';
WHERE (campo1 LIKE 'XXXXXXXXXXXXX%' AND FECHA<DATE('2017-04-05'));

The following error report appears:

Error SQL: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: LIKE;D 
SET ACT_GEOGRAFIA;=

What would the correct query be like?

    
asked by jordisec 27.06.2017 в 13:34
source

1 answer

2

You can not use LIKE in the% share% of the query.

You can try using SET , Function available in DB2:

UPDATE tabla
SET campo1 = REPLACE(campo1, 'XXXXXXXXXXXXX', 'YYYYYYY');
WHERE (campo1 LIKE 'XXXXXXXXXXXXX%' AND FECHA<DATE('2017-04-05'));
    
answered by 27.06.2017 / 13:54
source