php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1970 OCIColumnName can only be called BEFORE OCIFetchInto
Submitted: 1999-08-05 10:41 UTC Modified: 2006-07-17 08:06 UTC
From: jjl at mars dot tuwien dot ac dot at Assigned:
Status: Closed Package: OCI8 related
PHP Version: 3.0.12 OS: Linux RH 5.2 i386
Private report: No CVE-ID: None
 [1999-08-05 10:41 UTC] jjl at mars dot tuwien dot ac dot at
If you try to do
$colname = OCIColumnName($stmt, $i)
AFTER you have called OCIFetchInto(...) then $colname will be empty.
If you call it BEFORE OciFetchInto everything works as it should.
This behaviour gave me a headache for a few hours...

So the correct way to do it should be:
OCIPLogon(...)
$stmt = OCIParse($query)
OCIExecute($stmt...)
for ($i=1; $i <= number of columns; $i++) {
	$colname[$i] = OCIColumnName($stmt, $i);
}
while (OCIFetchInto(....)) {
  // do smthng with the actual data
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-08-05 16:01 UTC] mbritton at cvs dot php dot net
This is true only if you fetch all the way to the end of the result set using repeated OCIFetchInto's before calling the OCIColumnName.  It's like the cursor attributes go away once the last row is fetched.  This may be a product of Oracle's OCI routines.
 [1999-08-06 01:55 UTC] thies at cvs dot php dot net
this is an unexpected side-effect of my implementation of ref-cursors. please consider a cursor more-or-less "closed" after you read all the rows. if you really need it please open a change-request.
 [2016-07-08 21:13 UTC] rasmus@php.net
Automatic comment from SVN on behalf of rasmus
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=339591
Log: Engine karma for Keyur for PR #1970 and others
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Jun 19 01:01:28 2019 UTC