Skip to content
Advertisement

Error missing identifier oracle in FROM at line 13

SELECT XMLELEMENT("contabilidad",
    XMLAGG (
        XMLELEMENT ("empleado",
        XMLATTRIBUTES (num_emp AS "id", fecha_alta AS "fecha"),
        XMLELEMENT ("nombre", nombre),
        XMLELEMENT ("nombre",
            (SELECT (grado)
            FROM grado
            WHERE empleado.salario >=grado.salario_min and empleado.salario <=grado.salario_max)
            )
        )
        )
    FROM empleado
    WHERE empleado.num_dep=departamento.num_depto
    )

FROM departamento
WHERE num_depto='CONTABILIDAD'

It says there is an error at line 13. It says:

Error en la lĂ­nea de comandos : 13 Columna : 5

Error SQL: ORA-00931: falta el identificador

00931. 00000 -  "missing identifier"

I don’t understand what it means. Please, help.

Edit: I also tried this:

SELECT XMLELEMENT("contabilidad",
    XMLAGG (
        XMLELEMENT ("empleado",
        XMLATTRIBUTES (num_emp AS "id", fecha_alta AS "fecha"),
        XMLELEMENT ("nombre", nombre),
        XMLELEMENT ("grado_salarial",
            (SELECT (grado)
            FROM grado
            WHERE empleado.salario >=grado.salario_min and empleado.salario <=grado.salario_max)
            )
        )
        ))
    FROM empleado
    WHERE empleado.num_dep=departamento.num_depto
AND departamento.nombre='CONTABILIDAD'

It says it doesn’t recognize ‘departamento.nombre’

Advertisement

Answer

seems you missed a table .. try add a join for departamento

    SELECT XMLELEMENT("contabilidad",
        XMLAGG (
            XMLELEMENT ("empleado",
            XMLATTRIBUTES (empleado.num_emp AS "id", empleado.fecha_alta AS "fecha"),
            XMLELEMENT ("nombre", empleado.nombre),
            XMLELEMENT ("grado_salarial",
                (SELECT (grado.grado)
                FROM grado
                WHERE empleado.salario >=grado.salario_min and empleado.salario <=grado.salario_max)
                )
            )
            ))
        FROM empleado
        INNER JOIN departamento ON empleado.num_dep=departamento.num_depto
    AND departamento.nombre='CONTABILIDAD'
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement