
06/09/2007, 06:02
|
| | Fecha de Ingreso: noviembre-2005
Mensajes: 27
Antigüedad: 19 años, 2 meses Puntos: 0 | |
Create Table Mi problema es el siguiente:
Estoy creando un store procedure que tiene la funcion de recorrer una tabla, tomar el valor del campo llamado campo y por cada valor de ese campo crear una tabla. La manera que se me ocurrio fue: DECLARE vC_PRESTADOR varchar (13);
DECLARE done int default 0;
DECLARE PRE CURSOR FOR SELECT DISTINCT(campo) FROM tabla
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
OPEN PRE;
REPEAT
FETCH PRE
INTO vC_PRESTADOR;
IF NOT done THEN
SET @prest=vC_PRESTADOR;
CREATE TABLE IF NOT EXISTS @prest (n_beneficio NUMERIC(12,0),c_grado_paren NUMERIC(2,0));
END IF;
UNTIL done END REPEAT;
CLOSE PRE;
Pero en la linea CREATE TABLE me tira error de sintaxis y es por la variable
Si alguien conoce como hacer para que cree la tabla con el valor de una variable me diga
Saludos |