ORCAL SQLPLUS上机6-1

2024-04-10 13:20
文章标签 上机 sqlplus orcal

本文主要是介绍ORCAL SQLPLUS上机6-1,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

SQL> declare2  v_num number:=9;3  begin4  v_num:=v_num+1;5  dbms_output.put_line(v_num);6  end;7  /

--定义记录类型,类似结构体,用select...into

--定义记录类型,类似结构体,用select...into
SQL> declaretype employee_type is record(no_number number,
name_string varchar2(20),
sal_number number);
employee employee_type;
begin
select empno,ename,sal
into employee
from scott.emp
where empno = '7369';
dbms_output.put(employee.no_number);
dbms_output.put(' ' || employee.name_string);
dbms_output.put_line(' ' ||employee.sal_number);
end;
/

--判断两个整数大小,输出不同结果

declare
number1 integer:=80;
number2 integer:=90;
begin
if number1>=number2 then
dbms_output.put_line(number1 || '>=' || number2);
else 
dbms_output.put_line(number1 || '<' || number2);
end if;
end;
/

--%type类型使用

SQL>declare
var_name scott.emp.ename%type;
var_no scott.emp.empno%type;
var_sal scott.emp.sal%type;
begin
select empno,ename,sal
into var_no,var_name,var_sal
from scott.emp
where empno = '7839';
dbms_output.put_line(var_no||'  ' ||var_name||' '||var_sal);
end;
/

--判断是否为闰年

declare
year_date number;
leap boolean;
begin 
year_date:=2010;
if mod(year_date,4) <> 0 thenleap := false;
elsif mod(year_date,100) <> 0 thenleap:=true;
elsif mod(year_date,400) <> 0 thenleap:=false;
else leap:=true;
end if;
if leap thendbms_output.put_line(year_date||'是闰年');
elsedbms_output.put_line(year_date||'是平年');
end if;
end;
/

--for计算1到100的和

declare
sum_sum number:=0;
begin
for i in 1..100 loopsum_sum := sum_sum + i;
end loop;
dbms_output.put_line(sum_sum);
end;
/

--依次输出1到10之间的平方数

declare 
i number:=1;
begin loop dbms_output.put_line(i || '的平方数为:' || i*i);
i := i+1;
exit when i > 10;
end loop;
end;
/

--%rowtype类型使用

--%rowtype类型使用
SQL>declare
row_employee scott.emp%rowtype;
begin 
select * into row_employee
from scott.emp
where empno = '7839';
dbms_output.put_line(row_employee.empno);
dbms_output.put_line(row_employee.ename);
dbms_output.put_line(row_employee.job);
dbms_output.put_line(row_employee.sal);
end;
/

--使用while循环打印50以内能被3整除的数

declarei number:=1;
begin
while i < 50 loopif mod(i,3) = 0 thendbms_output.put_line(i);end if;i:=i+1;
end loop;
end;
/

--case语句的使用

declare
i number:=0;
begin 
while i < 5 loopcase iwhen 0 thendbms_output.put_line(i || 'is zero');when 1 thendbms_output.put_line(i || 'is one');when 2 thendbms_output.put_line(i || 'is two');elsedbms_output.put_line(i || 'is more than two');end case;i:=i+1;
end loop;
end;
/

这篇关于ORCAL SQLPLUS上机6-1的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/891183

相关文章

sqlplus: error while loading shared libraries: libnsl.so.1: cannot open shared object file: No such

在Zabbix Server服务器上安装oracle-instantclient11.2后,结果使用sqlplus命令时遇到“sqlplus: error while loading shared libraries: libnsl.so.1: cannot open shared object file: No such file or directory“错误,下面总结一下解决过程。

东南大学研究生-数值分析上机题(2023)Python 6 常微分方程数值解法

常微分方程初值问题数值解 6.1 题目 编制RK4方法的通用程序;编制AB4方法的通用程序(由RK4提供初值);编制AB4-AM4预测校正方法通用程序(由RK4提供初值);编制带改进的AB4-AM4预测校正方法通用程序(由RK4提供初值);对于初值问题 { y ′ = − x 2 y 2 , 0 ≤ x ≤ 1.5 , y ( 0 ) = 3 \begin{cases} y'=-x^{2}y

华为OD上机考试

1、寻找身高相近的小朋友 #include <iostream>#include <bits/stdc++.h>using namespace std;//寻找身高相近的小朋友//输入,第一行两个整数,分别是小明身高,其他小伙伴个数,第二行是其他小伙伴的身高//100 10//95 96 97 98 99 101 102 103 104 105//输出,和小明身高差绝对值小的前面,差值大的

C#上机实验

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;

C#实验上机

第二章--C#语法基础: 一,注释语句 /*注释语句包含在"反斜杠* "和" *反斜杠"中, 或者两个反斜杠和换行符之中, 或者三个反斜杠和换行符之中(可以被VS自动识别为文件注释以提取) 要注意注释中的\,该续行符会把下一行连上来一起注释掉出错。*/ static void Main(string[] args) {//语句块包含在{}中  int MyInterg

【机房合作】状态模式与上机

在机房收费系统中,有几个业务逻辑是比较复杂的,比如说上机、下机。记得我在做第一版VB收费系统的时候,还特别地将上下机拿出来画了一个完整的流程图,要不这样做的话,最后的结果一定是懵了,也不想再继续写代码了。 在进行设计模式的学习之前,我们很有必要将上机这一业务逻辑完整的梳理一遍。 一.上机业务逻辑 1.判断卡号是否存在 2.判断卡号是否使用 3.判断卡号余额是否充足 4.判断卡号是否正

寒假第二天--线性表--数据结构上机测试1:顺序表的应用

数据结构上机测试1:顺序表的应用 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 在长度为n(n<1000)的顺序表中可能存在着一些值相同的“多余”数据元素(类型为整型),编写一个程序将“多余”的数据元素从顺序表中删除,使该表由一个“非纯表”(值相同的元素在表中可能有多个)变成一个“纯表”(值相同的元素在表中

北邮OJ-92. 统计节点个数-13计院上机B

最终算法: 使用树模型,建立完整的包含父节点与子节点的树结构,这是为了后面在遍历比较与父与子的时候能够找到父找到子。然后关于degree的计算, 在输入父子关系的时候可以直接把父与子的degree分别+1(因为求的是总度,可以看成无向图的顶点的度来处理)。 错误建模: 1.使用了并查集模型:错误在于只能记录父节点而不能记录子节点 2.使用了图模型 :错误在于把树转化为图之后,要把简单的父

北邮OJ-87. 日期-13计院上机A

题目描述 请你计算出第X年Y月Z日是第X年的第几天。其中,1月1日是第一天,1月2日是第二天,以此类推。 计算时请注意闰年的影响。对于非整百年,年数能整除4是闰年,否则不是闰年;对于整百年,年数能整除400是闰年,否则不是闰年。如1900年和1901年不是闰年,而2000年和2004年是闰年。 输入格式 第一行有一个整数T (T≤100),表示一共有T组数据需要你处理。 接下来一共有T行

北邮OJ-91. 文件系统-13网研上机D

典型的树结构。各种先序遍历就能解决,只是符合北邮一贯的尿性——难度不大就是量巨多,题目就能写两页,神烦 题目描述 现在很多操作系统的文件系统都是基于树形结构设计的。即一个目录下可以有若干个目录和文件,而每个目录和文件都可以通过一条从根目录出发的唯一路径来唯一确定。我们希望你实现对这样的一个文件系统的简单管理。 为了简化问题,我们做出如下假设: 假设文件系统初始时只有一个根目录root。