SQL Server Examples:
1. SQL Server example of a call from a Stored Procedure:
Add the following to the declaration section of the stored procedure:
DECLARE @v_result integer
DECLARE @v_return_code varchar(1)
DECLARE @v_return_msg varchar(256)
DECLARE @v_run_date datetime
Then add the call to the procedure:
SET @v_run_date = GETDATE() + 1
EXEC Ws_Job_Schedule @p_sequence, @p_job_name, @p_task_name, @p_job_id, @p_task_id
, 'Daily Run', @v_run_date, @v_return_code OUTPUT, @v_return_msg OUTPUT, @v_result OUTPUT
Perhaps add a check of the result:
IF @v_result <> 1
BEGIN
SET @p_status =@v_result
SET @p_return_msg = 'Failed to schedule the Job. Return Code was ' +@v_return_code
SET @p_return_msg = @p_return_msg + '. ' + RTRIM(@v_return_msg)
END
2. SQL Server example of a call from the command line using sqlcmd (all one line):
sqlcmd -S"SQL SERVER" -WslWarehouse -E -Q"DECLARE @RES integer;DECLARE @RET varchar(1);DECLARE @MSG varchar(65);EXEC Ws_Job_Schedule 1,'Sched Job','Sched',0,0,'Daily Run','2009-01-01 11:30:59',@RET OUTPUT,@MSG OUTPUT,@RES OUTPUT; SELECT @RES,@RET,@MSG"
The following out is typical:
----------- - -----------------------------------------------------------------
1 S Job Daily Run rescheduled to Jan 1 2009 11:30AM
(1 rows affected)
3. SQL Server example of a call from QAD SQL Admin
{Call Ws_Job_Schedule(1,'Sched Job','Sched',0,0,'Daily Run','2009-01-01 11:30:59',?,?,?)};