
How do I do an existence test with dbtools.h++
Quote:
>I'm drawing a blank on how one does an existence test using SQL.
>All I want to do is ascertain whether some row in a table exists.
>I'm using Rogue Wave dbtools.h++
>How would I code this using a RWDBReader, RWDBSelector, etc.?
Use the global function rwdbExists(const RWDBSelectorBase&). Eg,
extern RWDBSelector mySelector;
extern RWDBDatabase db;
RWDBSelector s = db.selector();
s << "Yes it does";
s.where(rwdbExists(mySelector));
// etc.
This is equivalent to the SQL "Select 'Yes it does' where
exists( <text of mySelector here> )
Caveat: there may be restrictions on what you can put into the
exists clause. For example, my MS SQL-Server 6.0 claims this
is a syntax error: "select 'yes' where exists( select name, id
from sysobjects where id < 10 )" It's ok if there's only one
item selected in the inner select.
Quote:
>Thanks
>---------------------------------------------------------------------
>Christopher Ruegger phone: (301) 925-1164
--
Stan Sulsky
97 Madbury Rd. | (603) 868-2270 - voice
Durham, NH 03824 USA | (603) 868-1352 - fax