Do you know how to call a MySQL stored procedure from batch file?
Thank you ;)
I change my mind and I decided to create batch calling sql file :
My batch
@ECHO OFF
cls
setlocal enableDelayedExpansion
SET MYSQL_EXE="C:Program FilesMySQLMySQL Server 5.6inmysql.exe"
SET DB_USER=****
SET DB_PWD=***
SET DB=***
set DD=%DATE:~0,2%
set MM=%DATE:~3,2%
set YY=%DATE:~8,2%
set YYYY=%DATE:~6,4%
set HH=%TIME:~0,2%
set MN=%TIME:~3,2%
SET "CURRDAT=%YYYY%-%MM%-%DD% %HH%:%MN%:00"
FOR /F %%f in ('DIR "K:CRNTRAVAILPROGRAMMATIONPrev ConsocsvPCE_PRECO20140522*.*" /B') DO (
REM call stored procedure From MYSQL server
del "C:Users7642FHLocalfileTest.sql"
ECHO USE pce; > C:Users7642FHLocalfileTest.sql
ECHO LOAD DATA LOCAL INFILE '!FILEPATHSQL!' >> C:Users7642FHLocalfileTest.sql
ECHO !TBL! >> C:Users7642FHLocalfileTest.sql
ECHO FIELDS TERMINATED BY ";" >> C:Users7642FHLocalfileTest.sql
ECHO LINES TERMINATED BY '
' >> C:Users7642FHLocalfileTest.sql
ECHO IGNORE 1 ROWS >> C:Users7642FHLocalfileTest.sql
SET "VAR=(@var1,@var2,@var3)"
ECHO !VAR! >> C:Users7642FHLocalfileTest.sql
ECHO !SQL! >> C:Users7642FHLocalfileTest.sql
CALL %MYSQL_EXE% --user=%DB_USER% --password=%DB_PWD% --database=%DB% < C:Users7642FHLocalfileTest.sql
)
And my sql
USE pce;
LOAD DATA LOCAL INFILE 'C:/Users/7642FH/Local/RawFile/20141018/PREV_PCE_20141018_20141013_092802.csv'
INTO TABLE tbl_pceraw
FIELDS TERMINATED BY ";"
LINES TERMINATED BY '
'
IGNORE 1 ROWS
(@var1, @var2, @var3)
SET ElementId=@var1, TargetDateTime=!!, CurrValue = REPLACE(@var3, ',', '.'), DataType='Actual', `TargetDate``TargetDateFolder``ComputeDateTime``ForcastValue``TargetFolder`;
I hope that it could be useful for someone !
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…