数字转日期 pl/sql_PL / SQL程序加两个数字

数字转日期 pl/sql

For starters, let us look at a PL/SQL program to add two numbers or integers and fetching the result into a third variable.

首先,让我们看一下一个PL / SQL程序,该程序将两个数字或整数相加并将结果提取到第三个变量中。

This program takes two inputs one for each variable and adds the result to a third variable and prints it. 

该程序为每个变量取两个输入,并将结果加到第三个变量并打印。

PL / SQL程序加两个数字 ( PL/SQL Program To Add Two Numbers)

1
2
3
4
5
6
7
8
9
10
11
Declare
Var1 integer;
Var2 integer;
Var3 integer;
Begin
Var1:=&var1;
Var2:=&var2;
Var3:=var1+var2;
Dbms_output.put_line(var3);
End;
/
1
2
3
4
5
6
7
8
9
10
11
Declare
Var1 integer ;
Var2 integer ;
Var3 integer ;
Begin
Var1 : =& var1 ;
Var2 : =& var2 ;
Var3 : = var1 + var2 ;
Dbms_output . put_line ( var3 ) ;
End ;
/

Output

输出量

数字转日期 pl/sql_PL / SQL程序加两个数字

Since, we need variables in this program code so we need to declare them in the declaration section. In the begin section, we need to initialize and take input from the user. All the logical and mathematical calculations for this program logic need to be established here.

由于在此程序代码中需要变量,因此我们需要在声明部分声明它们。 在开始部分,我们需要初始化并接受用户的输入。 需要在此建立该程序逻辑的所有逻辑和数学计算。

Var1:=&var1; This statement assigns the value that the user enters for the variable. Similarly, we have taken input for next variable.

Var1:=&var1; 该语句分配用户为变量输入的值。 同样,我们为下一个变量输入了数据。

Var3:=var1+var2 This statement is used to assign the calculated values of Var1 and Var2 into the third variable.

Var3:= var1 + var2此语句用于将Var1和Var2的计算值分配给第三个变量。

Dbms_output.put_line() The statement takes a parameter which can be printed onto the console screen.

Dbms_output.put_line()语句采用可以打印到控制台屏幕上的参数。

Note: For this statement to work properly, it is sometimes necessary to use a particular statement as mentioned below:

注意:为了使该语句正常工作,有时有必要使用如下所述的特定语句:

When you start the SQL Command Prompt/Terminal, just type: Set serveroutput on;

启动SQL命令提示符/终端时,只需键入: 将服务器输出设置为开;

This statement is used to activate the working of print statement on the console screen. This will help to get the proper output onto the screen/terminal as expected.

此语句用于**控制台屏幕上的print语句。 这将有助于按预期将适当的输出显示到屏幕/终端上。

Finally, the End statement is used to terminate the code.

最后,End语句用于终止代码。

翻译自: https://www.thecrazyprogrammer.com/2015/06/plsql-program-to-add-two-numbers.html

数字转日期 pl/sql