Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The use of PLSQL basic syntax

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "the use of PLSQL basic syntax". In daily operation, I believe many people have doubts about the use of PLSQL basic syntax. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope to help you answer the doubts about "the use of PLSQL basic syntax"! Next, please follow the small series to learn together!

Procedural Language and SQL. By adding variables and control statements, we can write more logically complex database operations

statement frame composition

declare -Optional place to declare various variables or cursors. begin -necessary to begin executing statements. -- A one-line comment statement is represented by two '-' connected together./* Multi-line comment statement, can be newline */exception -optional error handling. end; -necessary (note the semicolon after end) simple helloworld program 1 declare2 v_temp number(6):=123; /* := is an assignment symbol */3 begin4 dbms_output.put_line('middle');5 dbms_output.put_line(v_temp);6 end; Note

You need to set up the environment to display the program's content

set serveroutput off --> Turn off output (default off) set serveroutput on --> Turn on output base data type

Number

Int integer type

Pls_integer integer, error when overflow occurs

Binary_integer integer, representing a signed integer

Char Fixed length character type, up to 255 characters

Varchar2 variable length character type, up to 2000 characters

Long variable length character type, up to 2GB

Date Date type

Boolean (TRUE, FALSE, NULL)

%type means that you don't need to know the specific field type, just be consistent with the specified field type. For example:v_empno emp.empno%type;

%rowtype is exactly the same as the table structure %rowtype Example:

1 Print multiplication table 2 begin 3 for i in 1.. 9 loop 4 for j in 1.. i loop 5 dbms_output.put(j||'*'||i||'='||(i*j)||chr(9)); 6 if i=j then dbms_output.new_line(); 7 end if; 8 end loop; 9 end loop;10 end; At this point, the study of "the use of PLSQL basic syntax" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report