strange behavour V10

caelum

New Member
:confused:

Can someone tell me why i can't find a record in table 'er-200' when i use example 1.
But when i use example 2, i do find that record.

When i use both examples on other databases (V9 or V10) they both work.




DEF VAR c_sleutel AS CHAR NO-UNDO.


/* 1 */

FIND FIRST er-200 WHERE er-200.cd_hfdrelnr = '00000017' NO-LOCK NO-ERROR.

FOR EACH ba-012
where ba-012.id-cdads = er-200.cd_adressleutel NO-LOCK:
DISP ba-012.
END.

/* 2*/


FIND FIRST er-200 WHERE er-200.cd_hfdrelnr = '00000017' NO-LOCK NO-ERROR.

c_sleutel = er-200.cd_adressleutel.

FOR EACH ba-012
where ba-012.id-cdads = c_sleutel NO-LOCK:
DISP ba-012.
END.
 
You've got a NO-ERROR on your FIND of er-200 but you are not testing to see if that FIND succeeds. You are then trying to use the record in the FOR EACH. If there is nothing there it will fail.

(The FIRST is almost certainly totally unnecessary too.)

Try changing it to:

Code:
find er-200 no-lock where er-200.cd_hfdrelnr = '00000017' no-error.

if not available( er-200 ) then
  do:
    message "Oops!".
    return.
  end.

for each ba-012 no-lock where ba-012.id-cdads = er-200.cd_adressleutel:
  display ba-012.
end.

I'm guessing that it works on your other systems because those systems actually have an er-200 record that meets the WHERE criteria and this system does not.
 
Thnx Tom,

But i'm sure there is a re-200 record. That's the reason i don't test it :).

Like i said, in my second example (when i put the value of the re-200 record in a variable it works).
Why does it only meets the WHERE criteria when i use this variable?
 
Oops, I didn't parse the original post correctly. You're right -- that is odd.

Are you getting an error message?
 
No messages,

You know what's funny. This is a snippet of code that is used for years. Never had any problems with it. So i think it's a database problem. But i don't know what it is. Like you said, it's odd :confused:

I can display the value of this field, but i can't use it to find other records in other tables. I even try to overwrite te value myself, doesn't work eather.

i'm lost:eek:
 
The two fields have same type in data dictionary ? I suppose yes, else code should not run.

Uhm maybe assigning value to a char variable makes some kind of data conversion that makes the value be equal to the field in the second table. My supposition.

In example 1, if u write something like

where ba-012.id-cdads = STRING(er-200.cd_adressleutel)

it works?

P.S. : i try to help you, but i m just a newbie of progress!

I mean that for some reason there's a difference in that two fields on that two records..
There could be a space or some charachter that is not visible to you but that makes the two not equal..
Sometimes i found this problem even in access or sql-server based database..
 
How do you have c_sleutel defined? And how is er-200.cd_adressluetel defined? I am leaning towards the possibility that the lengths of the two fields are different in some way that makes the comparison not work the way you would expect.
 
Back
Top