当前位置: 动力学知识库 > 问答 > 编程问答 >

How to passe parameters from batch(.bat) to trigger in a mySql file?

问题描述:

I have to files :batchFile.bat and sqlFile.sql

The batchFile.bat contains this code :

@echo OFF

set host=localhost

set user=root

set pass=123

set dbname=db_prod

set dbname_hist=db_prod_hist

mysql -u %user% -h %host% -D %dbname% -p%pass% -v < sqlFile.sql

The sqlFile.sql contains this code :

delimiter //

DROP TRIGGER IF EXISTS tri_tableA1//

CREATE TRIGGER tri_tableA1

AFTER INSERT ON tableA1

FOR EACH ROW

BEGIN

INSERT INTO *{dbname_hist}*.tableA1 (id, prixAchatUnitaireHT, montantAchat, duree)

select NEW.id, NEW.prixAchatUnitaireHT, NEW.montantAchat, NEW.duree;

END//

delimiter ;

My question is: how can i passe the {dbname_hist} parameter from the .bat file to .sql file ?!

分享给朋友:
您可能感兴趣的文章:
随机阅读: