创建和填充 table oracle php 时出现问题 ORA-00933 ORA-00922 ORA-00928
Problem creating and populating table oracle php ORA-00933 ORA-00922 ORA-00928
我一直在网站中使用 Oracle 数据库,但在删除、创建或插入表时遇到错误。
掉落得到
Warning: oci_execute(): ORA-00933: SQL command not properly ended
创造给予
Warning: oci_execute(): ORA-00922: missing or invalid option
插入给出
Warning: oci_execute(): ORA-00928: missing SELECT keyword
编辑:(固定插入)
<?php
putenv("ORACLE_SID=teaching");
if ($Connection = oci_connect("username", "password")){
$sql = "DROP table BRANCH;";
$Statement = oci_parse($Connection, $sql);
oci_execute($Statement);
//drop rest of tables
$sql = "CREATE TABLE Branch
(Branch# Number,
PRIMARY KEY(Branch#));";
$Statement = oci_parse($Connection, $sql);
oci_execute($Statement);
//create rest of tables
$sql = "INSERT INTO Branch VALUES (12);";
$Statement = oci_parse($Connection, $sql);
oci_execute($Statement);
//insert rest of data
oci_close($Connection);
}else{
var_dump(oci_error($Connection));
}
?>
(@PonderStibbon 已经在评论中回答了,我将其放入后人的答案中 - 因此是社区 Wiki。)
在最后一条语句中,您将值插入到 table 中,INSERT
命令的语法不正确。正确的语法是:
INSERT INTO Branch VALUES (12)
我一直在网站中使用 Oracle 数据库,但在删除、创建或插入表时遇到错误。
掉落得到
Warning: oci_execute(): ORA-00933: SQL command not properly ended
创造给予
Warning: oci_execute(): ORA-00922: missing or invalid option
插入给出
Warning: oci_execute(): ORA-00928: missing SELECT keyword
编辑:(固定插入)
<?php
putenv("ORACLE_SID=teaching");
if ($Connection = oci_connect("username", "password")){
$sql = "DROP table BRANCH;";
$Statement = oci_parse($Connection, $sql);
oci_execute($Statement);
//drop rest of tables
$sql = "CREATE TABLE Branch
(Branch# Number,
PRIMARY KEY(Branch#));";
$Statement = oci_parse($Connection, $sql);
oci_execute($Statement);
//create rest of tables
$sql = "INSERT INTO Branch VALUES (12);";
$Statement = oci_parse($Connection, $sql);
oci_execute($Statement);
//insert rest of data
oci_close($Connection);
}else{
var_dump(oci_error($Connection));
}
?>
(@PonderStibbon 已经在评论中回答了,我将其放入后人的答案中 - 因此是社区 Wiki。)
在最后一条语句中,您将值插入到 table 中,INSERT
命令的语法不正确。正确的语法是:
INSERT INTO Branch VALUES (12)