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_Connect_Replace @p_sequence, @p_job_name, @p_task_name, @p_job_id, @p_task_id
, 'REPLACE', 'CONN_TEST2', '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 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(77);EXEC Ws_Connect_Replace 0,'Change Conn','Conn',0,0,'REPLACE','CONN_TEST2','CONN_TEST1',@RET OUTPUT,@MSG OUTPUT,@RES OUTPUT; SELECT @RET,@MSG"
The following out is typical:
- -----------------------------------------------------------------------------
S Connection information for CONN_TEST1 replaced from CONN_TEST2
(1 rows affected)
3. SQL Server example of a call from QAD SQL Admin
{Call Ws_Connect_Replace(0,'Change Conn','Conn',0,0,'REPLACE','CONN_TEST2','CONN_TEST1',?,?,?)};