duansao6776 2014-06-10 20:35
浏览 73

使用PHP和oracle数据库执行在另一个表中存储为列的查询

I have a bunch of sql queries stored in a column of an oracle database table. I have to retrieve one query at a time, execute it and display the results of this query on the front end. Here is the first query in the QUERY column.

select a.division_id, a.completion_id, a.num_of_stages, b.num_of_stages as numb,     abs(a.num_of_stages - b.num_of_stages) as diff from odm_dba.odm_comp_summary a, (select    division_id, completion_id, count(*) num_of_stages from odm_dba.odm_comp_stage group by     division_id, completion_id) b where a.division_id = b.division_id and a.completion_id =     b.completion_id and a.num_of_stages <> b.num_of_stages;

I executed this code in toad. It was working fine. No I am using the below code to retrieve the QUERY column and then execute it.

<?php 
session_start();
ob_start();
require_once 'dbconnect.php';

$qry = "SELECT query FROM vdc_dba.queries";
$result = oci_parse($conn, $qry);
oci_execute($result);

$row = oci_fetch_array($result);
echo $row['QUERY'];
$new_result=oci_parse($conn,$row['QUERY']);
oci_execute($new_result);
$row1 = oci_fetch_array($new_result);
echo $row1['DIVISION_ID'];

?>

This is the output of the above query

" The actual query and then Warning: oci_execute(): ORA-00911: invalid character in C:\xampp\htdocs\query.php on line 13

Warning: oci_fetch_array(): ORA-24374: define not done before fetch or execute and fetch in C:\xampp\htdocs\query.php on line 14"

I am not sure how to use the result of a query as a query again. I am new to PHP, any help would be appreciated. Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向