replaces all other exceptions, which means you cannot handle other exceptions, replace it with the current exception (this is the choice of custom exceptions in most cases); if it is TRUE, the newly thrown exceptions are stored at the top of the exception stack (Other exceptions have occurred ).3) Oracle pre-defined PL/SQL exceptions
Exception name
ORACODE
SQLCODE
Trigger time
LOGIN_DENIED
01017
-1017
Invalid user
; Description of the Communication area: Oracle provides two communication areas SQL Communication Area (SQLCA) and Oracle Communication Area (ORACA) Sqlca is a scalar of struct type, is the interface of Oracle and application, executes pro*C, Oracle deposits the state of each embedded SQL execution into the SQLCA;SQLCA structure:structsqlca{Charsqlcaid[8];//identify a SQL communication areaLongSQLBC;//length of the communication areaLongSqlcode; /*There are three possible values for the status
code is as followsProfile Testdatabasesqlca.dbms = "ODBC" SQLCA. autocommit = Falsesqlca.dbparm = "connectstring= ' dsn=testdatabase '"//Add the following code, note that the semicolon is in the English state, otherwise error connect;open (Frm_log)(2) write the login code. Double-click the Login button on the form, or directly select the ItemChanged (this item is at the bottom of the form)Then select the Click event for the login button(3) write the code of the login button as followsLogin stri
--oracle exception return complete information, see finally attached--Of course, it's best to select the returned information, along with other relevant information about the code--such as the occurrence of object name, time, etc. insert pre-built reference error table--11:08 2007-11-26 edit by Inreyou
DeclareStrName Varchar2 (20);BeginStrName: = ' datanotfound '; --datanotfound
If StrName = ' Divideiszero ' ThenRAISE Zero_divide;elsif strName = ' Datanotfound ' ThenRAISE No_data_found;End If;
e
Transferred from http://layznet.javaeye.com/blog/592873
When you write a stored procedure before, the exception handling is:...EXCEPTIONWhen others THENROLLBACK;End ...This type of writing when the stored procedure throws an exception, we do not know what kind of exception it throws (such as column width is not large enough to throw an exception when inserting data), you can display the exception information as followsEXCEPTIONWhen others THENDbms_output.put_line ('
;CommitexceptionWhen E_integrity ThenDbms_output.put_line (' Not exists deptno ');When others thenDbms_output.put_line (Sqlcode);End"Custom Exceptions"The biggest difference between custom exceptions is the trigger that needs to be displayed ,Three steps to use:1) Define part of the definition E_no_employee exception;2) Perform a partial trigger if Sql%notfoud then raise E_no_employee;3) Exception handling section captures and processesDeclareE_integr
Label:llbicestyleroc Use exception emsbstvalues /**
Write auto-marshal command: "Sync WebService use"
wyg 2017-03-12
*
/PROCEDURE Isdt_vehicle_autolock (P_wid in VARCHAR2,
P_vehicleno in VARCHAR2,
p_state out INT,
p_msg off VARCHAR2) is
BEGIN
INSERT INTO T_isdt_elockautorequest
(RequestID,
wid,
Vehicleno,
operatetype,
cre
varchar2)AsVar dba_tables.table_name % type: = null;V_err_code number (10 );V_err_txt varchar2 (400 );BeginSelect max (d. table_name)Into varFrom dba_tables dWhere d. OWNER = 'jf'And d. TABLE_NAME = 'orgconnection1012' | id;If var is not nullThenInsert into test values (id );Commit;End if;ExceptionWhen others thenV_err_code: = sqlcode;V_err_txt: = 'test: '| sqlerrm | DBMS_UTILITY.format_error_backtrace ();Insert into proc_err_logs (code, message, inf
This article describes how to use dynamic cursors in a DB2 database. If you are interested in using dynamic cursors in a DB2 stored procedure, the following is a detailed description of the main content of the article.
Create procedure data_wtptest (IN in_taskid_timestamp varchar (30 ),OUT o_err_no int, OUT o_err_msg varchar (1024 ))Language SQL P1: BEGIN ATOMICDeclaration startTemporary Variable Error variableDeclare sqlcode integer default 0;DECLARE
SQLCA.SQL-CODE, you can know whether the last fetch statement was successful. Generally, when the sqlcode value is0 indicates that everything is normal, 100 indicates that the result set has been obtained at the end, and other values indicate that the operation is faulty, so we can write the following code:Lb_continue = trueLl_total = 0Do While lb_continueFetch customercur-sorInto: ls_acct_no,: Ls_name,: Ll_balance;If sqlca.
exception is the same as the built-in exception, then when you reference the exception, it will solve your exception instead of the built-in exception.
Name the database incorrectly
If you want to handle an exception, you must have a name for the exception. There are thousands of database errors, but less than 25 are built-in named exceptions. However, if you need to handle these unnamed exceptions, you can associate a name with an error code. To achieve this purpose, the Pragma exception_i
whether the last fetch statement was successful. Generally, when the sqlcode value is 0, it indicates that everything is normal. 100 indicates that it has reached the end of the result set, and other values indicate that the operation is faulty, so that we can write the following code:Lb_continue = trueLl_total = 0Do While lb_continueFetch customercur-sorInto: ls_acct_no,: Ls_name,: Ll_balance;If sqlca. sqlcode
;Int age;Char brf [256];} DBStudent_t;Exec SQL END DECLARE SECTION;
For example:
Int db_ifx_update (...){Exec SQL BEGIN DECLARE SECTION;DBStudent_t dbstudent;Exec SQL END DECLARE SECTION;...Exec SQL UPDATE SET * = (: dbstudent) WHERE id = '000000 ';}
Iv. variable definitionThe host variable must be defined as follows:
Exec SQL BEGIN DECLARE SECTION;Char svrname [SQL _SVRNAME_MAX_LEN],/* Server name */Usrname [SQL _USRNAME_MAX_LEN],/* User name */Passwd [SQL _PASSWD_MAX_LEN],/* Passwd */Cnname [S
= testdatabase'" // Add the following code. Note that the semicolon is in English; otherwise, connect; open (frm_log) is returned)
(2) write the logon code. Double-click the logon button on the form or select itemchanged directly (this item is at the bottom of the form)
Select the logon button and click the event.
(3) Compile the logon button Code as follows:
// Log on to string userName, userPwd // declare the userName and password variable userName = trim (sle_name.text) // obtain the userN
can know whether the last fetch statement was successful. Generally, when the sqlcode value is 0, it indicates that everything is normal. 100 indicates that it has reached the end of the result set, and other values indicate that the operation is faulty, so that we can write the following code:Lb_continue = trueLl_total = 0Do While lb_continueFetch customercur-sorInto: ls_acct_no,: Ls_name,: Ll_balance;If sqlca.
to implement package definitions RETURN number is BEGIN DELETE from dept WHERE Deptno=d
Ept_no;
IF Sql%found then RETURN 1;
ELSE RETURN 0;
END IF;
EXCEPTION when OTHERS and then RETURN-1;
END remove_dept;
PROCEDURE query_dept (dept_no in number) is the BEGIN SELECT * into Deptrec from dept WHERE Deptno=dept_no; EXCEPTION when No_data_found and then Dbms_output. Put_Line (' No Code in database ' | | dept_no| | '
Departments '); When Too_ma
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.