title: how to fetch data from stored procedure in oracle
body: <p>what i need to fetch data from stored procedures</p>
  
  <p>syntax in sql developer</p>
  
  <pre><code> select abc_web_demo.wwv_json_data.dashboards('abc','7','tt',1211) from dual
  </code></pre>
  
  <p>returns json string</p>
  
  <pre><code>  {"data":[{"logs":7,"to_abc":88,"to_cl":12,"to_me":0}]}
  </code></pre>
  
  <p>code</p>
  
  <pre><code> $tns = "
   (DESCRIPTION =
  (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST =ABC)(PORT = 1521))
  )
  (CONNECT_DATA = (SID = AAA))
   )
     ";
  
   try {
  $conn = new PDO("oci:dbname=".$tns, '**', '**');
  $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  echo 'Connected to database';
  
   } catch(PDOException $e) {
     echo 'ERROR: ' . $e-&gt;getMessage();
   }
      $sql = "CALL abc_web_demo.wwv_json_data.dashboards('ABC','79','Y',121221) ";
  
   $stmt = $conn-&gt;prepare($sql);
    $te=$stmt-&gt;execute();
  
  //$stmt = $connection-&gt;query("SELECT @NEW_ID");
  //$id = $stmt-&gt;fetchColumn();
  
  print_r($te);
  </code></pre>
  
  <p>Problem</p>
  
  <ul>
  <li><p>i have google &amp; found i need to pass in string in query
  like $stmt = $connection->query("SELECT @NEW_ID");</p></li>
  <li><p>here in my my case i need to  pass 4 parameters in procedure.</p></li>
  <li><p>i new in stored procedures i need help how to pass 4 arguments in procedure .</p></li>
  <li><p>how to access json response using fetch statement.</p></li>
  <li><p>i need json repsonse from fetch data.</p></li>
  <li><p>any help much appreciated</p></li>
  </ul>
  
  <p>Solution i tried </p>
  
  <pre><code> $output = $conn-&gt;query("select 'abc', '7' ")-&gt;fetch(PDO::FETCH_ASSOC);
   var_dump($output);
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>    SQLSTATE[HY000]: General error: 923 OCIStmtExecute: ORA-00923: FROM keyword not found where expected
  </code></pre>
  
  <p>when i tried test query it works</p>
  
  <pre><code>$stmt = $conn-&gt;prepare("select * from customers");
  $st=$stmt-&gt;execute();
  $result = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
  print_r($result);
  </code></pre>