Jelas, Anda tidak bisa (disederhanakan)
set t1.fieldA = (t2.fieldB, distance) --> you want to put two values into a single column
Oleh karena itu, dapatkan fieldB
sendiri dari subquery yang menggunakan fungsi analitik (row_number
) untuk "mengurutkan" baris menurut sdo_nn_distance(1) desc
; lalu dapatkan fieldB
baris pertama nilai.
Sesuatu seperti ini (saya harap saya mengatur tanda kurung dengan benar):
UPDATE table1 t1
SET t1.fieldA =
(SELECT x.fieldB --> only fieldB
FROM (SELECT T2.fieldB, --> from your subquery
SDO_NN_DISTANCE (1) distance,
ROW_NUMBER ()
OVER (ORDER BY sdo_nn_distance (1) DESC) rn
FROM table1 T1, table2 T2
WHERE (sdo_nn (t1.geometry,
t2.geometry,
'SDO_NUM_RES=1',
1) = 'TRUE')) x
WHERE rn = 1) --> where RN = 1
WHERE EXISTS
(SELECT 1
FROM table2 t2
WHERE sdo_nn (t1.geometry,
t2.geometry,
'SDO_NUM_RES=1',
1) = 'TRUE'
AND ( t2.cell_name = 'string1'
OR t2.cell_name = 'string2')
AND t1.fieldA IS NULL);