ORA-00984 此处不允许列

发布于 2024-11-12 23:03:21 字数 801 浏览 7 评论 0原文

我收到错误 “执行-984 ORA-00984:此处不允许列” 当我使用 Pro*C 在我的表 Registred_Customer 中插入值时,

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)
);

在 Pro*C 方法中使用 pro*c 方法插入值

addCustomer(i, name,age, gender, address,contectNo);

,我使用以下代码在此处插入

EXEC SQL INSERT INTO REGISTRED_CUSTOMER VALUES  
(cust_id, cust_name, age, sex, addr,   contact);

cust_name 和 addr 是 char *;性是 char 其余为 int;

它在使用变量时报告错误,但使用直接值可以正常工作 就像 EXEC SQL INSERT INTO REGISTRED_CUSTOMER VALUES (10, 'Pankaj', 23, 'M', 'asdfs', 45875);

我尝试更改几行但徒劳。

提前致谢。

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

Registred_Customer is defined as

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

addCustomer(i, name,age, gender, address,contectNo);

in Pro*C method I use following code to insert

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;

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);

I tried changing few lines but in vain.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

柠檬 2024-11-19 23:03:22

如果我看对了,你正在尝试插入到列中,列?

“执行 SQL 插入 REGISTRED_CUSTOMER VALUES(cust_id、cust_name、年龄、性别、地址、联系人);”?

如果您发布完整的程序会更有帮助。

问候

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);"??

it would be more helpful if you post your procedure complete.

Regards

牛↙奶布丁 2024-11-19 23:03:22

正如先生提到的,您正在尝试使用列作为输入值。当您提供实际值时,它就会起作用。您是否打算使用 PL/SQL 变量或过程参数?在这种情况下,无论您的过程参数被调用什么,您都应该将其放在值部分中。

即如果 addCustomer 看起来像

PROCEDURE addCustomer (pId NUMBER, pName VARCHAR2, pAge NUMBER, pGender CHAR, pAddress VARCHAR2, pContact NUMBER)

那么你会做类似的事情

INSERT INTO registered_customer (cust_id, name, age, sex, addr, contact) VALUES (pId, pName, pAge, pGender, pAddress, pContact);

但是如果你要插入到所有列中,你可以省略列定义并只提供值

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.

i.e if addCustomer looks like

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

要走就滚别墨迹 2024-11-19 23:03:22

我还在执行插入的存储过程中收到此错误消息。我在 Values 子句中拼错了一个参数名称,Oracle 解释器将拼错的名称视为列名称并发出 00984。

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.

饮湿 2024-11-19 23:03:21

您的 Pro*C 代码基本上缺少冒号(假设您的形式参数称为 cust_idcust_nameage 等)

EXEC SQL INSERT INTO REGISTRED_CUSTOMER VALUES  
    (:cust_id, :cust_name, :age, :sex, :addr, :contact);

:显式指定列名称会更加稳健。否则,对表架构的更改可能会导致难以发现错误:

EXEC SQL INSERT INTO REGISTRED_CUSTOMER (Cust_Id, Name, Ag, Sex, Addr, Contact)
    VALUES (:cust_id, :cust_name, :age, :sex, :addr, :contact);

Your Pro*C code is basically missing the colons (assuming that your formal parameters are called cust_id, cust_name, age etc.):

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文