-2

我正在尝试使用 perl DBI 将 perl 生成的数据插入到 oracle 数据库表中。这是我第一次尝试这个,所以很可能我犯了一个简单的错误。

我目前使用的是:

$dbh = DBI->connect ('dbi:Oracle:geosgen','student','train')
  || die "Database connection not made: $DBI::errstr";

  $sql = "INSERT INTO MYTEST VALUES ($series, $sheet, $maxlat, $minlat, $maxlong, $minlong)";

  $create = $dbh->do($sql);
  print "Content-type:text/html\n\n\n";
if($Create){
print "Success";
}
else{
print "Failure<br/>$DBI::errstr";
}

我得到的输出是这样的:

DBD::Oracle::db do failed: ORA-00917: missing comma (DBD ERROR: error possibly near <*> indicator at char 36 in 'INSERT INTO MYTEST VALUES (Scotland <*>one inch 1st, Shetland Islands (North) (131), -0.6800, -1.4100, 60.9700, 60.6900)') [for Statement "INSERT INTO MYTEST VALUES (Scotland one inch 1st, Shetland Islands (North) (131), -0.6800, -1.4100, 60.9700, 60.6900)"] at bruce1.pl line 69, <INPUT> line 924. Content-type:text/html

表示它已成功读取数据但失败。我想我犯了一个菜鸟错误,有什么明显的吗?

4

1 回答 1

4

SQL 要求引用字母常量:

INSERT INTO MYTEST VALUES ('Scotland 1 inch 1st', 'Shetland Islands (North) (131)', -0.6800, -1.4100, 60.9700, 60.6900)

如果您打印 $sql 的值,您会发现它们不是。

于 2013-06-05T21:08:15.853 回答