Oracle Table Demo statement SQL code www.2cto.com -- Created on 2010/07/29 by WANGNAN declare -- Local variables here i1 VARCHAR2 (20): = '1'; i2 VARCHAR2 (20): = '1 '; i3 VARCHAR2 (20): = '2'; i4 VARCHAR2 (20): = '3'; i5 VARCHAR2 (20): = '3'; i6 VARCHAR2 (20 ): = '3'; i7 VARCHAR2 (20): = '5'; I _before VARCHAR2 (20); TYPE t_type IS TABLE OF VARCHAR2 (20); t_table t_type; BEGIN -- Test statements here t_table: = t_type (); t_table.extend; t_table (1): = i1; t_table.extend; t_table (2): = i2; t_table.extend; t_table (3 ): = i3; t_table.extend; t_table (4): = i4; t_table.extend; t_table (5): = i5; t_table.extend; t_table (6): = i6; t_table.extend; t_table (7 ): = i7; FOR I IN 1 .. t_table.count loop if I _before is null or I _before <> t_table (I) THEN I _before: = t_table (I); dbms_output.put_line (t_table (I); END IF; END LOOP; exception when others then dbms_output.put_line (Sqlerrm); end;