无效的数据类型PL/SQL

无效的数据类型PL/SQL,sql,oracle,plsql,Sql,Oracle,Plsql,我有以下几点- TYPE station_record_type IS RECORD ( station_code t_stations.station_code%TYPE, city_name d_cities.city_name%TYPE, station_name d_stations.station_name%TYPE, state_name gis_states.state_name%TYPE,

我有以下几点-

 TYPE station_record_type IS RECORD
    (
        station_code  t_stations.station_code%TYPE,
        city_name d_cities.city_name%TYPE,
        station_name d_stations.station_name%TYPE,
        state_name gis_states.state_name%TYPE,
       country_name d_countries.country_name%TYPE,
        record_type pls_integer
    );

    TYPE stations_table_type IS TABLE OF station_record_type
       INDEX BY BINARY_INTEGER;


  o_stations_to_retrieve      stations_table_type
我正在尝试使用--


我收到错误“stations\u table\u type的数据类型无效”。如何修复它?

在Oracle中,不支持以这种方式使用包定义的类型。您需要按以下方式创建数据库sql对象类型:注意,此处不支持声明列%type(既不支持INDEX BY子句也不支持INDEX BY子句)

现在,您可以使用这些类型实现排序选择

    SELECT CAST (MULTISET (SELECT station_record_type (station_code,
                                                         city_name,
                                                         station_name,
                                                         state_name,
                                                         country_name,
                                                         record_type)
                               FROM TABLE (o_stations_to_retrieve)
                           ORDER BY country_name,
                                    state_name,
                                    city_name,
                                    record_type,
                                    station_name ) AS stations_table_type)
      INTO o_stations_to_retrieve
      FROM DUAL;
CREATE TYPE station_record_type IS OBJECT
(
    station_code  varchar2(100),
    city_name varchar2(100),
    station_name varchar2(100),
    state_name varchar2(100),
   country_name varchar2(100),
    record_type number
 )
 /
  create   TYPE stations_table_type IS TABLE OF station_record_type;