Я хотел бы спросить Вас, что именно делает этот PL / SQL-код:
DECLARE
table_doesnot_exists EXCEPTION;
PRAGMA EXCEPTION_INIT (table_doesnot_exists, -942);
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE TABLE_NAME';
EXCEPTION
WHEN table_doesnot_exists
THEN NULL;
END;
Я частично понимаю это, но мне это интересно -942
.
2 ответа
Я просмотрел и прокомментировал блок. В основном ваш код тестирует настраиваемую обработку ошибок.
DECLARE
--Define the custom exception
table_doesnot_exists EXCEPTION;
/*
*In order to use the custom exception we have to declare it (typically used with ORA messages
*that have no predefined name. Syntax: PRAGMA EXCEPTION_INIT (exception_name, -ORA_ERR_#);
*In this case: 00942, 00000, "table or view does not exist"
*Original code cited 942 but the oerr code is actually 00942, the leading 0's in this case are irrelevant
*/
PRAGMA EXCEPTION_INIT (table_doesnot_exists, -942);
BEGIN
--Attempt to drop the table
EXECUTE IMMEDIATE 'DROP TABLE test_table_does_not_exist';
EXCEPTION
--If the table we attempted does not exist then our custom exception will catch the ORA-00942
WHEN table_doesnot_exists
--Now lets throw out a debug output line
THEN DBMS_OUTPUT.PUT_LINE('table does not exist');
END;
/
Это просто код исключения Oracle для таблицы не существует
Из документации оракула:
ORA-00942 table or view does not exist
Cause: The table or view entered does not exist, a synonym that is not allowed here was used, or a view was referenced where a table is required. Existing user tables and views can be listed by querying the data dictionary. Certain privileges may be required to access the table. If an application returned this message, the table the application tried to access does not exist in the database, or the application does not have access to it.
Для получения дополнительной информации http://www.techonthenet.com/oracle/errors/ora00942.php < / а>
Похожие вопросы
Новые вопросы
sql
Язык структурированных запросов (SQL) - это язык запросов к базам данных. Вопросы должны включать примеры кода, структуру таблицы, примеры данных и тег для используемой реализации СУБД (например, MySQL, PostgreSQL, Oracle, MS SQL Server, IBM DB2 и т. Д.). Если ваш вопрос относится исключительно к конкретной СУБД (использует определенные расширения / функции), используйте вместо этого тег этой СУБД. Ответы на вопросы, помеченные SQL, должны использовать стандарт ISO / IEC SQL.