oracle 错误 201 必须声明选择标识符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7719716/
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
Error 201 select identifier must be declared
提问by user293895
I am trying to make a login form through Oracle's Form Builder, I have a table called TRAVEL_USER which I made in SQLPlus.
我正在尝试通过 Oracle 的 Form Builder 创建一个登录表单,我有一个名为 TRAVEL_USER 的表,它是我在 SQLPlus 中创建的。
I have made a button and am using the trigger WHEN-BUTTON-PRESSED.
我制作了一个按钮,正在使用 WHEN-BUTTON-PRESSED 触发器。
To start myself off I am using this code to simply count the number of users registered on the system:
为了开始我自己,我使用这个代码来简单地计算系统上注册的用户数量:
DECLARE
TUsers NUMBER := 0;
BEGIN
SELECT COUNT(*) FROM TRAVEL_USER;
END;
When compiling this I get the following error: Error 201: identifier 'TRAVEL_USER' must be declared.
编译时出现以下错误:错误 201:必须声明标识符“TRAVEL_USER”。
I can confirm that this table exists in the database I am connecting to, I checked via SQLPlus and the data block wizard in the Oracle Forms Builder.
我可以确认这个表存在于我要连接的数据库中,我通过 SQLPlus 和 Oracle Forms Builder 中的数据块向导进行了检查。
I connect to the database with full admin privileges (using the system username).
我以完全管理员权限(使用系统用户名)连接到数据库。
回答by DCookie
What user owns the TRAVEL_USER table? If you're connecting as the user SYSTEM (Bad Idea) then you likely need to fully qualify the table name with the schema name that owns the table:
哪个用户拥有 TRAVEL_USER 表?如果您以用户 SYSTEM(坏主意)的身份连接,那么您可能需要使用拥有该表的架构名称来完全限定表名:
SELECT COUNT(*) FROM owner.travel_user;
Either that or create a public synonym for the table:
要么为该表创建一个公共同义词:
CREATE PUBLIC SYNONYM travel_user FOR owner.travel_user;
You should not make a habit of using the SYS or SYSTEM accounts for application purposes. They are system accounts and should be used for system purposes.
您不应养成将 SYS 或 SYSTEM 帐户用于应用目的的习惯。它们是系统帐户,应用于系统目的。
回答by Sukhwinder
(BEST WAY IS TO)
(最好的方法是)
DECLARE
SNAME NUMBER:=0;
BEGIN
SELECT COUNT(*) INTO SNAME FROM TRAVEL_USER;
:PCOUNT:=SNAME;
END;
I USED THIS IN ORACLE FORM BUILDER 10G PRACTICALLY AND IT WORKS
我在 ORACLE FORM BUILDER 10G 中实际使用它并且它有效
FIRST SELECT COUNT FROM TABLE INTO VARIABLE(SNAME) AND AFTER THAT CREATE AN DISPLAY ITEM LIKE(PCOUNT) THEN ASSIGN THE VALUE OF SNAME TO PCOUNT
首先从表中选择计数到变量(SNAME),然后创建一个显示项,如(PCOUNT)然后将 SNAME 的值分配给 PCOUNT
I AM USING THIS CODE INTO THE WHEN-PRESSED-BUTTON TIGGER AND IT WORK'S PROPERLY
我正在将此代码用于按下按钮的触发器并且它正常工作