raymurphy
asked on
Trying to pass down 24 parameters to Windows batch file (chokes after 9)
I'm using some functionality in SQL Server to build up a call to a Windows batch file, with that call to the batch file intended to pass down a total of 24 parameters.
So the functionality in SQL looks like this :
SET @COMMAND = 'CALL batchtest.bat ' + @PROGRAM_CALLED + ' ' + @JOB_QUEUE + ' ' + @FROMDATE + ' ' + @TODATE + ' ' + @OBJ1 + ' ' + @OBJ2 + ' ' + @OBJ3 + ' ' + @OBJ4 + ' ' + @OBJ5 + ' ' + @OBJ6 + ' ' + @OBJ7 + ' ' + @OBJ8 + ' ' + @OBJ9 + ' ' + @OBJ10 + ' ' + @OBJ11 + ' ' + @OBJ12 + ' ' + @OBJ13 + ' ' + @OBJ14 + ' ' + @OBJ15 + ' ' + @OBJ16 + ' ' + @OBJ17 + ' ' + @OBJ18 + ' ' + @OBJ19 + ' ' + @OBJ20 + ' '
This is how SQL Server constructs the call to the batch file
CALL batchtest.bat TESTPROG JOBQ 20130801 20130831 '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ''
In the batch file, I eventually use rmtcmd to build up a sbmjob command to an IBM AS400 system :
rmtcmd //as400machine "sbmjob cmd(call %1 parm('%3' '%4' %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 %17 %18 %19 %20 %21 %22 %23 %24)) ...etc...
The problem I'm having is that the Windows batch file does not seem to handle more than 9 parameters.
If I use echo in the batch file (i.e. echo %%1 = (%1) etc ..) to log the imcoming parameters, I see the following :
%1 = (TESTPROG)
%2 = (JOBQ)
%3 = (20130801)
%4 = (20130831)
%5 = ('')
%6 = ('')
%7 = ('')
%8 = ('')
%9 = ('')
%10 = (TESTPROG0)
%11 = (TESTPROG1)
%12 = (TESTPROG2)
%13 = (TESTPROG3)
%14 = (TESTPROG4)
%15 = (TESTPROG5)
%16 = (TESTPROG6)
%17 = (TESTPROG7)
%18 = (TESTPROG8)
%19 = (TESTPROG9)
%20 = (JOBQ0)
%21 = (JOBQ1)
%22 = (JOBQ2)
%23 = (JOBQ3)
%24 = (JOBQ4)
So the echo command shows that parameters %1-%9 are being picked up properly as expected in the batch file, but the next nine (%10 to %19) seem to have the value of %1 (TESTPROG) suffixed by 0, 1, 2, 3 etc, and the next five seem to have the value of %2 (JOBQ) suffixed by 0, 1, 2, 3 etc ...
Any ideas, how I can pick up ALL of the 24 incoming parameters in the Windows batch file so that they can be passed down to my rmtcmd command ?
Thanks
Ray
So the functionality in SQL looks like this :
SET @COMMAND = 'CALL batchtest.bat ' + @PROGRAM_CALLED + ' ' + @JOB_QUEUE + ' ' + @FROMDATE + ' ' + @TODATE + ' ' + @OBJ1 + ' ' + @OBJ2 + ' ' + @OBJ3 + ' ' + @OBJ4 + ' ' + @OBJ5 + ' ' + @OBJ6 + ' ' + @OBJ7 + ' ' + @OBJ8 + ' ' + @OBJ9 + ' ' + @OBJ10 + ' ' + @OBJ11 + ' ' + @OBJ12 + ' ' + @OBJ13 + ' ' + @OBJ14 + ' ' + @OBJ15 + ' ' + @OBJ16 + ' ' + @OBJ17 + ' ' + @OBJ18 + ' ' + @OBJ19 + ' ' + @OBJ20 + ' '
This is how SQL Server constructs the call to the batch file
CALL batchtest.bat TESTPROG JOBQ 20130801 20130831 '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' '' ''
In the batch file, I eventually use rmtcmd to build up a sbmjob command to an IBM AS400 system :
rmtcmd //as400machine "sbmjob cmd(call %1 parm('%3' '%4' %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16 %17 %18 %19 %20 %21 %22 %23 %24)) ...etc...
The problem I'm having is that the Windows batch file does not seem to handle more than 9 parameters.
If I use echo in the batch file (i.e. echo %%1 = (%1) etc ..) to log the imcoming parameters, I see the following :
%1 = (TESTPROG)
%2 = (JOBQ)
%3 = (20130801)
%4 = (20130831)
%5 = ('')
%6 = ('')
%7 = ('')
%8 = ('')
%9 = ('')
%10 = (TESTPROG0)
%11 = (TESTPROG1)
%12 = (TESTPROG2)
%13 = (TESTPROG3)
%14 = (TESTPROG4)
%15 = (TESTPROG5)
%16 = (TESTPROG6)
%17 = (TESTPROG7)
%18 = (TESTPROG8)
%19 = (TESTPROG9)
%20 = (JOBQ0)
%21 = (JOBQ1)
%22 = (JOBQ2)
%23 = (JOBQ3)
%24 = (JOBQ4)
So the echo command shows that parameters %1-%9 are being picked up properly as expected in the batch file, but the next nine (%10 to %19) seem to have the value of %1 (TESTPROG) suffixed by 0, 1, 2, 3 etc, and the next five seem to have the value of %2 (JOBQ) suffixed by 0, 1, 2, 3 etc ...
Any ideas, how I can pick up ALL of the 24 incoming parameters in the Windows batch file so that they can be passed down to my rmtcmd command ?
Thanks
Ray
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER