Skip navigation links

MySQL Forums :: Cursors :: Subselect and walking throught result with cursor


Advanced Search

Subselect and walking throught result with cursor
Posted by: Jan Jůna ()
Date: September 13, 2010 01:17PM

Hi,
at first, sorry for my bad english, if you will not understand, tell me and i will try to describe it in another way.

I have a little problem, when I have select with subselect in procedure and i'm trying to walk throught result with cursor and fetch.

Basically, I have a table "robots" where I store data:
ID (Auto increment value for robot identification)
IDaukce ( = ID of auction which is robot related to)
uziv ( = user which is robot related to)
counter (int value, tells me what row for what IDauction will be selected)

And now, I need select for every IDaukce (ID of auction) robot with lowest counter.

For example:
ID:1 | IDaukce:1 | Uziv: John1 | Counter: 1
ID:2 | IDaukce:1 | Uziv: Chuck | Counter: 0
ID:3 | IDaukce:2 | Uziv: Chuck | Counter: 0

So it will select IDaukce 1 and IDaukce 2 and for every IDaukce it will choose row with lowest counter, so the result will be:

ID:2 | IDaukce:1 | Uziv: Chuck | Counter: 0
ID:3 | IDaukce:2 | Uziv: Chuck | Counter: 0


So I maked some select and when I try this in phpMyAdmin, it works fine - it will get some results (more then one).

But when Im trying to walk throught result with CURSOR, it gives me only one row - and it starts doing this when I added subselect.

Can somebody help me?
I think,I have two options how to make it work:
1) make select for getting robots without subselect.
2) figure out, why CURSOR doesn't work with more then 1 row from result.


I pasted here my actual version of PROROCEDURE, which is doing this work.
http://pastebin.com/tPQKELew
(there are more conditions, but in phpMyAdmin it works fine so I dont think, that probleme is in WHERE clause)

I will be glad for every usefull tip or help.
(and again - sorry for english :D )

Options: ReplyQuote


Subject Views Written By Posted
Subselect and walking throught result with cursor 3104 Jan Jůna 09/13/2010 01:17PM
Re: Subselect and walking throught result with cursor 1090 Devart Team 09/14/2010 01:13AM
Re: Subselect and walking throught result with cursor 1074 Jan Jůna 09/15/2010 04:42AM
Re: Subselect and walking throught result with cursor 1257 Devart Team 09/16/2010 01:27AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.