数据库原理及Oracle应用.pdfVIP

  • 0
  • 0
  • 约2.02千字
  • 约 5页
  • 2026-02-27 发布于河南
  • 举报

数据库原理及Oracle应用

实验报告

数据库原理及Oracle应用

课程名称:

经济管理学院

学院:

信息管理与信息系统

专业班:

姓名:

110

学号:

指导教师:

12年5月7日

实验五、程序块的使用

实验目的:

SQLPLUS的使用

DBAStudio的使用

实验要求:了解游标的使用,掌握plsql的高级编程技巧

1.解释并运行下列程序的结果

setserveroutputon

declare

maxrecordsconstantint:=100;

iint:=1;

begin

foriin1..maxrecordsloop

insertintotempuser.testtable(recordnumber,currentdate)

values(i,sysdate);

endloop;

dbms_output.put_line(成功录入数据!);

commit;

end;

声明常量是maxrecords和i并分别初始化为100和1,利用for循环给tempuser.testtable表插

入100条记录,它的值分别为recordnumber字段的值为1-100,currentdate字段的值为系统

日期。

2.使用匿名块来计算的是10+3*4-20+5**2的值。

3.通过程序判断两个整数变量的大小,输出不同的结果,将下列程序补全。

setserveroutputon

declare

number1integer:=80;

number2integer:=90;

begin

。。。

。。。

。。。

end;

4.举一循环控制的事例程序。如序将number1变量每次加1,一直到等于number2为

止,统计输出循环次数。

setserveroutputon

declare

number1integer:=80;

number2integer:=90;

iinteger:=0;

begin

。。。

。。。

。。。

end;

5.将下列程序调成正确可以运行的程序,并说明程序实现的功能。

为职工增加10%的工资,从最低工资开始长,增加后工资总额限制在50万以内。

6.将下列程序调成正确可以运行的程序,并说明程序实现的功能。

DECLARE

v_deptnoemp.deptno%type:=p_deptno;

v_empnoemp.empno%type;

v_salemp.sal%type;

v_jobemp.job%type;

cursoremp_cursorISSELECTempno,job,salFROMempwheredeptno=v_deptnoFORUPDATE

OFsal;

BEGIN

FORemp_recordINemp_cursorLoop

IFemp_record.sal800THEN

UPDATEempSETsal=800WhereCURRENTOFemp_cursor;

ENDIF;

dbms_output.put_line(emp_record.empno||emp_record.sal);

ENDLOOP;

commit;

End;

/

查询emp表某部门的雇员情况,如果某雇员的工资小于80

文档评论(0)

1亿VIP精品文档

相关文档