The current version of SQLNS doesn't really provide a *direct* way for
you to allow users to select the operator for the subscription. But
there are a couple of ways to do it leveraging the flexibility of the
First you can, of course, create multiple subscription classes, one for
each possibility. In your stock example, there'd be three - >, <, and =.
This is straightforward to do so I won't expound on this option.
But, there is a way to do it with just one subscription class. You can
create the subscription class with multiple conditions, allowing the
user to specify only the ones that apply to them.
For example, let's say the event data has StockSymbol and StockPrice as
it's fields. A subscription class could be created that has StockSymbol,
PriceGreaterThan, PriceLessThan, and PriceEqualTo. (I'm using your
example, but realistically the PriceEqualTo wouldn't be very useful.)
Your matching rule needs to make some of these conditions optional by
including some OR's in the WHERE clause. Something like this:
SELECT StockNotify(<parameter list goes here>)
FROM StockEvents e, StockSubscriptions s
WHERE e.StockSymbol = s.StockSymbol
AND ((s.PriceGreaterThan IS NULL) OR (e.StockPrice > s.PriceGreaterThan))
AND ((s.PriceLessThan IS NULL) OR (e.StockPrice < s.PriceLessThan))
AND ((s.PriceEqualTo IS NULL) OR (e.StockPrice = s.StockPrice))
Your Subscription Management Application would then be designed to allow
users to specify a stock symbol and one or more of the conditions. A
stock symbol is required, but the others are not (You should of course
require at list one, but that's a front end issue).
SQL Server MVP
Get up to speed quickly with SQLNS
The examples tend to trigger off of absolute conditions. For example,
let me know when a stock price is > a value. Can you create a
subscription rule where the operator is included in the subscription?
For example, a single subscription template would allow you to
determine when the stock is <, >, = to a value. The user would choose
the operator when setting up the subscription.
What would this look like?