Ver Mensaje Individual
  #3 (permalink)  
Antiguo 12/11/2011, 17:32
levital
 
Fecha de Ingreso: noviembre-2009
Mensajes: 5
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: generar valores alatorios

gracias por responder
pero mi pregunta es simple como ago para k me genere aleatoriamente estas dos letras A y D
es algo mas o menos para esto


CREATE PROCEDURE venta()
BEGIN
DECLARE i INT DEFAULT 1;
declare tipoventa int;
declare letraaleatorio char(1);
WHILE (i<=5) DO
set tipoventa=1+ROUND(RAND()*(2-1));/*GENERA NUMERO ALEATORIO ENTRE 1 Y 2*/
set fecha =str_to_date(concat(floor(1 + rand() * (12-1)),'-',floor(1 + rand() * (28 -1)),'-','2011'),'%m-%d-%Y');
set letraaleatorio=K FUNCION O K PONGO PARA K ME GENERE ENTRE A Y D <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
IF tipoventa=1 then/*1 ES TIPO DE VENTA CREDITO*/
INSERT INTO venta(Tip_Venta,estado_venta,cod_Usuario,monto_ven ta,interes,descuento,fecha_venta,turno_venta,hora_ venta)
VALUES(tipoventa,'0012009',letraaleatorio,10.000,0 .200,0.000,fecha,2,'11:56 AM');
ELSE
INSERT INTO venta(Tip_Venta,estado_venta,cod_Usuario,monto_ven ta,interes,descuento,fecha_venta,turno_venta,hora_ venta)
VALUES(tipoventa,'0012009',letraaleatorio,10.000,0 .000,0.000,fecha,2,'11:56 AM');
END IF;
SET i=i+1;
END WHILE;
END

Última edición por levital; 12/11/2011 a las 17:59