Ver Mensaje Individual
  #6 (permalink)  
Antiguo 18/05/2014, 12:37
dacroma
 
Fecha de Ingreso: mayo-2013
Ubicación: bogota
Mensajes: 157
Antigüedad: 11 años
Puntos: 2
Respuesta: guardar un dato de una tabla en una variable

El error dice:
Código MySQL:
Ver original
  1. you have an error in your SQL sintax; check de manual that corresponds to your
  2. mysql server version for de rigth sintax to use near '=0;
  3. num=(select total from factura where cod_factura=4); select num; end;' at line 3

y cuando lo hago de forma diferente:

Código MySQL:
Ver original
  1. delimiter //
  2. create procedure funcionX( param int)
  3. param=0;
  4. param=(select total from cliente where id_cliente=4);
  5.  
  6. if param>3000 then
  7. select "el valor es apto";
  8. select "el valor no es apto";
  9. end;
  10. //
  11. delimiter ;
  12. you have an error in your SQL sintax; check de manual that corresponds to your
  13. mysql server version for de rigth sintax to use near 'param=0;
  14. param=(select total from factura where cod_factura=4); select param; end;' at line 3

ò

Código MySQL:
Ver original
  1. delimiter //
  2. create procedure funcionX( param int)
  3. set @var=0;
  4. @var=(select total from cliente where id_cliente=param);
  5.  
  6. if @var > 3000 then
  7. select "el valor es apto";
  8. select "el valor no es apto";
  9. //
  10.  
  11. you have an error in your SQL sintax; check de manual that corresponds to your
  12. mysql server version for de rigth sintax to use near '@var=0;
  13. @var=(select total from factura where cod_factura=param); select param; end;' at line 3
  14. delimiter ;