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_Load_Change @p_sequence, @p_job_name, @p_task_name, @p_job_id, @p_task_id
, 'CONNECTION', 'load_customer', 'CONN_TEST1'
, @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 replace load table connection details. 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(80);EXEC Ws_Load_Change 1,'Check Job','Stat',0,0,'CONNECTION','load_customer','CONN_TEST1',@RET OUTPUT,@MSG OUTPUT,@RES OUTPUT; SELECT @RES,@RET,@MSG"
The following out is typical:
----------- - --------------------------------------------------------------------------------
NULL S CONNECTION changed from CONN_TEST1 to CONN_TEST1 for load table load_customer
(1 rows affected)
3. SQL Server example of a call from QAD SQL Admin
{Call Ws_Load_Change(1,'Check Job','Stat',0,0,'CONNECTION','load_customer','CONN_TEST1',?,?,?)};