使用PLSQL语句和游标循环打印出emp表中所有人工资和姓名。急谢谢了
2017-12-25 · 知道合伙人软件行家
关注
展开全部
查询输出所有员工编号,姓名,工资(PLSQL表类型)
DECLARE
TYPE emp_table_type IS TABLE OF employees%ROWTYPE INDEX BY BINARY_INTEGER;
e emp_table_type;
CURSOR emp_cursor IS
SELECT * FROM employees;
BEGIN
OPEN emp_cursor;
FETCH emp_cursor BULK COLLECT
INTO e;
FOR i IN 1 .. e.count LOOP
dbms_output.put_line('编号' || e(i).employee_id);
dbms_output.put_line('姓名' || e(i).last_name);
dbms_output.put_line('工资' || e(i).salary);
dbms_output.put_line('----------------------------');
END LOOP;
CLOSE emp_cursor;
END;
(5)查询输出所有员工编号,姓名,工资(通过limit控制提取的数据量)
DECLARE
TYPE emp_table_type IS TABLE OF employees%ROWTYPE
INDEX BY BINARY_INTEGER;
e emp_table_type;
CURSOR emp_cursor IS
SELECT * FROM employees;
BEGIN
OPEN emp_cursor;
FETCH emp_cursor BULK COLLECT INTO e LIMIT 6 ;
FOR i IN 1..e.count LOOP
dbms_output.put_line('编号' || e(i).employee_id);
dbms_output.put_line('姓名' || e(i).last_name);
dbms_output.put_line('工资' || e(i).salary);
dbms_output.put_line('----------------------------');
END LOOP;
CLOSE emp_cursor;
END;
DECLARE
TYPE emp_table_type IS TABLE OF employees%ROWTYPE INDEX BY BINARY_INTEGER;
e emp_table_type;
CURSOR emp_cursor IS
SELECT * FROM employees;
BEGIN
OPEN emp_cursor;
FETCH emp_cursor BULK COLLECT
INTO e;
FOR i IN 1 .. e.count LOOP
dbms_output.put_line('编号' || e(i).employee_id);
dbms_output.put_line('姓名' || e(i).last_name);
dbms_output.put_line('工资' || e(i).salary);
dbms_output.put_line('----------------------------');
END LOOP;
CLOSE emp_cursor;
END;
(5)查询输出所有员工编号,姓名,工资(通过limit控制提取的数据量)
DECLARE
TYPE emp_table_type IS TABLE OF employees%ROWTYPE
INDEX BY BINARY_INTEGER;
e emp_table_type;
CURSOR emp_cursor IS
SELECT * FROM employees;
BEGIN
OPEN emp_cursor;
FETCH emp_cursor BULK COLLECT INTO e LIMIT 6 ;
FOR i IN 1..e.count LOOP
dbms_output.put_line('编号' || e(i).employee_id);
dbms_output.put_line('姓名' || e(i).last_name);
dbms_output.put_line('工资' || e(i).salary);
dbms_output.put_line('----------------------------');
END LOOP;
CLOSE emp_cursor;
END;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |