The MessageLanguage Method

Previous Next

See Also

You can generate all kinds of messages, by calling the MessageLanguage method of the internal RulesEngine component.

This method has almost the same behavior as the MessageLanguage() application method. The main addition is that methods of a component can be called from an INVOKE statement.

If the message has been translated in the System Local Messages window, and you use the language, you get the translated message.

To generate a system message, execute the following statement:

SELECT RulesEngine.MessageLanguage('<category>', '<name>', '<type>' [,'<par1>', '<par2>', ...])

Parameters

The MessageLanguage method requires the following parameters:

category:

Mandatory parameter. This is the category that the message belongs to, specified in the System Messages window.

name:

Mandatory parameter. This is the logical name of the message that has been specified in the System Messages window.

type:

Mandatory parameter. The value can be:

· INFORMATION: Shows an information message. The transaction continues.

 

· WARNING: Shows a warning message. The transaction continues.

 

· ERROR: Shows an error message and causes a violation. The transaction stops.

 

· QUESTION: Shows a question with a Yes and a No button. When clicking Yes, the value 1 is returned. When clicking No, the value 2 is returned. You can define additional behavior depending on the value returned.

IMPORTANT:

The QUESTION type can only be used within a Client-Server application. When used in a web application, Batch Runner, or the Remote Rules Service API, you get an error message.

par1 [,par2]:

Optional parameter(s). This is a string that substitutes a parameter in the message. The method call can have any number of parameters, thus has a variable number of input parameters.

Example 1:

INVOKE RulesEngine.MessageLanguage

WITH

SELECT 'Frequent End User Msg', 'COMMIT', 'INFORMATION', '4'

This results in an information message: '4 record(s) committed'.

Example 2:

Suppose that when a contract is signed, the user must decide whether the contract must be frozen or not. You can write a transitional constraint to achieve this:

UPDATE    contract

SET    frozen= 'Y'

WHERE    1=

       (INVOKE RulesEngine.MessageLanguage

        WITH

        SELECT     'MyCategory'

           ,'MSG_QUESTION_FREEZE_CONTRACT'

           ,'QUESTION'

           , ID

        WHERE    OLD(signed) = 'N'

        AND    signed = 'Y'

       )

NOTE:

If the message type is set to ERROR, and the message is called from the SQL Command dialog, you always get an additional, general error message. This is expected behavior.

Failed to execute the command.

Failed to open select cursor for statement

<...>

Related Topics

Where To Use the MessageLanguage Method