2015-02-24 105 views
2

我有以下各項無效的數據類型PL/SQL

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 

我試圖使用排序集合 -

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; 

,我收到了錯誤的數據類型無效的stations_table_type。我該如何解決它?

回答

3

在Oracle使用以這種方式包定義的類型不被支持。您需要創建下列方式數據庫SQL對象類型:注意此處不支持該聲明列%類型(既不INDEX BY子句)

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; 

現在,您可以實現使用這些類型排序選擇。