Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/11/2009, 09:13
FIDOKELELE
 
Fecha de Ingreso: enero-2009
Ubicación: talca
Mensajes: 23
Antigüedad: 15 años, 3 meses
Puntos: 0
Respuesta: funcion string_to_array de postgres en MYSQL?

no puede ser
algo debe existir entonces para realizar multiples insert con los valores contenidos en una variable tipo texto

como puedo hacer esto de postgres:

Cita:


CREATE OR REPLACE FUNCTION "public"."ingresar_traslado" (in_origen integer, in_destino integer, in_detalle text, in_rut text, in_estados text, in_estado boolean) RETURNS record AS
$body$
DECLARE
arreglo_detalle INTEGER [];
arreglo_estado INTEGER[];

ultimo_id INTEGER;
primer_id INTEGER;
valor_maximo INTEGER;
BEGIN
arreglo_detalle:= string_to_array(in_detalle,',');
arreglo_estado:= string_to_array(in_estados,',');

primer_id:=array_lower(arreglo_detalle,1);
ultimo_id:=array_upper(arreglo_detalle,1);

INSERT into activotraslado (origen,destino,rutfuncionario,estado,fechaenvio)V ALUES(in_origen,in_destino,in_rut,in_estado,now()) ;

valor_maximo= (SELECT max(idtraslado) FROM activotraslado);



WHILE primer_id<=ultimo_id LOOP

INSERT INTO trasladodetalle(iditemactivoserie, estadoenvio,idtraslado,recibido )VALUES(arreglo_detalle[primer_id],arreglo_estado[primer_id],valor_maximo,'f');

UPDATE itemactivoserie SET idlugar = in_destino WHERE iditemactivoserie = arreglo_detalle[primer_id];

primer_id:=primer_id+1;
END LOOP;
RETURN NULL;
END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
RETURNS NULL ON NULL INPUT
SECURITY INVOKER;


en MYSQL ?