[V4RB] Best Way to see if a value exists?

Ruslan Zasukhin sunshine at public.kherson.ua
Sun May 30 18:21:55 CDT 2004


On 5/30/04 6:07 PM, "Karen" <keatk at comcast.net> wrote:

Hi Karen,

> Right now I'm doing:
> 
> Dim cur as VCursor, ValueExists as boolean
> 
> Cur = db.SQLSelect("SELECT field FROM table WHERE Field = 'something')
> 
> ValueExists = Cur <> NIL AND Cur.RecordCount > 0
> 
> 
> 
> 
> I was wondering if the following would be faster:
> 
> 
> Dim cur as VCursor, ValueExists as boolean
> 
> Cur = db.SQLSelect("SELECT Count(field) FROM table WHERE Field =
> 'something')
> 
> ValueExists = Cur <> NIL AND Cur.ULongField(1).Value <> 0

No, it do the same PLUS it should COUNT

> Also would that be he right way for that way of doing it?
> I am assuming here that a count is a ULongField.

yes

> I am also assuming Cur.RecordCount can never be 0,  as a count of 0
> should still return a "record"

Right.

-----------
In Valentina 2.0 will be added such features which should help on this task


1) WHERE fld = 2 LIMIT 1


2) API way:

    dim res as boolean

    res = table.field( "fld" ).Exists( 2 )


-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list