This is my query running in oracle without any problem, please, consider the columns in bold, because they represent the ordering at the end of the query.
SELECT distinct B.CEDULA as cedula, [B]B.NBR_EMPLEADO[/B] AS nombre, [B]B.APE_1 [/B]AS apellido1,
[B]B.APE_2[/B] as apellido2, A.PERIODO as periodo, b.PUESTO,[B] b.UBICACION[/B], A.COMPETENCIA,
A.ESPERADO_CUALITATIVO, A.OBTENIDO_CUALITATIVO, A.BRECHA, A.COD_PERFIL as perfil,
e.des_ubicacion, [B]c.nombre[/B] as nombre_competencia, f.nbr_puesto as nombre_puesto
FROM srh260 a, srh011 b, srh250 c, srh018 d, srh072 e, srh040 f
WHERE b.cedula = a.cedula
and b.puesto = f.puesto
and b.cedula = d.cedula
and b.ubicacion = e.ubicacion
and a.competencia = c.competencia
and a.cod_perfil = f.cod_perfil
and a.origen = 'COM'
and a.periodo like '%'
and b.ubicacion like '%'
and a.cod_perfil like '%'
and b.cedula like '%'
and b.TPO_NOMBRAMIENTO like '%'
and F_CALCULA_EDAD(b.FCH_NACIMIENTO, SYSDATE) BETWEEN 0 AND 100
and F_CALCULA_EDAD(b.FCH_INGRESO, SYSDATE) BETWEEN 0 AND 100
and b.SEXO LIKE '%'
and b.EDO_CIVIL LIKE '%'
and d.GRADO_ACADEMICO_OBTENIDO LIKE '%'
order by b.ubicacion asc, b.ape_1 asc, b.ape_2 asc, b.nbr_empleado asc, c.nombre asc
When I open the application, this error is prompted:
ORA-01791: not a SELECTed expression
What is the problem? well, ScriptCase parsed the query as:
SELECT distinct A.PERIODO as periodo, b.CEDULA as cedula,
f.nbr_puesto as nombre_puesto, e.des_ubicacion as e_des_ubicacion,
A.ESPERADO_CUALITATIVO as a_esperado_cualitativo, A.OBTENIDO_CUALITATIVO as a_obtenido_cualitativo,
A.BRECHA as a_brecha, B.NBR_EMPLEADO as nombre, B.APE_1 as apellido1,
B.APE_2 as apellido2, A.COD_PERFIL as perfil
from srh260 a, srh011 b, srh250 c, srh018 d, srh072 e, srh040 f
where b.cedula = a.cedula
and b.puesto = f.puesto
and b.cedula = d.cedula
and b.ubicacion = e.ubicacion
and a.competencia = c.competencia
and a.cod_perfil = f.cod_perfil
and a.origen = 'COM'
and a.periodo like '%'
and b.ubicacion like '%'
and a.cod_perfil like '%'
and b.cedula like '%'
and b.TPO_NOMBRAMIENTO like '%'
and F_CALCULA_EDAD(b.FCH_NACIMIENTO, SYSDATE) BETWEEN 0 AND 100
and F_CALCULA_EDAD(b.FCH_INGRESO, SYSDATE) BETWEEN 0 AND 100
and b.SEXO LIKE '%'
and b.EDO_CIVIL LIKE '%'
and d.GRADO_ACADEMICO_OBTENIDO LIKE '%'
order by b.UBICACION asc, b.ape_1 asc, b.ape_2 asc, b.nbr_empleado asc, c.nombre asc
See how in this query parsed by ScriptCase the column b.Ubicacion and c.nombre are not listed, as result, Oracle engine throws an error because you can not order by a field that is not listed in the select statement using “distinct” keyword. So, now what? I do not know what to do:
- I have created others applications and the error persist.
- Clearing cache, same result
- Logged time after time with no success
- Changing the query to order only by one field, and then reordering as a I need keeps the same error.
I am stuck.