DECLARE
TYPE STUDENT_INDEX_TABLE_TYPE IS TABLE OF STUDENT%ROWTYPE INDEX BY BINARY_INTEGER;
student_index_table STUDENT_INDEX_TABLE_TYPE;
BEGIN
SELECT * BULK COLLECT INTO student_index_table FROM STUDENT;
dbms_output.put_line(student_index_table(1).sname);
END;CREATE TABLE STUDENT
(
SID VARCHAR(10) PRIMARY KEY,
SNAME VARCHAR(10),
SCORE INT
)INSERT INTO STUDENT VALUES('1','AA',88);
INSERT INTO STUDENT VALUES('2','PP',66);
INSERT INTO STUDENT VALUES('3','OO',55);提示 student_index_table 类型错误,请高手解决,在线等!
---------- ---------- ----------
1 AA 88
2 PP 66
3 OO 55已用时间: 00: 00: 00.01
16:01:29 tina@PRACTICE> DECLARE
16:01:43 2 TYPE STUDENT_INDEX_TABLE_TYPE IS TABLE OF STUDENT%ROWTYPE INDEX BY BINARY_INTEGER;
16:01:43 3 student_index_table STUDENT_INDEX_TABLE_TYPE;
16:01:43 4 BEGIN
16:01:43 5 SELECT * BULK COLLECT INTO student_index_table FROM STUDENT;
16:01:43 6 dbms_output.put_line(student_index_table(1).sname);
16:01:43 7 END;
16:01:44 8 /
AAPL/SQL 过程已成功完成。已用时间: 00: 00: 00.00
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
请问plsql 5 下怎么写呢 谢谢
1 CREATE TABLE STUDENT
2 (
3 SID VARCHAR(10) PRIMARY KEY,
4 SNAME VARCHAR(10),
5 SCORE INT
6 )
7* tablespace myts
17:21:02 8 /表已创建。 1 declare
2 type student_index_type is table of student%rowtype index by binary_integer;
3 student_index student_index_type;
4 begin
5 select * bulk collect into student_index from student;
6 dbms_output.put_line(student_index(1).sname);
7* end;
17:22:42 SQL> /PL/SQL 过程已成功完成。17:23:50 SQL> set serveroutput on
17:23:58 SQL> /
AAPL/SQL 过程已成功完成。