Das Notes Forum

Domino 9 und frühere Versionen => ND6: Entwicklung => Thema gestartet von: Toma Bogdan am 15.06.04 - 16:54:27

Titel: GetDocumentByKey method works strange
Beitrag von: Toma Bogdan am 15.06.04 - 16:54:27
I use the following code to search within another DB using the ID filed (a number field)
Code
Set dbB=New notesdatabase (dbA.server,path$ + "a_doc.nsf")
Set view=dbB.getview("(DOCS)")
Set target=view.getdocumentbykey(L(i),True)
If Not (target Is Nothing) Then
   Set uidoc = ws.EditDocument( False, target )   
Else 
   Messagebox("The doc doesn't exist or can't be accessed !")
End If

the view (Docs) located in the a_doc.nsf DB contains just a single sorted column (ID) for the GetAllDocumentsByKey method to work.

When I try to find a doc that exist in the second DB (a_doc.nsf), I receive the above script message (The doc doesn't exist or can't be ...) even it exist !  ???

where is the mistake ?

10x
Titel: Re:GetDocumentByKey method works strange
Beitrag von: koehlerbv am 15.06.04 - 17:08:19
From my experience GetDocumentByKey works without any problems at all.
Is your column in the view in the other database really sorted ?
Do you really use the value with L (i) which you expect ?

A few days ago somebody reported problems with values of the data type Double and GetDocumentByKey with a specific Notes version. A workaround for that was to use string variables instead of number variables (I always use GetDocumentByKey with string values): Change your sorted column to @Text (IDField) and use string variables in your array L, too.

HTH,
Bernhard
Titel: Re:GetDocumentByKey method works strange
Beitrag von: Semeaphoros am 15.06.04 - 18:12:28
I too think, that searching with strings will be mor reliable than searching with numbers, when using GetDocumentByKey
Titel: Re:GetDocumentByKey method works strange
Beitrag von: TMC am 15.06.04 - 23:59:43
Well, Toma, would be interesting which result you receive when using a string variable instead of a number variable.
The user, Bernhard mentioned above, was first using a long variable and had no problems. Only when he was using a variable of the data type Double an error occurred.

Please let us know your result.
Titel: Re:GetDocumentByKey method works strange
Beitrag von: Toma Bogdan am 16.06.04 - 09:21:46
well, I have converted the key to a number Set target=v.getdocumentbykey(Cint(L(i)),True) and it works now ! it was my mistake  ::)

I too think, that searching with strings will be mor reliable than searching with numbers, when using GetDocumentByKey

is it true ?
Titel: Re:GetDocumentByKey method works strange
Beitrag von: Semeaphoros am 16.06.04 - 13:15:07
Yes, thats true, probabily with integers you don't have much troubles (but you cannot be sure about that). With any real data type I am pretty sure, that you will run into problems, as the machine is plagued by rounding problems and hence it has a lot of difficulties to get a correct "equal" value, this is an inherent problem with any computing.