473,780 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New to OCI - double results?

Hello there

I'm trying to work with the example for OCI... and the $row returns 2
values, the same twice, but my query only have one... code below.

Can anyone explain?

BR
S
$query = 'select distinct(someth ing) from a.b';

$stid = oci_parse($conn X, $query);
if (!$stid) {
$e = oci_error($conn X);
print htmlentities($e['message']);
exit;
}

$r = oci_execute($st id, OCI_DEFAULT);
if (!$r) {
$e = oci_error($stid );
echo htmlentities($e['message']);
exit;
}

print '<table border="1">';
while ($row = oci_fetch_array ($stid, OCI_RETURN_NULL S))
{

print '<tr>';
print "<td>".(count($ row))."</td>";
foreach ($row as $item) {
print '<td>'.$item.' </td>';
}
print '</tr>';
}
print '</table>';

oci_close($conn X);

Jan 26 '07 #1
4 2570
Rik
Sonnich <so************ @elektrobit.com wrote:
Hello there

I'm trying to work with the example for OCI... and the $row returns 2
values, the same twice, but my query only have one... code below.

Can anyone explain?

while ($row = oci_fetch_array ($stid, OCI_RETURN_NULL S))
http://www.php.net/oci_fetch_array

"returns an array with both associative and numeric indices."

So, tell it which one to use either associative:
oci_fetch_assoc ($stid, OCI_RETURN_NULL S)

Or numerical:
oci_fetch_row($ stid, OCI_RETURN_NULL S)

If you don't need the indexes, the last one seems to be the fastest.
--
Rik Wasmus
Jan 26 '07 #2
On 26 Jan 2007 08:52:57 -0800, "Sonnich" <so************ @elektrobit.com wrote:
>I'm trying to work with the example for OCI... and the $row returns 2
values, the same twice, but my query only have one... code below.
[snip]
while ($row = oci_fetch_array ($stid, OCI_RETURN_NULL S))
oci_fetch_array returns the values twice - once with numeric indexes, and
again with the names of the columns as keys.

http://uk.php.net/oci_fetch_array

The default mode is OCI_BOTH - you don't want that.

--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Jan 26 '07 #3
I got this to work using
while ($row = oci_fetch_row ($stid))

But not I get another problem, see comment here:

$stid = oci_parse($conn X, $sql2);
if (!$stid)
{
$e = oci_error($conn X);
echo htmlentities($e['message'])."<br>";
}
else
{
$r = oci_execute($st id, OCI_DEFAULT);
// instead of going ahead, it still gives the error here. How do I
stop that.
// the error is correctly catched here anyway, but I'd like to have it
only. Meaning no default response when the query fails.
if(!$r)
{
$e = oci_error($stid );
if(strpos($e['message'],"CONNECT BY loop")!==false)
echo "<font class=\"error\" >Loop error with item:
$Item[$i]</font><p>";
else
echo htmlentities($e['message'])."<br>";
}
else
{

On Jan 26, 6:52 pm, "Sonnich" <sonnich.jen... @elektrobit.com wrote:
Hello there

I'm trying to work with the example for OCI... and the $row returns 2
values, the same twice, but my query only have one... code below.

Can anyone explain?

BR
S
Jan 29 '07 #4
On Mon, 29 Jan 2007 09:03:12 -0800, Sonnich wrote:
I got this to work using
while ($row = oci_fetch_row ($stid))

But not I get another problem, see comment here:

$stid = oci_parse($conn X, $sql2);
if (!$stid)
{
$e = oci_error($conn X);
echo htmlentities($e['message'])."<br>";
}
else
{
$r = oci_execute($st id, OCI_DEFAULT);
// instead of going ahead, it still gives the error here. How do I
stop that.
By using the standard PHP error suppression operator:
$r = @oci_execute($s tid, OCI_DEFAULT);

I would advise against doing that, but it is a possibility. OCI does
so called deferred parse, which means that parse and execute steps are
bundled into a single step. When your statement fails, it's usually a
serious situation.

--
http://www.mladen-gogala.com
Feb 23 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

32
22643
by: f | last post by:
I have this double sum, a, b, c; sum = a + b + c; printf("%.20f = %.20f, %.20f, %.20f", sum, a, b, c); I found that the debug version and release version of the same code give me different result. I am using VC++ 6.0. In debug version, the print out is:
31
6651
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one variable becomes 364 and the other one becomes 365. Does anyone have any insight to what the problem is? Thanks in advance. Bjørn
6
7276
by: James Thurley | last post by:
According to the docs, floats are 32 bit and doubles are 64 bit. So using floats should be faster than using doubles on a 32 bit processor, and my tests confirm this. However, most of the Math methods deal with doubles and I'm having problems with casting them back to floats. For example: (double)0.1f = 0.10000000149011612 I don't need the accuracy of doubles, but the speed of floats would be benificial, but it seems I'm either...
10
18774
by: Bryan Parkoff | last post by:
The guideline says to use %f in printf() function using the keyword float and double. For example float a = 1.2345; double b = 5.166666667; printf("%.2f\n %f\n", a, b);
4
13777
by: dc15 | last post by:
For an intro to VB project I have to write a program which takes an amount of Miles, Yards, and Inches.....and converts it to metric (KM, M, and CM) when all values are entered to the input text boxes it works fine, but if there is a number missing I get the following error: An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll Additional information: Cast from string "" to type 'Double' is...
6
5717
by: R.Biloti | last post by:
Hi folks I wrote the naive program to show up the unit roundoff (machine precision) for single and double precision: #include <stdio.h> int main (void) { double x;
29
2969
by: Virtual_X | last post by:
As in IEEE754 double consist of sign bit 11 bits for exponent 52 bits for fraction i write this code to print double parts as it explained in ieee754 i want to know if the code contain any bug , i am still c++ beginner
206
13312
by: md | last post by:
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) It then updates the value with numberOfPrecisions after the decimal
0
2561
by: Charles Coldwell | last post by:
James Kanze <james.kanze@gmail.comwrites: True, with some additional considerations. The commonly used IEEE 754 floating point formats are single precision: 32 bits including 1 sign bit, 23 significand bits (with an implicit leading 1, for 24 total), and 8 exponent bits double precision: 64 bits including 1 sign bit, 52 significand bits
1
1664
by: Sells, Fred | last post by:
I'm using python 2.4 under linux (centos 5.1). I need to pass an array of doubles to a c function but am getting an error, shown near the bottom of this post. ---------------------------------------------------- my swig interface file looks like this * File: rug520.i */ %module rug520 %include "typemaps.i"
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10139
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.