In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to use the basic syntax of the Oracle tool PL/SQL. In view of this problem, this article introduces in detail the corresponding analysis and solutions, hoping to help more partners who want to solve this problem to find a more simple and easy way.
We will learn the basic syntax of PL/SQL. PL/SQL is a block structure language; the PL/SQL program is divided into several parts and logical blocks of code are written in each part. Each block consists of three subparts-
Declaration section-this section begins with the keyword DECLARE. This is an optional part and defines all variables, cursors, subroutines, and other elements to be used in the program.
Executable command section-this section is contained between the keywords BEGIN and END, which is a mandatory section. It consists of executable PL/SQL statements of the program. It should have at least one line of executable code, and it can be just a NULL command to indicate that nothing is done.
Exception handling section-this section begins with the keyword EXCEPTION. This is an optional section that contains exceptions for errors in the handler.
Each PL/SQL statement ends with a semicolon (;). Using BEGIN and END, you can nest PL/SQL blocks within other PL/SQL blocks. The following is the basic structure of the PL/SQL block-
DECLARE BEGIN EXCEPTION END;Hello World example DECLARE message varchar2 (20): = 'Hello, Worldwaters; BEGIN dbms_output.put_line (message); END; /
The END; line represents the end of the PL/SQL block. To run the code from the SQL command line, type the / character after the last line of the code. When the above code is executed at the SQL prompt, it produces the following results-
Hello WorldPL/SQL procedure successfully completed.PL/SQL identifier
PL/SQL identifiers are constants, variables, exceptions, procedures, cursors, and reserved words. The identifier consists of one letter, optionally followed by multiple letters, numbers, dollar signs, underscores and numeric symbols, not exceeding 30 characters.
By default, identifiers are not case-sensitive. For example, you can use integer or INTEGER to represent a numeric value. You cannot use a reserved keyword as an identifier.
PL/SQL delimiter
A separator is a symbol with a special meaning. The following is a list of delimiters in PL/SQL-
The delimiter describes the +, -, *, / addition, subtraction / negative, multiplication, division% attribute binding 'string delimiter. Component selector (,) expression or list delimiter: host variable indicator, item separator "reference identifier separator = relational operator @ remote access indicator; declaration or statement Terminator: = assignment operator = > associative operator" join operator * * exponential operator label separator (start and end), * / multiline comment delimiter (start and end)-single-line comment indicator.. Range operator, = relational operator,'=, ~ =, ^ = different versions of the "not equal" operator PL/SQL comments
Program comments can include illustrative text in written PL/SQL code and help others read the source code. All programming languages allow some form of annotation.
PL/SQL supports both single-line and multiline comments. All characters in the comment are ignored by the PL/SQL compiler. PL/SQL single-line comments begin with a delimiter-- (double hyphen), and multiple-line comments are enclosed by / * and * /.
DECLARE-- variable declaration message varchar2 (20): = 'Hello, Worldwaters; BEGIN / * * PL/SQL executable statement (s) * / dbms_output.put_line (message); END; /
When the above code is executed at the SQL * Plus prompt, it produces the following results-
Hello WorldPL/SQL procedure successfully completed.PL/SQL program unit
The PL/SQL unit is any of the following-
PL/SQL block
Function
Bag
Inclusion body
Process
Trigger
Types
Type body
The answer to the question about how to use the basic grammar of Oracle tool PL/SQL is shared here. I hope the above content can be of some help to everyone. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.