Executes an SQL statement, supplied by standard input or the -Q option, on the server and prints the results to the standard output.
esp_query -p host:port/workspace/project -c user[:password] [OPTION...]
esp_query accepts an SQL query on the standard input and forwards it to a running instance of the Event Stream Processor. It then prints the results of the query on the standard output.
From a UNIX or Linux command line prompt, or the Query panel in the ESP Studio, the SQL query must be enclosed in double quotes. From a DOS command line prompt, double quotes must not enclose the SQL query.
Querying streams doesn't make sense, but the esp_query can be used to obtain information from an error stream if a downstream window is defined to retain the state of the error stream.
To print the contents of stream Emp, on a UNIX machine named myhost, using SQL port 11100:
echo "select * from Emp" | ./esp_query -p myhost:11100/workspace/project -c user:password
If myhost is a Windows machine, the esp_query syntax is the same, but the query must not be in quotes:
echo select * from Emp | esp_query -p myhost:11100/workspace/project -c user:password
To delete an entry from the Dept stream and update the Emp stream accordingly:
echo "delete from Dept where dn='SWP'; update Emp set dn='' where dn='SWP'" | ./esp_query -p myhost:11100/workspace/project -c user:password
To query a window, named ErrorState, that retains the state of an error stream named ErrorStream:
echo "select e.*, recordDataToString(e.sourceStreamName, e.errorRecord ) errorRecord from errorState e" |esp_query -p myhost:11100/workspace/project -c user:password