oracle ORA-00984 列在这里不允许
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6216350/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ORA-00984 column not allowed here
提问by Nitesh
I am getting error "Execute-984 ORA-00984: column not allowed here" while I am inserting values in my table Registred_Customer using Pro*C
当我使用 Pro*C 在我的表 Registred_Customer 中插入值时,我收到错误“Execute-984 ORA-00984: column not allowed here”
Registred_Customer is defined as
Registred_Customer 定义为
CREATE TABLE Registred_Customer (
Cust_id NUMBER(6) PRIMARY KEY,
Name VARCHAR2(20) NOT NULL,
Age NUMBER,
Sex CHAR,
Addr VARCHAR2(50),
Contact NUMBER(10)
);
Inserting values using a pro*c method
使用 pro*c 方法插入值
addCustomer(i, name,age, gender, address,contectNo);
in Pro*C method I use following code to insert
在 Pro*C 方法中,我使用以下代码插入
EXEC SQL INSERT INTO REGISTRED_CUSTOMER VALUES
(cust_id, cust_name, age, sex, addr, contact);
here cust_name and addr are char *; and sex is char rest as int;
这里 cust_name 和 addr 是 char *; 和性是 char 休息作为 int;
It reports error while using variable but works fine using direct values
like EXEC SQL INSERT INTO REGISTRED_CUSTOMER VALUES (10, 'Pankaj', 23, 'M', 'asdfs', 45875);
它在使用变量时报告错误,但使用直接值可以正常工作,例如 EXEC SQL INSERT INTO REGISTRED_CUSTOMER VALUES (10, 'Pankaj', 23, 'M', 'asdfs', 45875);
I tried changing few lines but in vain.
我尝试更改几行但徒劳无功。
Thanks in advance.
提前致谢。
回答by Codo
Your Pro*C code is basically missing the colons (assuming that your formal parameters are called cust_id
, cust_name
, age
etc.):
你的PRO * C代码基本上缺少冒号(假设你的形式参数,称为cust_id
,cust_name
,age
等):
EXEC SQL INSERT INTO REGISTRED_CUSTOMER VALUES
(:cust_id, :cust_name, :age, :sex, :addr, :contact);
And it would be more robust to explicitly specify the columns name. Otherwise a change to the table schema can result in difficult to find bugs:
明确指定列名会更健壮。否则对表架构的更改可能会导致难以发现错误:
EXEC SQL INSERT INTO REGISTRED_CUSTOMER (Cust_Id, Name, Ag, Sex, Addr, Contact)
VALUES (:cust_id, :cust_name, :age, :sex, :addr, :contact);
回答by Hector Sanchez
If im seeing correct you are trying to insert into the columns, the columns??
如果我看对了,您正在尝试插入列,列?
"EXEC SQL INSERT INTO REGISTRED_CUSTOMER VALUES (cust_id, cust_name, age, sex, addr, contact);"??
“EXEC SQL INSERT INTO REGISTRED_CUSTOMER VALUES(cust_id、cust_name、年龄、性别、地址、联系人);”??
it would be more helpful if you post your procedure complete.
如果您发布完整的程序会更有帮助。
Regards
问候
回答by Chris Cameron-Mills
As Mr. mentioned, you are trying to use the columns as input values. When you provide actual values it works. Are you perhaps meaning to use PL/SQL variables or the procedure arguments? In this case, whatever your procedure parameters are called is what you should put in the values section.
正如先生所提到的,您正在尝试使用列作为输入值。当您提供实际值时,它会起作用。您可能打算使用 PL/SQL 变量或过程参数吗?在这种情况下,无论您的过程参数被称为什么,您都应该将其放入值部分。
i.e if addCustomer looks like
即如果 addCustomer 看起来像
PROCEDURE addCustomer (pId NUMBER, pName VARCHAR2, pAge NUMBER, pGender CHAR, pAddress VARCHAR2, pContact NUMBER)
Then you'd do something like
然后你会做类似的事情
INSERT INTO registered_customer (cust_id, name, age, sex, addr, contact) VALUES (pId, pName, pAge, pGender, pAddress, pContact);
But if you are inserting into all columns you can leave out the column definition and just provide values
但是,如果您要插入所有列,则可以省略列定义而只提供值
回答by giscone
I also got this error message in a stored procedure doing an insert. I misspelled a parameter name in the values clause and the oracle interpreter saw the misspelled name as a column name and issued the 00984.
我还在执行插入操作的存储过程中收到此错误消息。我在 values 子句中拼错了一个参数名称,oracle 解释器将拼错的名称视为列名称并发出 00984。