Select returns: Query OK, -1 rows affected

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
waheed
Junior Boarder
Junior Boarder
Posts: 26
Joined: 18.11.2005, 21:41

Select returns: Query OK, -1 rows affected

Post by waheed »

I have a select statement with a function call in MySQL 5.0.
It doesn't return any data with Query OK, -1 rows affected as a result, but I remove the function it returns the data I asked for. The result without using the function get 65000 records.

What could be the problem?
The function is listed in Integer field treated as Largeint

I tried doing a search on google but -1 is seen as 1!! and I don't find an answer.

This is not related to the zeos bug, but it uses the same function.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

From the mysql C API reference :
25.2.3.1. mysql_affected_rows()
my_ulonglong mysql_affected_rows(MYSQL *mysql)

Description

Returns the number of rows changed by the last UPDATE, deleted by the last DELETE or inserted by the last INSERT statement. May be called immediately after mysql_query() for UPDATE, DELETE, or INSERT statements. For SELECT statements, mysql_affected_rows() works like mysql_num_rows().

Return Values

An integer greater than zero indicates the number of rows affected or retrieved. Zero indicates that no records were updated for an UPDATE statement, no rows matched the WHERE clause in the query or that no query has yet been executed. -1 indicates that the query returned an error or that, for a SELECT query, mysql_affected_rows() was called prior to calling mysql_store_result(). Because mysql_affected_rows() returns an unsigned value, you can check for -1 by comparing the return value to (my_ulonglong)-1 (or to (my_ulonglong)~0, which is equivalent).
So, my best guess is : function error on one of your data rows. We don't have your data, so we can't find that out ourselves.
I suppose you already tried your query with a where clause that limits to one row?

It worked (at least : didn't fail) when I debugged Bug 16.

Success!!
Mark
waheed
Junior Boarder
Junior Boarder
Posts: 26
Joined: 18.11.2005, 21:41

Post by waheed »

You're right. Thanks again. Data was wrong.
Post Reply