describes how to use cursor to query a single data record and insert a single data record.
Create or replace procedure PD_CESHI IS v_ErrorCode NUMBER; -- error code v_ErrorText VARCHAR2 (4000); -- error message cursor c1 isSELECT. EMPNO,. ENAME,. JOB,. MGR,. HIREDATE,. SAL,. COMM,. deptno from emp a, EMP_2 B where. empno = B. empno; BEGIN For te in c1 loop begin insert into EMP_3 (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) values (te. EMPNO, te. ENAME, te. JOB, te. MGR, te. HIREDATE,
Oracle Stored Procedure record exception, Oracle Stored Procedure record
For Oracle stored procedures, an exception can be thrown to the code or recorded in a table. If your system application has many nodes, such as our 40 nodes, if an error is thrown into the code, the error cannot be found at all. It is best to use a table to record the error. This function should be common.
-- Create an error log table
Create table PUB_PROC_ERR_LOG(LOG_ID NUMBER,MODULE_NAME VARCHAR2 (100 ),PROC_NAME VARCHAR2
Tags: update definition sql pos COM open err Drive exceProblem: Error bgjob_2]com.kingdee.bos.dao.ormapping.sqlaccessexception:update data error. The Error for batch element #1: The value of a host variable in the EXECUTE or OPEN statement are out of range for its CORRESPO Nding use: sqlcode=-302, sqlstate=22001, driver=3.68.61caused exception message Is:datalimitcaused exception message is:error for batch element #1: The value of a host variable in t
DECLARETYPE cst_table_list is Table of VARCHAR2 (40); TYPE Cst_list is TABLE of VARCHAR2 (40);TYPE Name_list is TABLE of VARCHAR2 (40); TYPE Type_list is TABLE of VARCHAR2 (20);Cst_tab_name cst_table_list:=cst_table_list (); Cst_name cst_list:=cst_list ();Tab_name name_list:=name_list (); Tab_type type_list:=type_list ();Sql_str VARCHAR2 (500);V_err_code number; V_err_msg VARCHAR2 (200);Begin-Drop all reference constraints begin SQL_STR: = ' Select Table_name,constraint_name from user_constraint
Tags: database focus compiler support Val User obj cat OtherSummarized as follows: dbms_utility. Format_call_stack -This was introduced in Oracle7, dbms_utility. Format_call_stack this built-in function returns a formatted string that shows the execution call stack: The sequence of calls to all procedures or functions at the call point of this function. In other words, the function answers the question: "How did I get here?" ” dbms_utility. Format_error_stack -This was introduced in Oracle7, dbm
into Sys_user values (1001, ' Zhangwz ', fun_get_md5 (' zhangwz ', ' 123456 '));
Sql> commit; Remove password when user logs in: Create or Replace procedure P_login (i_uname varchar2
, i_passwd varchar2) is
v_id number;
V_error_text varchar2 ($);
Begin
Select ID into
v_id from
sys_user
where username = i_uname and
password = FUN_GET_MD5 (i_uname , i_passwd);
Exception when
others then
v_error_text: = ' username or password is incorrect! ' | | ', Sqlcode
-defined exception handlingFor the processing of pre-defined exception cases, simply reference the corresponding exception case name directly in the exception handling section of the PL/SQL block and complete the corresponding exception error handling.Example: DECLAREV_empno Emp.empno%type:=empno;V_sal Emp.sal%type;BEGINSELECT sal into v_sal from emp WHERE empno=v_empno;IF v_salUPDATE emp SET sal=sal+100 WHERE empno=v_empno;Dbms_output. Put_Line (' encoded as ' | | v_empno| | ' Employee pay has
exception -- raise trigger END IF; EXCEPTION when No_result then-- When an exception is triggered dbms_output. Put_Line (' Your data UPDATE statement failed! '); When OTHERS Then-- can be understood as exception packets, which receive exception dbms_output beyond the definition exception . Put_Line (SQLCODE| | ' ---' | |SQLERRM);
END; -----------------------------------------------------------------------------------------------
on the Error_code is added to the top of the stack. Specifies false,pl/sql to replace the Error_code error stack with the default value of FALSE. Example 1: DECLAREempno employees.employee_id%TYPE;
No_such_row EXCEPTION; BEGINempno:= empno; UPDATEEmployeesSETSalary=Salary+ - WHEREId=empno; IFSql%NOTFOUND ThenRAISE No_such_row; END IF; EXCEPTION whenNo_such_row ThenRaise_application_error (-20001,'no rows to modify'); END; Example 2: BEGIN
UPDATEEmpSETDeptno= the WHEREEmpno=1111; IFSql%NOTFOU
directly ');--Handling exceptionsWhen Too_high_sal and then Dbms_output.put_line (' pay too much ');End⑥ using sqlcode in PL/SQL, SQLERRMSQLCODE return error code numberSQLERRM returns an error message.EXCEPTIONWhen OTHERS ThenDbms_output. Put_Line (sqlcode| | ' ---' | | SQLERRM);⑦ Exception Program:1. By select ... into ... Query a person's salary, if not, output "no data found"Declare--Define a variableV
variables: SQLCODE error code Sqler Rm Error content When an exception is thrown, the two variables are automatically populated, and you can get both values to determine the error: 3: User-defined exception: First look at three examples to explain: Ex1: [sql] sql> declare 2 V_DEPTNO number: = 500; 3 v_name varchar2 (:= ' testing '); 4 e_invalid_department EXCEPTION; 5 begin 6 UPDATE departments SET department_na
------------------------------ ------------------------------ ------------------------------
SYS mydt_source/data/oradata/jssweb/dmp
The above query determines that the script is located in the operating system:/data/oradata/jssweb/dmp directory, directly to the directory to view the generated script file, execute:
[Oracle@yans1 ~]$ More/data/oradata/jssweb/dmp/configure_rep.sql
The script is longer, not all posted here, you can browse in detail in your test environment, if you need to mod
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.