main logo
Subject: Re: [V4RB] Best Way to see if a value exists?
Author: Ruslan Zasukhin
Posted: 2004/05/30 10:21:55
 
View Entire Thread
New Search


On 5/30/04 6:07 PM, "Karen" <keatk at comcast D.OT 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@paradigmasoft.com
web: http://www.paradigmasoft.com

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

_______________________________________________
Valentina mailing list
Valentina at lists D.OT macserve.net
http://lists.macserve.net/mailman/listinfo/valentina

 
©2004 Ruslan Zasukhin
<-- Prior Message New Search Next Message -->