EXECUTE REMOTE PROCEDURE clause

Specifies the name of a predefined service that should be invoked by the Remote Procedure Statement and the values of the service parameters.

Syntax

EXECUTE REMOTE PROCEDURE " service"
Component

service

The name of an RPC service defined in the file c8-services.xml.

ON ERROR extension

Use the ON ERROR extension to handle remote procedure execution errors that may cause the Sybase CEP Engine to stop project execution.

The syntax for the EXECUTE REMOTE PROCEDURE clause with the ON ERROR extension is:
EXECUTE REMOTE PROCEDURE "service"  
   ON ERROR [error_insert_clause] CONTINUE
   SELECT…
Additional syntax related to the error_insert_clause:
error_insert_clause: INSERT INTO error_stream_name error_select_list
error_stream_name: Name of an output stream or local stream.
error_select_list: SELECT {error_expression} [,...]
error_expression: A CCL expression.
The error_expression can only contain:
  • References to columns in the stream specified in the stream_clause.
  • Operators, constant literals, and scalar functions.
  • CCL parameters in the project. These should be prefaced with $.
  • The ERROR_MESSAGE() built in.

The ON ERROR extension is optional. The error_insert_clause for the ON ERROR extension is also optional. If the ON ERROR extension is not provided and errors occur, the behavior of this clause is determined by the setting of the IgnoreErrors property in the c8-services.xml service configuration file. By default, this property is set to 'false', which means that if an error occurs, the query is aborted.

When the ON ERROR extension is provided without the error_insert_clause, errors found in the execution of this clause are ignored and CEP Engine continues to execute the project. Subsequent tuples arriving in any of the input streams of the from_clause continue to trigger execution of this clause. If these executions generate errors, they are also ignored by the CEP Engine.

When the ON ERROR extension is provided with the error_insert_clause, errors found in the execution of this clause are ignored and CEP Engine continues to execute the project. However a new tuple is also inserted into the errorstream (specified by error_stream_name). This tuple contains the fields selected in the error_select_list clause. The timestamp of this tuple is the same as the timestamp of the tuple in the from_clause that triggered the execution of this clause. These tuples are inserted in the errorstream in the same order as that of the original tuples in the from_clause that triggered the execution of this clause.

The ON ERROR extension cannot be used with both an EXECUTE STATEMENT DATABASE/EXECUTE REMOTE PROCEDURE clause and a REMOTE SUBQUERY/PROCEDURE clause in the same CCL statement. This causes errors. To avoid errors, the CCL statements must be broken into separate statements using an intermediate local stream.

Set the MaxRetries parameter in the service definitions for Database to determine how many times Sybase CEP Engine should retry statement execution after experiencing errors.

The parameter in the service file is written as follows:
<Param Name="MaxRetries">some_number</Param>
where some_number is an integer between 0 and 255.

If the MaxRetries parameter is set to a value greater than 0, say N, then every time there is an error in an Execute Statement or Subquery statement that subscribes to this service definition, the Sybase CEP Engine automatically retries the execution of that statement up to a maximum of N number of times. If the execution of the statement fails for all the N number of times, an error tuple is inserted into the errorstream.

The default value for MaxRetries is 0, that is, by default there is no retry.

Example

This query invokes procedure Temperature and passes values from the TempIn stream to the parameters City, ZipCode, and Time:

EXECUTE REMOTE PROCEDURE "Temperature"
SELECT 'CityName' AS City, 'ZipCode' AS ZipCode, 
   GetTimestamp() AS Time
FROM TempIn
WHERE TempIn.ID = City;
The following example demonstrates how errors are logged when the ON ERROR extension and insert_clause are provided with this clause.
EXECUTE STATEMENT DATABASE "StockTradeDB"
[[
    INSERT INTO TradeTable VALUE(?Symbol, ?Price, ?Volume, ?Ts)
]]
ON ERROR
INSERT INTO DBWriteErrorStream
SELECT Symbol, Ts, ERROR_MESSAGE()
CONTINUE
SELECT 
Symbol  as Symbol,
Price as Price,
Volume as Volume,
GETTIMESTAMP(InTrades) as Ts
FROM 
InTrades KEEP EVERY 1 minute;

where the schema for DBWriteErrorStream is (Symbol String, Ts TimeStamp, ErrMsg String).