Alibabacloud.com offers a wide variety of articles about pl sql examples for practice, easily find your pl sql examples for practice information here online.
fromEmpwhereEmpno=N; Dbms_output.put_line ('Employee name is:'||v_ename); Dbms_output.put_line ('Employee Sal is:'||v_sal); Exception whenNo_data_found ThenDbms_output.put_line ('Please input current number!'); End;6. With%type, ensure that the data type of the variable is consistent with the data type of the field in the table:Declarev_ename Emp.ename%type;v_sal emp.sal%type;begin SelectEname,sal intoV_ename,v_sal fromEmpwhereEmpno=N; Dbms_output.put_line ('Employee name is:'||v_ename); Dbms
11g for optimized compilation 2088.6 conclusion 209Chapter 2 calling PL/SQL 9th from SQL9.1 cost of using PL/SQL functions in SQL 2109.1.1 context switch 2119.1.2 run 2169.1.3 less ideal data access 2189.1.4 difficulties of optimizer 2229.1.5 trap of read consistency 2269.1
/volnet/plsqldev.ico) 7.3.2 to eliminate the black command-line window, you can also write the following bat file directly: set nls_lang=simplified Chinese_china. Zhs16gbkStart plsqldev.exe This will not show a black command-line window. The same way to modify the icon. I'm also in the study of how applications that you write can be deployed in a free-to-install manner, and this link is worth referencing: http://www.oracle.com/technetwork/issue-archive/2008/08-nov/o68odpnet-101744.html For the
The Oracle tutorial you are looking at is the Oracle Pl/sql introductory case practice. We have already learned the basics of pl/sql programming, and this article will combine a case to deepen understanding of these knowledge points.
A Case Introduction
A database has two
a record matching the criteria can be found in the cursor, the result is trueSql> Declare 2 3v_id t1.id%type; 4 5 begin 6 7V_ID:=Ten; 8 9 Delete fromT1whereId=v_id;Ten One ifSql%Found Then ADbms_output.put_line ('T1 Recorder is delete!'); - Commit; - End if; the End;3.sql%rowcout statistics The number of records processed in the cursorSql> Declare 2 3v_id t1.id%type; 4 5 begin 6 7V_ID:=Ten; 8 9 In
(V_empnoinch Number, V_ename outvarchar2, v_sal out Number) 3 is 4 5 begin 6 7 SelectEname,sal intoV_ename,v_sal fromEmpwhereEmpno=V_empno; 8 9Dbms_output.put_line ('Employee name is:'||v_ename); Ten OneDbms_output.put_line ('Employee Salary is:'||v_sal); AException - whenNo_data_found Then -Dbms_output.put_line ('Employee ID is error!'); the whenOthers Then -Dbms_output.put_line ('Others Error!'); - End;running under the system:
; - Closecur_emp; +
- End; ② reading cursor data through a For loop: Sql> Declare
2 cursorCur_emp is
3 Select * fromEmpwhereDeptno=No; 4
5 begin
6 forEmp_recinchCur_emp Loop7Dbms_output.put_line (emp_rec.ename||' , '||Emp_rec.sal||' , '||Emp_rec.deptno); 8 EndLoop; 9
Ten End; ③ cursors with parameters: passing parameters to Cursors Sql> Declare
2
3
2E_emp_remain exception; 3pragma exception_init (E_emp_remain,-2291); 4
5V_empno Emp.empno%Type:=N; 6V_deptno Emp.deptno%Type:=nn; 7
8 begin
9 UpdateEmpSetDeptno=V_deptnowhereEmpno=V_empno; Ten Commit; OneException A whenE_emp_remain Then
-Dbms_output.put_line ('Department is NOT exists!'); - whenOthers Then
theDbms_output.put_line ('Others Error!'); - End; Get error codes and error messages in others: Sqlcode:oracle error code sqlerrm:oracle er
A code block for the basic introduction to PL/SQLPL/sql: Process language (Procedure Language) and structured language (structured Query Language) A combined programming language is an extension to SQL that supports a variety of data types such as large objects and collection types, using control statements such as conditions and loops, creating stored procedu
_ (: _"∠) _ _ (: _"∠) _ _ (: _"∠) _ Cheat Traffic Series _ (: _"∠) _ _ (: _"∠) _ _ (: _"∠) _Title Description:The names of all employees in the employee table are treated as follows: The first letter of the name is between ' A ' and ' G ', merged into the first string, between ' H ' and ' O ', merged into a second string, between ' P ' and ' Z ', merged into a third string, separated by a space between the names.Code:DECLAREstr1 String ( -); str2 string ( -); Str3 string ( -);CURSORName_ag isSEL
the performance of computation-intensive operations. these datatypes are not supported ed in this article. in practice, you may encounter other numeric types, such as FLOAT, INTEGER, and DECIMAL. these are subtypes of the four core numeric types in the preceding list. now let's take a closer look at NUMBER and PLS_INTEGER.The NUMBER datatype. the NUMBER data-type is by far the most common numeric datatype you'll encounter in the world of Oracle and
. These datatypes are not supported ed in this article.
In practice, you may encounter other numeric types, such as float, integer, and decimal. These are subtypes of the four core numeric types in the preceding list.
Now let's take a closer look at number and pls_integer.
The number datatype. the number data-type is by far the most common numeric datatype you'll encounter in the world of Oracle and PL/
Working with Dates in PL/SQL (date used in PL/SQL) The previous articles in this introductory PL/SQL series focused on working with strings and numbers in PL/
Today, I am working on an OA report. I use a stored procedure to calculate some data. When doing a for xxx in xxxx loop end loop; loop, I never knew it was Mao. I can't catch the no_data_found exception in for any more. Once this no_data_found Oracle occurs, it automatically jumps out of the for loop, but I don't know what went wrong, that was depressing for an hour. Shit. Later I remembered that pl/SQL too
normal.
After testing, the problem was found. The previous environment was 64-bit Windows 7 + 32-bit Oracle 11gr2, and oracle was changed to 64-bit 11gr2. This cause may be related to the version, because it cannot be ruled out by some unknown factors solved by the re-installation.
The test results are as follows:
3. The difference between the two examples is that example 1 does not modify the PL/
, the program immediately stops executing and goes to execute the exception handler.After the exception is processed, the execution of the entire PL/SQL block ends. So once an exception occurs, in the executable portion of the PL/SQL block, starting at the place where the exception occurred, the future code will no lon
Abstract: In the PL/SQL development process, SQL, PL/SQL can be used to meet most of the requirements. However, in some special cases, standard SQL statements or DML statements in PL/
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.