日期:2014-05-17  浏览次数:20362 次

php查询oracle 临时表,为什么为空?

$dbOracle=oci_connect("数据库连接都是正常的,查询不是临时表都正常");

$oracleSql="". 
"begin ". 
"    insert into FS_TT". 
"    select * ". 
"    from FS ". 
"    where rownum <2;". 
" end;";//不用begin 直接写sql也是一样的   $stid = oci_parse($dbOracle, $oracleSql);

 $r=oci_execute($stid);
 print_r($r);

 $oracleSql="select * from FS_TT";
 $stid = oci_parse($dbOracle, $oracleSql);
 $r=oci_execute($stid);
 print_r($r);
   //上面sql在plsql里面执行都没有问题,能查询出 临时表新插入的数据 
   //但是php就查询不出来 
   //把临时表,改成正是表,php就可以查询出来 
   //什么原因呢?我现在还算是在一个会话里面把? 
   //权限?我php连接用的用户名密码,和plsql用的一样   

 while ($row = oci_fetch_assoc($stid)){     
echo $row['NAME'],"<br>\n";
 }  


------解决方案--------------------
可能是  where rownum <=2; 后面的分号导致的查询失败


$oracleSql = "insert into FS_TT select * from FS where rownum <=2";
看看