Ошибка oracle ora 20000

oracle tutorial webinars

Programs that rely on PL/SQL can often be hit with run-time errors that occur due to faults in design, problems with coding and a number of other issues. However, one of the great aspects of working with PL/SQL in Oracle is that the user can plan for the errors that frequently arise by creating warnings, or exceptions, to signal them.

The user can have exceptions for items in a database such as “insufficient_budget” that signal when more funding is allocated to a particular budget category than what is owned. When the error occurs, an exception is raised and users can write routines called ‘exception handlers’ that essentially skip over the procedure to allow continuous running. The ORA-20000 concerns these type of user-defined errors as well as other errors that are artificially tacked onto a program to facilitate a database manager’s needs.

The Problem

The ORA-20000 is a generic error that almost always accompanies another error or a stack of errors. It is part of the reserved section of PL/SQL user-defined errors. The error is caused when a stored procedure (‘raise_application_error’) is called upon. Oracle raises exceptions from the innermost to the outermost error, so when the ORA-20000 is seen in front of a stack of errors, the user knows that the innermost error, or bottom, is the block that can serve as the catalyst.

The amount of information available on the ORA-20000 is minimal due primarily to its open-endedness. Essentially, when a user sees an ORA-20000, their goal is not necessarily to correct the ORA-20000. Instead, they need to resolve the error accompanying an ORA-20000, regardless of whether it is a user-created error or a reserved error. Because the error accompanies several other error messages, let us look at some of the more common combinations for the ORA-20000.

The Solution

One example of the ORA-20000 conjoined with another set of errors is shown below. Suppose the following stack of exceptions are thrown together:

ORA-20000: ORA-20000: ORA-0000: normal, successful completion
Update failed for the ch_clnt_mast
Line: 632 Execution of ap_old_ib_terms_xfer_dr failed Line: 1045
ORA-06512: at “AEPRDFCRH.ORA_RAISERROR”, line 16
ORA-06512: at “AEPRDFCRH.AP_OL_IB_TERMS_XFER_DR”, line 935

To review, the ORA-06512 is an error caused when the stack is unwound by unhandled exceptions in the code. As previously mentioned, the ORA-06512 error and ORA-20000 error are often triggered together. To fix these errors, the user would need to correct the condition causing the errors or write an exception handler.

To begin correcting the stack of errors, check the code in the lines indicated in the error message. In this particular case, the user-defined error likely occurred due to being place in a WHEN OTHERS exception. Check over the code in line 632 (update failed for the ch_clnt_mast) as well as line 1045 (ap_old_ib_terms_xfer_dr failed). The user will have to remove or work with the exception handlers that are masking the real error message so they can rerun the code to discover what is occurring in the system.

Another common error combination is the ORA-20000: ORU-10027: buffer overflow. DBMS_OUTPUT has various default buffer sizes that all depend on the user’s version of Oracle. In the system, the buffer size limit is 2000 bytes. The user can extend the buffer all the way to 1,000,000 bytes by issuing the statement below:

DBMS_OUTPUT.ENABLE(1000000);

The comparable SQL*Plus statement looks like this:

set serveroutput on size 1000000

If the user is working with Oracle’s 10g release or something more recent, unlimited buffer settings can be set with the following:

DBMS_OUTPUT.ENABLE (buffer_size => NULL);

And the SQL*Plus version:

set serveroutput on size unlimited

This should offset the ORA-20000: ORU-10027, but, if the user conducts this approach and is still triggering the error, it is recommended to look back through the code in full to see if any items are overriding the buffer settings.

Looking forward

            The ORA-20000 can be confusing and has such a wide range of responses that it would be impossible to cover them all here. If you find that you are having a difficult time managing the stack, contact your database manager or a licensed Oracle consultant to receive further instruction on correcting the error.

Have you gotten the ORA-20000 error when working with Oracle PL/SQL? Learn what causes it and how to resolve it in this article.

The ORA-20000 error code is displayed when there is some PL/SQL code that calls RAISE_APPLICATION_ERROR.ORA-20000 Solution

Also, the code is displayed along with another, more helpful, error code.

Similar to the ORA-06550 error, the ORA-20000 error often has another error that is the cause of this error.

There are a few common errors that appear when you see the ORA-20000 error, so I’ll mention them here.

ORA-20000 Solution: ORA-10027

Often, the ORA-20000 error is accompanied by the ORA-10027 error:

ORA-20000: ORA-10027: buffer overflow, limit of 2000 bytes

The ORA-20000 error occurs when using the DBMS_OUTPUT package. This package has all kinds of default buffer sizes, the values of which depend on your version of Oracle.

This example shows that the buffer limit is 2000 bytes, which means you can only output 2000 bytes at a time.

When the ORA-10027 error happens, it means that you have tried to output something that is more than the buffer limit.

To resolve this error, you can increase the buffer limit:

DBMS_OUTPUT.ENABLE(10000);

This increases it to 10,000 bytes. You can increase it up to 1,000,000 bytes:

DBMS_OUTPUT.ENABLE(1000000);

Other Solutions of ORA-20000

Because ORA-20000 is such a generic error and is always accompanied by another error, focus on those errors first.

You can read my guide to the Oracle errors here to find out how to resolve all of the Oracle errors.

I use Oracle 11g express. I try to install sample database HR. From cmd

sqlplus
system
123456

enter image description here

Error:
enter image description here

Comment created.


Commit complete.

BEGIN dbms_stats.gather_schema_stats(          'HR'                            ,                granularity => 'ALL'            ,                cascade => TRUE                 ,                block_sample => TRUE            ); END;

*
ERROR at line 1:
ORA-20000: Schema "HR" does not exist or insufficient privileges
ORA-06512: at "SYS.DBMS_STATS", line 3701
ORA-06512: at "SYS.DBMS_STATS", line 24470
ORA-06512: at "SYS.DBMS_STATS", line 24435
ORA-06512: at line 1

How I install sample database HR correctly?

asked Apr 12, 2016 at 4:38

Raphaël Colantonio's user avatar

2

Apparently the statement to create the user hr was not executed correctly, and despite that the execution of the hr_main.sql script is not stopped.

This worked for me:

Once as sysdba:

SQL> alter session set «_ORACLE_SCRIPT»=true;
Session altered.
SQL> create user hr identified by hr;
User created.
SQL> drop user hr cascade;
User droped.
SQL> @?/demo/schema/human_resources/hr_main.sql

User created.

answered Jul 28, 2019 at 1:20

Ikkiriu's user avatar

Navigate to the PDB container as SYS user before executing the script

[oracle@af18354c958e /]$ sqlplus sys as sysdba
Enter password: password

Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> alter session set container = ORCLPDB1
SQL> @hr_main.sql

specify password for HR as parameter 1:
Enter value for 1: hr

specify default tablespeace for HR as parameter 2:
Enter value for 2: users

specify temporary tablespace for HR as parameter 3:
Enter value for 3: temp

specify log path as parameter 4:
Enter value for 4: $ORACLE_HOME/demo/schema/log/

answered Nov 12, 2018 at 17:36

Nanditha's user avatar

NandithaNanditha

531 silver badge6 bronze badges

4

The problem is the line

create user hr identified by 123456a@

Because user is not created, you are getting other errors.

To resolve it do either of below

  • Remove special character from password. Or use underscores _ in password.

    create user hr identified by 123456a
    

    OR

  • Try enclosing password in double quotes. (I am not able to test it now. But if it doesn’t work, try first option. I referred this link)

    create user hr identified by "123456a@"
    

answered Apr 12, 2016 at 5:44

Utsav's user avatar

UtsavUtsav

7,8842 gold badges16 silver badges38 bronze badges

0

Вопрос:

Я создал триггер, который позволяет пользователю иметь 10 текущих размещенных заказов. Итак, теперь, когда клиент пытается разместить номер заказа 11, база данных оракула возвращает ошибку. Ну, 3 ошибки.

ORA -20000: В настоящее время у вас 10 или более заказов.

ORA-06512: в строке “C3283535.TRG_ORDER_LIMIT”, строка 12

ORA-04088: ошибка во время запуска триггера C3283535.TRG_ORDER_LIMIT ‘

Верхняя ошибка – это то, что я создал, используя:

raise_application_error (-20000: “В настоящее время у вас 10 или более заказов”.);

Я просто задался вопросом после поиска и пытался много способов изменить сообщения об ошибках для двух других ошибок или даже не показать их всем вместе с пользователем?

Вот код, который я использовал

    create or replace trigger trg_order_limit
before insert on placed_order for each row
declare
v_count number;
begin
-- Get current order count
select count(order_id)
into   v_count
from   placed_order
where  fk1_customer_id = :new.fk1_customer_id;

-- Raise exception if there are too many
if v_count >= 10 then
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20000, 'You currently have 10 or more orders  processing.');
end if;
end;

Большое спасибо Ричард

Лучший ответ:

Происхождение исключения идет от внутреннего к внешнему блоку, в отличие от переменной области, которая идет от внешнего к внутреннему блоку. Для получения дополнительной информации об этом, прочитайте “Макрофлин” “Программирование с помощью PL/SQL”, глава 5.

То, что вы получаете здесь, представляет собой стек исключений – исключения, полученные от самых внутренних блоков до самых внешних блоков.

Когда вы вызываете исключение из триггера, оператор raise_application_error возвращает ошибку.

Затем он распространяется на триггерный блок, который говорит ORA-06512: at "C3283535.TRG_ORDER_LIMIT", line 12. Это связано с тем, что триггер рассматривает повышенное исключение как ошибку и останавливается для продолжения.

Затем ошибка распространяется на сеанс, который вызывает ORA-04088: error during execution of trigger 'C3283535.TRG_ORDER_LIMIT'. Эта ошибка сообщает нам о том, где, как в какой части программы, была поднята ошибка.

Если вы используете внешнюю программу, такую как страницы сервера Java или PHP, вы сначала поймаете поднятую ошибку – 20000. Таким образом, вы можете отобразить то же самое для своего конечного пользователя.

РЕДАКТИРОВАТЬ :

О первой ошибке – ORA-20000, вы можете изменить ее в самой инструкции RAISE_APPLICATION_ERROR.

Если вы хотите обрабатывать ORA-06512, вы можете использовать ответ Uday Shankar, который поможет в ORA-06512 этой ошибки и отображает соответствующее сообщение об ошибке.

Но вы все равно получите последний ORA-04088. Если бы я был у вас на месте, я бы не стал беспокоиться, так как после получения ORA-20000 я бы поднял ошибку приложения на самой передней панели, скрывая все остальные данные от пользователя.

Фактически, это характер стека исключений Oracle. Возникают все ошибки от самого внутреннего до самого внешнего блока. Это очень полезно для нас, чтобы определить точный источник ошибок.

Ответ №1

В триггере вы можете добавить часть обработки исключений, как показано ниже:

EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20000, 'You currently have 10 or more orders processing.');

Ответ №2

Я вижу, что это довольно старый пост, но я думаю, что читатели должны знать, что

  1. Это фактически не обеспечивает соблюдение бизнес-правила (максимум 10 заказов). Если это просто “некоторый” номер, чтобы избежать слишком больших сумм, и вам все равно, если иногда у людей есть 12 заказов, тогда это может быть хорошо. Но если нет, подумайте о сценарии, когда у вас уже 9 заказов, а затем заказы для одного и того же клиента вставляются из двух разных сеансов/транзакций одновременно. В этом случае вы получите 11 заказов, не обнаружив эту ситуацию с переполнением. Таким образом, вы не можете полагаться на этот триггер на самом деле.
  2. Кроме того, вам может потребоваться перезапустить этот триггерный огонь при обновлении, если fk1_customer_id может быть обновлен (я видел реализации, где сначала NULL помещается в столбец FK, а затем обновляется до фактического значения). Вы можете подумать, реалистичен ли этот сценарий.
  3. В триггере есть основной недостаток. Вы находитесь внутри транзакции и внутри оператора, который в настоящее время выполняется, но еще не завершен. Итак, что, если вставка не является одной вставкой строки, а что-то вроде insert into placed_order (select... from waiting_orders...) что вы ожидаете от триггера?

Подобное бизнес-правило непросто обеспечить. Но если вы решите сделать это в триггере, вам лучше сделать это в триггер после инструкции (таким образом, не в триггере перед строкой). Триггер after after по-прежнему не будет видеть результаты других незафиксированных транзакций, но, по крайней мере, текущий оператор находится в определенном состоянии.

Фактически бизнес-правило МОЖЕТ принципиально применяться только в момент фиксации; но в базе данных Oracle нет такой вещи, как триггер ON-COMMIT. Вы можете сделать денормализацию количества записей в таблице клиентов (добавить столбец ORDER_COUNT) и поместить в эту таблицу отложенное ограничение (ORDER_COUNT <= 10). Но тогда вы все еще полагаетесь на правильное поддержание этого поля в своем коде.

Полностью надежная альтернатива, но несколько громоздкая, заключается в создании материализованного представления (что-то вроде SELECT fk_customer_id, count(*) order_count from placed_orders group by fk_customer_id, с FAST REFRESH ON COMMIT в таблице place_order и создания контрольного ограничения order_count <= 10 на материализованном виде. Это единственный способ надежно применять этот тип ограничений, не задумываясь о всех возможных ситуациях, таких как параллельные сеансы, обновления и т.д. Обратите внимание, что FAST REFRESH ON COMMIT замедлит вашу фиксацию, поэтому это решение не пригодно для больших объемов (вздох… Почему Oracle не предоставляет триггер ON COMMIT…)

Когда ORACLE выполняет хранимую процедуру, отчет
ORA-20000:ORU-10027:buffer overflow,limit of 10000 bytes.

Причина проблемы: процесс содержит dbms_output.putline (переменную), размер буфера составляет 10 000 бит, а количество напечатанных символов превышает ограничение.

Решение 1 Увеличьте буфер

set   serveroutput   on   size   1000000;

Решение 2 Установить буфер не ограничено

Добавьте DBMS_OUTPUT.ENABLE (buffer_size => null) после begin, чтобы указать, что выходной буфер не ограничен.

Вложение: Задайте команду в среде SQL * PLUS: set serveroutput on;
Метод dbms_output может выводить информацию. Кроме того, в Oracle SQL Developer должен быть открыт выход на сервер. PL / SQL может быть выполнен в ТЕСТОВОМ ОКНЕ, а распечатанный результат можно увидеть в выводе СУБД

  • Ошибка oracle ora 06550
  • Ошибка oracle ora 01400
  • Ошибка oracle ora 01017
  • Ошибка oracle ora 00933 sql command not properly ended
  • Ошибка ora 28001 the password has expired