MySQL Forums
Forum List  »  Stored Procedures

Re: INSERT DYNAMIC SQL DOESNT GET VALUES
Posted by: Luis Badillo
Date: June 05, 2018 12:01PM

Hi again!, I have the following dynamic sql, which in this moment is printing the column values but no the commas and a lot of space, i've been doing research but I havent found anything right now. Please you could take a look at the following code to improve my code and I can finish my job, which i have spent a lot of time on it. thanks a lot

/*Escribo la consulta donde inserto los datos de manera dinamica*/
SET @consulta_insertar_datos=CONCAT("SELECT 'INSERT IGNORE LOW_PRIORITY INTO
Call_Center_Infinit_",param_id_empresa,".",param_nombre_tabla_respaldar,"(",@columnas_tabla,") VALUES(',",TRIM(CONCAT_WS(',',@columnas_tabla)),"
FROM ",param_nombre_tabla_respaldar,"
INNER JOIN Empresas
ON ",param_nombre_tabla_respaldar,".id=Empresas.",param_nombre_columna,"
WHERE Empresas.id=",param_id_empresa,"
INTO OUTFILE \"/var/lib/mysql/respalda_datos_tbl_",param_nombre_tabla_respaldar,"_",DATE_FORMAT(CURRENT_TIMESTAMP(),'%d%b%Y_%H%i'),".sql\";");
/*Preparo la consulta para su ejecucion*/
PREPARE stmt_consulta_respalda_datos FROM @consulta_insertar_datos;
/*Ejecuto la consulta*/
EXECUTE stmt_consulta_respalda_datos;
/*Borro la sentencia preparada para futuras ejecuciones*/
DEALLOCATE PREPARE stmt_consulta_respalda_datos;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: INSERT DYNAMIC SQL DOESNT GET VALUES
552
June 05, 2018 12:01PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.