我必须从一个oracle表中读取值并插入到另一个表中, 到目前为止的代码如下所示,虽然select工作正常,但插入没有发生。 无法找到问题所在,请帮忙。
<?
$dbuser = "M_APP";
$dbpassword = "App1";
$db = "MRPORT";
//$conn = oci_connect($dbuser,$dbpassword,$db);
$conn = oci_connect($dbuser,$dbpassword,'152.16.11.14:1528/MT');
if (!$conn){
echo "Connection error" ;
exit;
}
$sql = "SELECT * FROM EMP";
echo $sql . "<br>";
$stmt = oci_parse($conn, $sql);
if (!$stmt) {
echo "Error in preparing the statement";
exit;
}
oci_execute($stmt, OCI_DEFAULT);
echo "stmt executed" . "<br>";
while($row=oci_fetch_array($stmt)) {
//echo $row[0]." ".$row[1]. "<br>";
echo $row[0]. "<br>";
$val=$row[0];
$i_sql="INSERT INTO MGT VALUES($val,'');";
$i_stmt = oci_parse($conn, $i_sql);
$ic_sql="commit;";
$ic_stmt = oci_parse($conn, $ic_sql);
oci_execute($i_stmt, OCI_DEFAULT);
oci_execute($ic_stmt, OCI_DEFAULT);
echo $row[2]. "<br>";
//echo $row[name] . "<br>";
}
oci_close($conn);
&GT;