Callable Procedures > SQL Server Examples:
  
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)
Then add the call to the procedure:
EXEC Ws_Job_Clear_Logs @p_sequence, @p_job_name, @p_task_name, @p_job_id, @p_task_id
, 'Daily Run', 10, @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 clear Job logs. 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_Clear_Logs 0,'ClearJob','Clear',0,0,'Daily Run',10,@RET OUTPUT,@MSG OUTPUT,@RES OUTPUT; SELECT @RES,@RET,@MSG"
The following out is typical:
----------- - -----------------------------------------------------------------
1 S Job Daily Run had 140 logs removed.
(1 rows affected)
3. SQL Server example of a call from QAD SQL Admin
{Call Ws_Job_Clear_Logs(0,'ClearJob','Clear',0,0,'Daily Run',10,?,?,?)};