This procedure allows an application to execute a SQL statement on a remote server and retrieve any result sets generated
by that statement. The SQL statement is sent verbatim to the remote server and therefore SQL Anywhere does not need to able
to parse the statement.
To use this system procedure, you must define the remote server with the CREATE SERVER statement.
Unlike the FORWARD TO statement, sp_forward_to_remote_server can be used within procedures. However, this stored procedure
cannot be used within the FROM clause of a SELECT statement since the schema of the remote result sets is arbitrary. You can
fetch remote result sets by declaring a cursor on a stored procedure that is called in the sp_forward_to_remote_server procedure.
Note
If the SQL statement returns multiple result sets, the sp_forward_to_remote_server stored procedure returns each remote result
set in turn.
There are no local side effects to executing this stored procedure; however, since the SQL statement that is executed on the
remote server is arbitrary, there may be side effects on the remote server.
The following example uses the sp_forward_to_remote_server stored procedure to determine the number of non-system tables in
a remote SQL Anywhere 16 database called RemoteSA.
CALL sp_forward_to_remote_server( 'RemoteSA',
'SELECT COUNT(*) FROM sys.systable WHERE CREATOR NOT IN (0,3,6)' );
The following example uses the sp_forward_to_remote_server stored procedure to read the columns from an Excel spreadsheet
named newSalesData.
call sp_forward_to_remote_server( 'RemoteExcel', 'SELECT * FROM newSalesData' );