你如何用PHP插入到oracle表中

时间:2013-06-27 18:42:53

标签: php oracle

我试图通过php脚本插入到oracle表中。

我的样本数据是:

$sql="insert into VMSTAT_PRD (DATE, LPAR, lcpu, mem, ent, r, b, p, avm, free, fi, fo, pi, po, fr, sr, in_faults, sy, cs, usr, sys, idle, waitio, pc, ec) VALUES ('2013-06-27 14:52:54','servera',96,393216,16.00,8,1,0,50104312,279318,5291,632,0,0,5799,10185,4533,74621,32708,5,4,91,1,1.87,11.7)";

$conn=odbc_connect('Odbc_name','user','passwd');
$rs=odbc_exec($conn,$sql);

我收到此错误:

PHP Warning:  odbc_exec(): SQL error: [Oracle][ODBC][Ora]ORA-00928: missing SELECT keyword
, SQL state S1000 in SQLExecDirect in C:\PHP\cpu.php on line 100

Warning: odbc_exec(): SQL error: [Oracle][ODBC][Ora]ORA-00928: missing SELECT keyword
, SQL state S1000 in SQLExecDirect in C:\PHP\cpu.php on line 100
Error in SQL

任何想法此错误消息的含义是什么?

1 个答案:

答案 0 :(得分:1)

你应该准备好真正插入数据库。

   $conn=odbc_connect('Odbc_name','user','passwd');


   $sql="insert into VMSTAT_PRD (DATE, LPAR, lcpu, mem, ent, r, b, p, avm, free, fi, fo, pi, po, fr, sr, in_faults, sy, cs, usr, sys, idle, waitio, pc, ec) VALUES ('2013-06-27 14:52:54','cigp01a2a001',96,393216,16.00,8,1,0,50104312,279318,5291,632,0,0,5799,10185,4533,74621,32708,5,4,91,1,1.87,11.7)";
   $prepare = odbc_prepare($conn, $sql);
   $rs=odbc_execute($prepare);