Files
cti/p-line/scripts/queue-update.sql
2026-10-14 23:05:02 +03:30

12 lines
454 B
SQL
Executable File

UPDATE tbl_cdr
SET real_dst = substring(dstchannel FROM '\/([^\/\-]+)\-')
WHERE dst LIKE 'queue%' AND substring(dst FROM 6) ~ '^[0-9]+$'
AND substring(dstchannel FROM '\/([^\/\-]+)\-') IS NOT NULL;
UPDATE tbl_cdr
SET dst = CONCAT('queue-',(SELECT name
FROM tbl_queues
WHERE id = CAST(regexp_replace(tbl_cdr.dst, '\D*(\d+)', '\1') AS bigint)
LIMIT 1))
WHERE dst LIKE 'queue%' AND substring(dst FROM 6) ~ '^[0-9]+$';
23