[英]Oracle SELECT statement not working - ORA-00942
Hopefully a simple question. 希望是一个简单的问题。
error_reporting(E_ALL);
ini_set('display_errors', '1');
$c = oci_connect('whatmyusrnameis', 'whatmypwdis', 'host');
if ($c) {
echo 'connection';
}
$s = oci_parse($c, 'select * from mantis_bug_table');
oci_execute($s);
The following results in 以下结果
Warning oci_execute(): ORA-00942: table or view does not exist
警告oci_execute(): ORA-00942: table or view does not exist
but the connection doesn't result in any errors and the DB table does exist and it is not empty. 但是连接不会导致任何错误,并且DB表确实存在并且它不是空的。
Any ideas??? 有任何想法吗??? Thank you :). 谢谢 :)。
Typically this has one of four possible problems 通常,这有四个可能的问题之一
select * from DB_USER.mantis_bug_table
(See Justin Cave's answer regarding SYNONYMs if you don't want qualify the tablename) 您可能需要将所有者添加到表名中,例如select * from DB_USER.mantis_bug_table
(如果您不想要限定表名,请参阅Justin Cave关于SYNONYM的答案) You can diagnose this by running the following 您可以通过运行以下命令来诊断它
SELECT * FROM ALL_TABLES WHERE UPPER(table_name) = 'MANTIS_BUG_TABLE'
MANTIS_BUG_TABLE
table? 是否有MANTIS_BUG_TABLE
表的公共或私有同义词? If the table is owned by some other user, you could try fully qualifying the table name 如果该表由其他某些用户拥有,则可以尝试完全限定表名
$s = oci_parse($c, 'select * from owner_of_table.mantis_bug_table');
If the user your PHP script is using doesn't have access to the table, you'll need a DBA or the owner of the table to 如果您的PHP脚本使用的用户无权访问该表,则您需要DBA或该表的所有者
GRANT SELECT ON owner_of_table.mantis_bug_table
TO whatmyusernameis;
If you have access to the table and fully qualifying the table name works but you don't want to have to fully qualify the table name every time, you can create a synonym 如果您有权访问该表并完全限定表名,但您不希望每次都完全限定表名,则可以创建同义词
CREATE [PUBLIC] SYNONYM mantis_bug_table
FOR owner_of_table.mantis_bug_table
A public synonym allows all users with access to the table to reference it without using a fully qualified name. 公共同义词允许所有有权访问该表的用户在不使用完全限定名的情况下引用该表。 A private synonym allows just the owner of the synonym (ie whatmyusernameis) to reference the table without a fully qualified table name. 私有同义词只允许同义词的所有者(即whatmyusernameis)引用该表而没有完全限定的表名。
You should point scheme in connection string like: 你应该在连接字符串中指向scheme,如:
oci_connect('whatmyusrnameis', 'whatmypwdis', 'host/**YOUR_DB**');
Look at http://www.php.net/manual/en/function.oci-connect.php in section connection_string 请查看connection_string部分中的http://www.php.net/manual/en/function.oci-connect.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.