Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Beginner question
Mon, Jul 21 2008 5:39 AMPermanent Link

"Norbert Stellberg"
Hello,

2 questions:

1. I have a DBIsamTable named ARTIKEL
   A fieldname is ARTNR

   How I can find an artikel 1234 in the fields ARTNR

2. How I can build an index with 2 fieldnames.
    special: copy( ARTNR,1,4) + copy (ARTName,1,4)

Thanks
with best regards
Norbert
Mon, Jul 21 2008 6:21 AMPermanent Link

"Eduardo [HPro]"
Norbert

> 1. I have a DBIsamTable named ARTIKEL
>    A fieldname is ARTNR
>
>    How I can find an artikel 1234 in the fields ARTNR
You should have an index on field ARTNR and use FindKey to find it:
if artikel.findkey([1234]) then begin
  // It was found
end else begin
  // It was not found
end;

> 2. How I can build an index with 2 fieldnames.
>     special: copy( ARTNR,1,4) + copy (ARTName,1,4)
In DBISAM there is no index expression and therefore you should create a
special field to store the expression evaluated:

MyTable.FieldByName('MyIndexField').AsString := copy( ARTNR,1,4) + copy
(ARTName,1,4)
MyTable.Post;

Eduardo

Mon, Jul 21 2008 6:43 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Norbert

>1. I have a DBIsamTable named ARTIKEL
> A fieldname is ARTNR
>
> How I can find an artikel 1234 in the fields ARTNR

Via tables you can use .Locate or .FindKey. If 1234 is only part of the field then you're probably best using .Locate and the loPartialKey.

You can also use a Filter eg 'ARTNR = '+QuotedStr('1234') and set filter to True or, again if its a partial key

'ARTNR LIKE '+QuotedStr('1234%') if its at the front of the field
'ARTNR LIKE '+QuotedStr('%1234') at the back of the field
'ARTNR LIKE '+QuotedStr('%1234%') somewhere in the field

>2. How I can build an index with 2 fieldnames.
> special: copy( ARTNR,1,4) + copy (ARTName,1,4)

If ARTNR and ARTName are both 4 character fields then use DBSys to create the index adding both fields in. If you want to extract just the first 4 characters from each field then you'll have to create another field, populate it with the information from ARTNR and ARTName and use that.

Roy Lambert [Team Elevate]

Mon, Jul 21 2008 6:55 AMPermanent Link

"Norbert Stellberg"
Thanks a lot.
with best regards
Norbert
Image