Language calls

Open Server provides functionality for processing language events in a flexible manner. A SRV_LANGUAGE event is triggered when a client application sends information through ct_command with the type argument set to CS_LANG_CMD. Whereas an RPC stream is composed of discrete elements—a name and parameters—language information arrives in a stream of undifferentiated characters. A SRV_LANGUAGE event handler must include code to parse the stream into its meaningful components. A SQL query is an example of a language stream.

This functionality is useful for applications that want to accept natural language input. For example, consider a clothing store application that lets users query a SQL database in English. A sales clerk could type in the question “How many shirts in blue?” The front-end client application could send this natural language query to an Open Server gateway application through a call to ct_command. The SRV_LANGUAGE handler parses this text, constructs this Transact-SQL query and sends it to a remote database:

select quantity from inventory_tab where color = “blue” and type = “shirt”

A SRV_LANGUAGE event handler must process language data in steps:

  1. Call srv_langlen to retrieve the length of the language request buffer.

  2. Allocate a local application buffer as large as the length returned by srv_langlen, plus 1 for the null-termination byte.

  3. Call srv_langcpy to copy all or part of the request data into the local buffer.

  4. Process the contents of the local buffer.