BEGIN 5 insert into orders ments (department_id, department_name) VALUES (280, n ull ); 6 EXCEPTION 7 WHEN e_insert_excep THEN 8 DBMS_OUTPUT.PUT_LINE ('insert OPERATION failed'); 9 DBMS_OUTPUT.PUT_LINE (SQLERRM); 10 END; 11/insert operation failed ORA-01400: NULL cannot be inserted ("HR ". "DEPA RTMENTS "." DEPARTMENT_NAME ") the PL/SQL process has been completed successfully. Define an e_insert_excep Exception name, call the EXCEPTION_INIT function to bind the Exception name, and output an err
(sys.dbms_obfuscation_toolkit.md5(input_string => '123456'));v_n := length(v_string);dbms_output.put_line(v_string || '--' || v_n);end;
You can also write a function and call it to implement MD5 encryption:
create or replace function fun_get_md5(i_username in varchar2, i_password in varchar2)return varchar2 isbeginreturn utl_raw.cast_to_raw(dbms_obfuscation_toolkit.md5(input_string => (i_username||i_password)));end fun_get_md5;sql> select fun_get_md5('zhangwz','123456') from dual;fun_get_md5('zh
When writing another stored procedure, the following SQL statement is used:Copy codeThe Code is as follows:Select max (RE_DATE) INTO V_RE_DATEFROM T_RECORDINGWhere id = '000000' It is reasonable to say that the query result based on this condition should be sqlcode = 1403, But the strange thing is that the following SQL exception is not captured:Copy codeThe Code is as follows:EXCEPTIONWHEN NO_DATA_FOUND THENNULL;WHEN OTHERS THENERR_CODE: =-2000;ERR_M
and the memory is insufficient, it is useless to increase the dbheap. SQL2009C. There is not enough memory to run this utility.
Cause: DB2 UTIL_HEAP_SZ is not set high enough for backup utilities.
Solution: db2 update db cfg for dbname using UTIL_HEAP_SZ the memory used for the specific digital db2 backup is UTIL_HEAP_SZ. Use the preceding command to adjust the memory ).
DB2 common error 7. When using JDBC to insert data into tables in batches. Error 23502 is reported. For example:
Error for ba
leave to exit the current stored procedures. return cannot be used.MySQL method can exit the current method using return.
6
Exception Handling in stored procedures is different
ExceptionWhen others thenRollback;Ov_rtn_msg: = c_sp_name | '(' | li_debug_pos | '):' |To_char (sqlcode) | ':' | substr (sqlerrm, 1,100 );
Declare exit handler for sqlexceptionBeginRollback;Set ov_rtn_msg = Concat (c_sp_name, '(', li_debug_pos ,'):',To_char (
select-statement for update [of column-list]. Update cursors implicitly lock the current record when browsing and modifying data. Note that update cursors are only valid for updatable views. To improve the concurrency, you often need to use the scroll cursor together. The definition method of the scroll cursor is declare cursorname scroll cursor [with hold] For selectstatement. However, the scroll cursor does not lock the current record.The following code completes the customer's browsing and m
User-Defined cursor.2. Application InstanceRead and process all the records with the code field "01" in the base table.STRING lsSQL, lsCode, lsName, lsFilterLsFilter = "01"LsSQL = "SELECT code, name FROM base WHERE substring (code, 3, 2) = ?"DECLARE cursor_base dynamic cursor for sqlsa;Prepare sqlsa from: lsSQL;Open dynamic cursor_base USING: lsFilter;FETCH cursor_base INTO: lsCode,: lsName;Do while sqlca. SQLCODE = 0.Records that meet the conditions
: SQLCODE =-104, SQLSTATE = 42601, SQLERRMC = INTEGER; R (50 ),
Because I couldn't find the desired answer on the internet, I directly looked at the problem and found that the prompt SQLERRMC = INTEGER; R (50) is removed from the INTEGER length, and I changed INTEGER (32) to INTEGER. Problem Solving
Second exception: DB2 SQL Error: SQLCODE =-542, SQLSTATE = 42831, SQLERRMC = SERIAL_NO, DRIVER = 4.15.82
Th
.• Although the lock upgrade will reduce the concurrent performance of the OLTP application, the lock upgrade will release the lock to occupy the memory and increase the memory space of the available lock.Lock upgrades may fail. For example, an application now has an IX lock on a table, and some rows in the table have an X lock, another application requests the IS lock on the table and the S lock on many rows, which causes the lock upgrade due to the number of applied locks. The database manager
In daily DB2 O M, we often encounter slow execution of Several SQL statements, but the cpu and memory usage of the database server is not high, similar problems are basically caused by locks, sorting, and other reasons. Next we will analyze how to quickly locate the lock wait problem from an instance and lock the table.
I. Lock information in logs
When you find a large amount of sqlcode reports 911 information in the database LOG DB2DIAG. LOG, there
of the exception handling unit.▲Exception handling handle: each independent when... then... is a handle.An exception handling unit can have multiple handling handles, for example:Exception/* Handle 1 */When no_data_foundThen.../* Handle 2 */When payment_overdueThen.../* Handle 3 */When othersThen...End;The when statement can only capture exceptions based on the Exception name, but cannot catch exceptions based on the error number.The when others statement is optional and must be the last proces
In the analysis of powershield protectedCodeThe following error occurs at a very low probability:
Get bool_true // note the following:
Get bool_false
If logic_flase then jump to the correct address // match the second bool_false, the jump is correct.
If logic_flase then jump to the correct address // actually cannot be executed here
In addition, multiple rows of sqlca. sqlcode
Get bool_true // note the following:
Get bool_false
If
When writing another stored procedure, the following SQL statement is used:
Copy codeThe Code is as follows: select max (RE_DATE) INTO V_RE_DATE
FROM T_RECORDING
Where id = '000000'
It is reasonable to say that the query result based on this condition should be sqlcode = 1403, But the strange thing is that the following SQL exception is not captured:Copy codeThe Code is as follows: EXCEPTIONWHEN NO_DATA_FOUND THENNULL;WHEN OTHERS THENERR_CODE: =-2
explicitly using the RAISE statement. When an EXCEPTION error is thrown, the control switches to the EXCEPTION part of the EXCEPTION block and runs the error handling code.To handle such exceptions, follow these steps:1. Define exceptions in the definition section of PL/SQL blocks:
2. RAISE
3. handle exceptions in PL/SQL blocks.
[User-defined exception]Declare
V_sal employees. salary % type;-- Declare an exceptionDelete_mgr_excep exception;-- Associate custom exceptions with oracle errorsPRAGM
When creating a table dynamically using Plsql, the user needs to have the Create any table permissionFor example:Create or replace procedure Create_table_test istmpstr varchar2 ( -); V_cursor number;j Number;begin forIinch Ten.. -Loop begin TMPSTR:='CREATE TABLE Dpc_test'|| I | |'As select * from Dpc_test WHERE 1=2'; Dbms_output.put_line (TMPSTR); --v_cursor: =Dbms_sql.open_cursor; --Dbms_sql.parse (v_cursor,tmpstr,dbms_sql.native); --j:=Dbms_sql.execute (v_cursor); Execute immediate tmpstr; E
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.