Ver Mensaje Individual
  #3 (permalink)  
Antiguo 09/07/2012, 10:17
socialk
 
Fecha de Ingreso: octubre-2011
Ubicación: Chile
Mensajes: 9
Antigüedad: 12 años, 7 meses
Puntos: 0
Respuesta: problema SP, con un IN dentro de un cursor

Muchas gracias por responder tan pronto, justamente como dices, es lo que sucede, pero el requerimiento era así...

lo resolví de la siguiente manera,

hice un select con concat dentro del procedimiento, lo que me devuelve lo inserté a una tabla temporal, y cree un cursor en base a esa tabla temporal, tuve que agregar un paso más.

Código MySQL:
Ver original
  1. DECLARE cTag CURSOR FOR SELECT id FROM tbTransactionsTemp;
  2. DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;

y dentro del procedimiento...

Código MySQL:
Ver original
  1. DROP TEMPORARY TABLE IF EXISTS tbTransactionsTemp;
  2. SET @qt = CONCAT("CREATE TEMPORARY TABLE tbTransactionsTemp SELECT max(pkIntradayTransaction) FROM tbIntradayTransactions WHERE fkInstrument IN (SELECT pkInstrument FROM tbInstruments WHERE fkInstrument IN (", idInstrument ,")) AND datetimeLastPrice <= DATE_SUB(NOW(),INTERVAL 15 MINUTE) GROUP BY fkInstrument;");
  3.  
  4. PREPARE stmt FROM @qt;
  5. EXECUTE stmt;
  6. DEALLOCATE PREPARE stmt;
  7.  
  8. OPEN cTag;
  9.  
  10.     REPEAT
  11.         FETCH cTag INTO _pkIntradayTransaction;
  12.         IF NOT done THEN
  13.            //lo que necesitaba hacer
  14.         END IF;
  15.         UNTIL done
  16.     END REPEAT;
  17.     CLOSE cTag;

no sé si sea la mejor forma para lograrlo, pero por ahora hace lo que necesitaba.

una vez más... muchas gracias...