必须声明错误PLS-00201标识符

时间:2015-04-30 00:39:18

标签: plsql

所以我一直有这个错误,而且我对于发生了什么一无所知。我已经用Google搜索了一些关于此错误的问题,但没有任何效果。我只想让它运行所以我可以完成我的项目。

public abstract class AbstractListMM<K,V> implements IMiniMap<K,V>{

    private List <K> keys; 
    private List <V> values;

// Initialize the lists of keys and values with a concrete instance
public AbstractListMM(List <K> keys, List <V> values)
{
    this.keys = keys;
    this.values = values;
}

// Return the number of bindings based on the size of the key list
public int size()
{
    return keys.size();
}

// Based on the lists size
public boolean isEmpty()
{
     return (keys.isEmpty() && values.isEmpty());
}

// Make a (shallow) copy of the keys list and return it
public List<K> keys()
{
     List<K> newKeys = this.keys;
     return newKeys;
} 

// Make a (shallow) copy of the vals list and return it
public List<V> values()
{
    List<V> values = this.values;
    return values;
}

// Use this.indexOf() to locate the given key as quickly as possible
public boolean contains(K key)
{
    if(this.indexOf(key) < 0)
        return false;
    else 
        return true;
}

// Use this.indexOf() to determine if a given key is present and
// return its associated value; return null if the key is not
// present
//
// TARGET COMPLEXITY: Same speed as indexOf()
public V get(K key)
{
    if(this.indexOf(key) < 0)
        return null;
    else 
    {
        for(int i = 0; i < this.values.size(); i++)
        {

        }
    }
}

// Use this.indexOf() to determine the location of the given
// key/value and remove it from the corresponding lists
//
// TARGET COMPLEXITY: O(N) due to list elements shifting
public V remove(K key);

// Find the numeric index of the key as quickly as possible based on
// the type of ListMM being implemented. Return a negative number if
// the given key is not present.
public abstract int indexOf(K key);

// Associate the given key with the given value in the
// lists. Creates an ordering of keys that is compatible with how
// indexOf() works to locate keys.
public abstract V put(K key, V value);

}

错误: 开始低谷;结束;        * 第1行的错误: ORA-06550:第1行第9栏: PLS-00201:标识符&#39; LOWINVENTORY&#39;必须申报 ORA-06550:第1行,第7列: PL / SQL:忽略语句

修改

create or replace procedure LOWINVENTORY is

--Variables
ID number;
itemNamed char(15);
description char(20);
startQty number;

--Define inventory item cursor
cursor nextItem is
select inventory.itemID, inventory.itemName, inventory.description, inventory.startQty;
from inventory
where inventory.startQty < 5;

begin
open nextItem;
fetch netxtItem into ID, itemNamed, description, startQty;
if nextItem%notfound then
    dbms_output.put_line('No items in need of reordering.');
else
    dbms_output.put_line('*********************');
    dbms_output.put_line('++Inventory Report++');
    dbms_output.put_line('*********************');
    dbms_output.put_line('Item Name---ID------Description----------Quantity');
    loop
        dbms_output.put_line(itemNamed||'-'||ID||'-'||description||'-'||startQty);
        fetch netxtItem into ID, itemNamed, description, startQty;
        if nextItem%notfound then
            dbms_output.put_line('************END REPORT*************');
            exit when nextItem%notfound;
    end loop;
end lowInventory;

表创建:

INSERT INTO inventory(itemID, itemLocation, itemName, description, typicalPrice, startQty)
VALUES(24548576, 'toolbox1', 'wrench', 'turns bolts', 14.00, 6);
INSERT INTO inventory(itemID, itemLocation, itemName, description, typicalPrice, startQty)
VALUES(83742345, 'toolbox1', 'pliers', 'grabs stuff', 11.00, 4);
INSERT INTO inventory(itemID, itemLocation, itemName, description, typicalPrice, startQty)
VALUES(39287426, 'chest2', 'jigsaw', 'cuts stuff', 28.00, 3);
INSERT INTO inventory(itemID, itemLocation, itemName, description, typicalPrice, startQty)
VALUES(48927349, 'chest1', 'blowtorch', 'torches stuff', 330.00, 2);
INSERT INTO inventory(itemID, itemLocation, itemName, description, typicalPrice, startQty)
VALUES(85463455, 'bench3', 'oil filter', 'filters stuff', 16.00, 20);

1 个答案:

答案 0 :(得分:1)

你的代码充满了愚蠢的错误, 首先,

select inventory.itemID, inventory.itemName, 
inventory.description, inventory.startQty;   --> semicolan here, the statment doesnt end
from inventory
where inventory.startQty < 5;

其次,

cursor nextItem is --> using nextItem as name in cursor but "netxtItem" while opening it,  a typo

第三,

如果在else部分内,则无止境,循环

以下是已编译的过程, 我创建了库存表,在程序中只使用了4列来编译程序

SQL> create or replace procedure LOWINVENTORY is
  2
  3  --Variables
  4  ID number;
  5  itemNamed char(15);
  6  description char(20);
  7  startQty number;
  8
  9  --Define inventory item cursor
 10  cursor nextItem is
 11  select inventory.itemID, inventory.itemName, inventory.description, inventory.startQty
 12  from inventory
 13  where inventory.startQty < 5;
 14
 15  begin
 16  open nextItem;
 17  fetch nextItem into ID, itemNamed, description, startQty;
 18  if nextItem%notfound then
 19      dbms_output.put_line('No items in need of reordering.');
 20  else
 21      dbms_output.put_line('*********************');
 22      dbms_output.put_line('++Inventory Report++');
 23      dbms_output.put_line('*********************');
 24      dbms_output.put_line('Item Name---ID------Description----------Quantity');
 25      loop
 26          dbms_output.put_line(itemNamed||'-'||ID||'-'||description||'-'||startQty);
 27          fetch nextItem into ID, itemNamed, description, startQty;
 28          if nextItem%notfound then
 29              dbms_output.put_line('************END REPORT*************');
 30              exit when nextItem%notfound;
 31             end if;
 32             end loop;
 33  end if;
 34
 35  end lowInventory;
 36  /

Procedure created.

SQL>

修改

SQL> insert into inventory (itemid,itemname,description,startqty) values (1,'abc','descp1',1) ;

1 row created.

SQL> insert into inventory (itemid,itemname,description,startqty) values (2,'abcd','descp2',1) ;

1 row created.

SQL> set serveroutput on;


SQL> exec lowInventory;
*********************
++Inventory Report++
*********************
Item Name---ID------Description----------Quantity
abc            -1-descp1              -1
abcd           -2-descp2              -1
************END REPORT*************

PL/SQL procedure successfully completed.

SQL>

编辑2

包含您提供的数据

SQL> exec lowinventory;
*********************
++Inventory Report++
*********************
Item Name---ID------Description----------Quantity

jigsaw         -39287426-cuts stuff          -3
pliers         -83742345-grabs stuff         -4
jigsaw         -39287426-cuts stuff          -3
blowtorch      -48927349-torches stuff       -2
************END REPORT*************

PL/SQL procedure successfully completed.