2015-11-13 59 views
0

我正在给我的代码的一小段代码,但在尝试为存储的Oracle PL SQL过程创建新订单时收到下面的错误消息。 第83行是代码中的插入语句,第84行是语句的插入部分。针对新的事务和订单的PL SQL存储过程

83/5 PL/SQL:SQL语句忽略
47分之84PL/SQL:ORA-00984:列在这里

BEGIN 
--Initializing values for variables 
x_rowcount := 0; 
x_stockonhand := 0; 
Totaldue := 0; 

--Total due calculation 
--(price of phone*quantity + shipping cost)*1.06 (assuming 6% sales tax) 
Totaldue := (((i_price * c_p_qty) + i_shipping_cost) * 1.06); 

SAVEPOINT start_transaction; -- mark a savepoint 
--INSERT a new record into order table. 
INSERT INTO orders(o_id,c_id,p_id,s_id,order_date,o_qty,order_total,card_type,cc_number,exp_date,shipping_status) 
VALUES (orders_seq.nextval, c_c_id,c_p_id,s_id,sysdate,c_p_qty,Totaldue,c_card_type,c_cc_number,c_exp_date,'Not shipped yet'); 
+0

认为您可能必须在插入前先获得序列。所以也许就像插入前从orders中选择orders_seq.nextval到myOrdersSeq中一样; (当然你需要定义myOrdersSeq) –

回答

0

不允许检查声明部分。通常,当您在未声明的变量名称或变量中输入拼写错误时,会出现此错误。例如:

SQL> create table tmp (id number, str varchar2(100)); 

Table created. 

SQL> declare 
a number; 
begin 
    insert into tmp (id, str) 
    values (a, a1); 
end; 
/ 
    values (a, a1); 
      * 
ERROR at line 5: 
ORA-06550: line 5, column 14: 
PL/SQL: ORA-00984: column not allowed here 
ORA-06550: line 4, column 3: 
PL/SQL: SQL Statement ignored 
0

这个错误是因为一个或多个值在VALUES(...,...)部分是无效的。

我会建议检查每一个,看看他们是有效的。例如,c_c_id是否在代码中的其他位置声明并赋值?如果没有,这可能是你的问题。每一个都需要声明并给出一个值,然后才能将其放入INSERT声明的VALUES(...,...)部分。

INSERT INTO orders(o_id,c_id,p_id,s_id,order_date,o_qty,order_total,card_type,cc_number,exp_date,shipping_status) 
VALUES (orders_seq.nextval, c_c_id,c_p_id,s_id,sysdate,c_p_qty,Totaldue,c_card_type,c_cc_number,c_exp_date,'Not shipped yet');