INF: Sending Transact-SQL Queries to Q+E Using COMMAND()

ID Number: Q72033

1.10 1.11 4.20

OS/2

Summary:

Pioneer Software's Q+E version 2.5 or later supports a function called

COMMAND() that allows you to construct large queries by sending them

in pieces through a DDE channel to a command buffer. This function

exists because some macro languages, such as the Microsoft Excel macro

language, limit the size of character variables.

More Information:

The COMMAND() function requires the following arguments:

COMMAND(op_num, exec_string)

The op_num parameter specifies how Q+E receives the commands. If

op_num is 1, a buffer is initialized and the exec_string is saved to

it. If op_num is 2, the exec_string is concatenated to the buffer. If

op_num is 3, the exec_string is concatenated to the buffer and the

complete command buffer is executed.

The exec_string parameter is a string of execute commands. It must

follow the same format that is used with the DDE EXECUTE function.

The following example illustrates how the COMMAND() function can be

used to create and execute a Transact-SQL statement from Excel.

chan=INITIATE("qe","system")

=EXECUTE(chan,"[command(1,'[open(''select * ')]")

=EXECUTE(chan,"[command(2,'from sysobjects ')]')]")

=EXECUTE(chan,"[command(3,'order by id '')]')]")

=RETURN()

In this example, the query generated is small enough that it could be

sent without using the COMMAND() function.

However, this method can be used to dynamically create and execute

large queries that normally would exceed the limit of one EXECUTE

statement.