📄 维勒斯.txt
字号:
第一题:
declare
i int;
--k int;
--j int;
begin
i := 0;
<<hang>>
for i in 1..4 loop --上四行
for k in reverse 0..(4-i) loop --打印空格
dbms_output.put(' ');
end loop;
for j in 1..(2*i-1) loop --打印*号
dbms_output.put('*');
end loop;
dbms_output.new_line();
end loop hang;
for i in 1..3 loop --下三行
for k in 0..i loop
dbms_output.put(' ');
end loop;
for j in reverse 1..(7-2*i) loop
dbms_output.put('*');
end loop;
dbms_output.new_line();
end loop;
end;
第二题:
declare
newage student.age%type;
--newid student.id%type;
begin
insert into student(id,age) values(6,50);
savepoint p1;
update student set age=&a where id=&i;
select age into newage from student where id = &i;
if newage>40 then
rollback to p1;
dbms_output.put_line('已返回回滚点提交');
commit;
else
dbms_output.put_line('已直接提交');
commit;
end if;
end;
第三题:
declare
wage emp.sal%type; --%type例子
whole emp%rowtype; --rowtype例子
type rec is record(
nam emp.ename%type,
job emp.job%type
);myrec rec; --record例子
type tabl is table of emp.job%type index by binary_integer;mytable tabl; --table例子
begin
select sal into wage from emp where empno=7654;
dbms_output.put_line('wage is ' ||wage);
select * into whole from emp where empno = &exrow;
dbms_output.put_line('姓名'||whole.ename);
dbms_output.put_line('岗位'||whole.job);
select ename,job into myrec from emp where empno=&exrec;
dbms_output.put_line('姓名'||myrec.nam);
dbms_output.put_line('岗位'||myrec.job);
select ename into mytable(-1) from emp where empno=&extab;
dbms_output.put_line('姓名'||mytable(-1));
end;
第四题:
declare
--row_in_table emp%rowtype;
type row_table is table of emp_20%rowtype index by binary_integer;
datas row_table;
begin
for i in 1..5 loop
select * into datas(i) from emp_20 where id=i;
end loop;
for i in 1..5 loop
dbms_output.put('id '||datas(i).id);
dbms_output.put(' name '||datas(i).name);
dbms_output.put(' sex '||datas(i).sex);
dbms_output.put(' age '||datas(i).age);
dbms_output.put(' salary '||datas(i).salary);
dbms_output.put(' sid '||datas(i).sid);
dbms_output.new_line();
end loop;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -