locate methods for cursor

Sims, John (CDC/NCBDDD/DBDDD) (CTR) ayu8 at cdc.gov
Tue Jun 27 09:08:12 CDT 2006


> Hi John,
> 
> > Sorry if I'm a little late to the dance.  I was on 
> vacation.  The .Net 
> > Datatable (similar in concept to a Vcursor) has a 
> PrimaryKey property 
> > as an array of DataColumns.  You can then execute a "Find" on the 
> > Datatable by providing it with the value (or values if you have a 
> > multiple column
> > PrimaryKey) and it will return the Datarow of the row that 
> matches.  
> > As in a database, the PrimaryKey column(s) must contain values that 
> > make each row unique.  If you attempt to create a 
> PrimaryKey that has 
> > duplicate data, it will fail.  Perhaps you could do 
> something similar 
> > with the Vcursor.
> > 
> > Vcursor.PrimaryKey as Vfield()
> > 
> > Then Vcursor.Find(Value()) could set the Vcursor to the matching 
> > record if found or EOF if not found.
> > 
> > Just my little input.
> 
> To clarify. So steps are next?
> 
>     curs = db.SqlSelect( "select f1, f2, f3, FROM T1 ..." )
> 
>     curs.PrimaryKey = f2    // f2 must have unique values...
> 
>     curs.Find( v2 )  // move cursor to record that have in f2 
> value v2.
>         
> 
> Right ?
> 
> 
> --
> Best regards,
> 
> Ruslan Zasukhin
> VP Engineering and New Technology
> Paradigma Software, Inc

Hi Ruslan,

Yes, that is very much how the .NET Datatable works.  The only thing I
would point out is that the .NET Datatable allows you to use multiple
column PrimaryKey by making PrimaryKey an array of Datacolumns.  Using
your example, it might look more like this.

Dim pk() as Vfield

curs = db.SqlSelect( "select f1, f2, f3, FROM T1 ..." )

Pk.append(f2)
 
curs.PrimaryKey = pk    // f2 must have unique values...

Dim vals() as string

Vals.append(v2)

curs.Find( Vals )  // move cursor to record that have in f2 value v2.


So, if you needed a multiple column primary key, you could do this.

Dim pk() as Vfield

curs = db.SqlSelect( "select f1, f2, f3, FROM T1 ..." )

Pk.append(f2)
Pk.append(f3)
 
curs.PrimaryKey = pk    // The combination of f2 and f3 must have unique
values...

Dim vals() as string

Vals.append(v2)
Vals.append(v3)

curs.Find( Vals )  // move cursor to record that have in f2 value v2 and
f3 value v3.


I hope I have made this clear enough.  If not, let me know.

Thanks!

-John



More information about the Valentina mailing list