答案+问题:
CREATE TABLE STUDENT_TEST
(
STUDENT_NAME VARCHAR2(30 BYTE),
STUDENT_SEX NUMBER(2),
STUDENT_AGE NUMBER(3),
CHINESE NUMBER(8),
ENGILSH NUMBER(8),
COMPUTER NUMBER(8),
SALL NUMBER(8),
PAIMING VARCHAR2(30 BYTE),
IF_HEGE VARCHAR2(6 BYTE)
);
create or replace procedure t_student_teat(if_flag out varchar2)
is
vn_student_name varchar2(20);
vn_student_sex number(2);
vn_student_age number(2);
vn_chinese number(3);
vn_enlish number(3);
vn_computer number(3);
vn_all number(3);
vn_paiming number(5);
vn_count number(10);
vn_allcount number(10);
boy number(10) := 0;
girl number(10) := 0;
--vn_if_hege varchar2(20);
cursor c_tt is
select student_name from student_test order by sall desc;
begin
if_flag := '1';
for i in 1 .. 1000 loop
select 'student_name' || lpad(i, 4, '0')
/*1.怎么查询内容带引号?lpad(i, 4, '0')是什么意思?*/
into vn_student_name
from dual;
/*2.此表是哪来的?*/
select trunc(dbms_random.value(17, 20)) into vn_student_age from dual;
/*3.此语句详细解释每个词的意思,与使用方法*/
select trunc(dbms_random.value(1, 151)) into vn_chinese from dual;
select trunc(dbms_random.value(1, 151)) into vn_enlish from dual;
select trunc(dbms_random.value(1, 151)) into vn_computer from dual;
vn_all := vn_chinese + vn_enlish + vn_computer;
vn_student_sex := round(DBMS_RANDOM.VALUE(1, 2));
/*4.等号后边的用法说明*/
if vn_student_sex = 1 then
/*5.if语句如何实现功能简述,boy和girl不用定义?怎么还出现501了*/
girl := girl + 1;
else
boy := boy + 1;
end if;
if boy >= 501 then
vn_student_sex := 1;
elsif girl >= 501 then
vn_student_sex := 2;
end if;
vn_paiming := 1;
insert into student_test
values
(vn_student_name,
vn_student_sex,
vn_student_age,
vn_chinese,
vn_enlish,
vn_computer,
vn_all,
vn_paiming,
'Y');
end loop;
commit;
/*6.往后是啥意思?*/
select count(*) into vn_allcount from student_test;
vn_count := 1;
for rec in c_tt loop
update student_test
set paiming = vn_count
where student_name = rec.student_name;
commit;
if vn_count > vn_allcount * 0.8 then
update student_test
set if_hege = 'N'
where student_name = rec.student_name;
commit;
end if;
vn_count := vn_count + 1;
end loop;
commit;
exception
when others then
dbms_output.put_line(sqlerrm);
if_flag := '0';
rollback;
end t_student_teat;
由于有字数限制,我分2块写题和答案,答案满意者,200分全送上
这是题目连接
http://zhidao.baidu.com/question/241580602.html
麻烦也说下结构体,就是大概的结构。思路