日期:2014-05-17  浏览次数:20891 次

oracle 11g PLS-00201问题
我用的是oracle 11.2.0.1

创建function语句:
SQL code

CREATE OR REPLACE 
FUNCTION get_greece_alphabet_py(p_Index NUMBER)
RETURN NUMBER IS
  v_greece_alphabet_list TGREECE_ALPHABET_LIST := TGREECE_ALPHABET_LIST(
    'a','b','g','d','e','z','e','th','i','k','l','m','n','x','o','p','r',
    's','t','u','ph','kh','ps','o'
  );
BEGIN
  IF (p_Index>0) AND (p_Index<95) THEN
    RETURN v_greece_alphabet_list(p_Index);
  ELSE
    RETURN '';
  END IF;
end get_greece_alphabet_py;


在创建function会有类似如下错误:
PLS-00201:必须声明标识符 TGREECE_ALPHABET_LIST
PLS-00320:此表达式的类型声明不完整或格式不正确
PL/SQL:Statement ignored

百度和google貌似都没搜到相关的问题
各位帮忙看看是什么问题
先谢谢了
急。。。。。。。。。

------解决方案--------------------
SQL code

CREATE OR REPLACE 
FUNCTION get_greece_alphabet_py(p_Index NUMBER)
RETURN NUMBER IS
  type TGREECE_ALPHABET_LIST is table of varchar2(10);--你使用了集合類型,但沒有定義,定義下就可以了
  v_greece_alphabet_list TGREECE_ALPHABET_LIST := TGREECE_ALPHABET_LIST(
    'a','b','g','d','e','z','e','th','i','k','l','m','n','x','o','p','r',
    's','t','u','ph','kh','ps','o'
  );
BEGIN
  IF (p_Index>0) AND (p_Index<95) THEN
    RETURN v_greece_alphabet_list(p_Index);
  ELSE
    RETURN '';
  END IF;
end get_greece_alphabet_py;
/

------解决方案--------------------
SQL code

--可以
create or replace type TGREECE_ALPHABET_LIST is table of varchar2(10);
/
CREATE OR REPLACE 
FUNCTION get_greece_alphabet_py(p_Index NUMBER)
RETURN NUMBER IS
  v_greece_alphabet_list TGREECE_ALPHABET_LIST := TGREECE_ALPHABET_LIST(
    'a','b','g','d','e','z','e','th','i','k','l','m','n','x','o','p','r',
    's','t','u','ph','kh','ps','o'
  );
BEGIN
  IF (p_Index>0) AND (p_Index<95) THEN
    RETURN v_greece_alphabet_list(p_Index);
  ELSE
    RETURN '';
  END IF;
end get_greece_alphabet_py;
/