Hello I have a problem I need to make this query, the original is from oracle:
SELECT EXTRACTVALUE (
xmltype (v.dsc_val),
'/xmlCuentasLiquidacion/cuentasLiquidacion[id_prd="'
|| p_cod_producto
|| '"]/cuenta[moneda_pago="'
|| (SELECT ac.VALUE
FROM atributos_configuraciones ac
WHERE aC.id_conf = t.id_conf
AND KEY = 'moneda_cta_cargo')
|| '"]/cuenta_pago')
FROM base_bd_convenios.atributos a
JOIN base_bd_convenios.valor_atributo va
ON a.id_atr = va.id_atr
JOIN base_bd_convenios.valores v
ON va.id_val_atr = v.id_val_atr
WHERE a.cod_atr =
'cuentaAbonoBancoLiquidacion'
AND v.id_rec = p_cod_recaudador
And I must make your migration to sql server my question is how I could do it, try with values but I was not lucky:
SELECT cast(v.dsc_val as xml).value(
'/xmlCuentasLiquidacion/cuentasLiquidacion[id_prd="' + cast(@p_cod_producto as varchar) + '"]/cuenta[moneda_pago="' +
(SELECT ac.A_VALUE FROM BD_TARIFICACIONES.atributos_configuraciones ac WHERE aC.id_conf = t.id_conf AND A_KEY = 'moneda_cta_cargo') + '"]/cuenta_pago','nvarchar(max)')
FROM bd_convenios.atributos a JOIN bd_convenios.valor_atributo va ON a.id_atr = va.id_atr
JOIN bd_convenios.valores v ON va.id_val_atr = v.id_val_atr
WHERE a.cod_atr = 'cuentaAbonoBancoLiquidacion' AND v.id_rec = @p_cod_recaudador
It tells me the following error:
The argument 1 of the XML data type method "query" must be a string literal
I understand that it is due to the cast in the variable "v.dsc_val"
, but this variable is defined as text and without the cast it throws me the following problem:
Cannot call methods on text