Hello there,

I have a problem, I wrote a stored procedure to retrieve some data
from various tables and then put it in a temporary table to use it
later, most of the procedure works just fine but there's something
that doesn't and I can not guess what the error can be.

Okay so, here's the thing:

I declared a cursor that joins some tables:

DECLARE cur_libros CURSOR FOR SELECT ISBN, CONCAT(Nombre, " ",
Apellido), Nombre_Editorial, YEAR(Fecha_publicacion), Precio, Titulo
FROM Autor JOIN Libro_Autor USING(Id_autor) JOIN Libro USING(ISBN)
JOIN Libro_Editorial USING(ISBN) JOIN Editorial USING(Id_Editorial)
WHERE Nombre = nom AND Apellido = ap;

[ When I execute the SELECT sentence for this cursor it works just
fine, the records are retrieved as I want them, so I know it isn't a
problem with the table or the JOIN. ]

Later in the procedure I fetch the cursor data into some local
variables I have declared:

FETCH cur_libros INTO myisbn, nombre_autor, editorial,
ano_publicacion, precio, titulo;

most of the variables are filled with data after the fetch but precio
and titulo are not. I searched the Internet trying to find a solution
and ended up in a bug report for mySQL:

Bug #8692
Cursor fetches null values into variables

Suggested fix:
Variables should contain valid data.  Fetch should fetch valid data
into the variables.

So I added some SET sentences to initialize the variables before
fetching data into them:

SET titulo = "";
SET precio = 0;

Still nothing... in fact the variables are never updated is not that
the fetch set them to null is more like the fetch just don't touch
them, they are never modified, no matter what I initialize them to the
variables never change.

I tried to check the data types to make sure they are the same that
the ones in the table and the data types are Ok they match, so... What
is the problem here?

What are the more common causes for a variable not been updated in a
FETCH? If I would have a little idea about that I could figure out
what the problem is, so I would really appreciate your help.

Thanks in advance.

--
Sergio

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to