Writing a Query

Write application code which filters incoming data.

Now, with your project components in place, you're ready to write the application code that will filter incoming data for rows containing a specific stock symbol.

Follow these steps to write a query:

  1. Type the following text into the Queries tab after the existing statements, starting at about line 25. As you type, notice the autocompletion feature. When the autocompletion list appears, click the word you want to use and then press the TAB key:
    INSERT INTO FilteredTrades
    

    Autocompletion works not only for CCL reserved words, like INSERT and INTO, but also for stream and column names that you've defined yourself. This first line of code specifies that the results of the query be published to the FilteredTrades output stream.

  2. Enter the rest of the query:
    SELECT *
    FROM StockTrades
    WHERE Symbol = 'EBAY';
    

    These lines of code tell Sybase CEP Engine to take all fields from the input stream (StockTrades), but only from rows where the value of the Symbol column is "EBAY". A semi-colon ends the Query statement.

    Your Queries tab should look like this:

    SFFirstQuery2 PNG

    Notice how Sybase CEP Studio color-codes different parts of the syntax for easy identification: reserved words are blue; column names, stream names, and numeric values are black; string literals enclosed in double quotation marks are red, and string literals enclosed in single quotation marks are magenta.