Новая Школа - онлайн-школа подготовки к ЕГЭ
Задача Задача №3621820
А
Аноним
18 июня 2026 05:05 · публичный вопрос
А
Аноним

(select concat((select granted_role from user_role_privs where granted_role = 'DBA') from DUAL))

Ответ нейросети
18 июня 2026 05:05

It looks like you’re trying to check if the current user has the DBA role by querying USER_ROLE_PRIVS. The exact statement you posted is not valid Oracle SQL because CONCAT takes two arguments, but you provided only one (a scalar subquery). Also, you don’t need DUAL or a nested subquery in this form.

What you’re trying to do (and how to fix it)

  • Simple existence check (most clear for exams):

    • SQL: SELECT CASE WHEN EXISTS ( SELECT 1 FROM user_role_privs WHERE granted_role = 'DBA' ) THEN 'DBA granted' ELSE 'DBA not granted' END AS dba_status

    FROM dual;

  • Return the role if present (minimal):

    • SQL: SELECT granted_role FROM user_role_privs WHERE granted_role = 'DBA';
  • Using a string concatenation style (Oracle uses || for concatenation; CONCAT requires exactly two args):

    • SQL: SELECT COALESCE((SELECT granted_role FROM user_role_privs WHERE granted_role = 'DBA'), 'No DBA found') AS info FROM dual;

Notes:

  • Oracle’s CONCAT function takes two arguments. You can alternatively use the concatenation operator ||= to combine strings.
  • If the inner subquery returns no rows, it yields NULL; COALESCE or NVL can handle that gracefully.

If you share the exact goal (e.g., just test for presence, or print a message like “DBA found”), I can tailor the exact query.