Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Locate always returns False


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Jan 19, 2016 11:13 AM Last Post By: Paulo Mariano
Paulo Mariano

Posts: 29
Registered: 11/25/12
Locate always returns False  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 15, 2016 9:18 AM
Hello.

For a given table in Informix, the primary key is composed of 3 columns:
col1: SmallInt
col2: Char(20)
col3: DateTime Year to Second

In a Delphi XE6 application, a TFDQuery object retrieves some rows from the mentioned table, including the columns that define the primary key.
Then, Locate method is called with values that match one of the rows retrieved:
Found := Locate('col1; col2; col3', VarArrayOf([value1, value2, value3]), []);

Despite assigning value1, value2 and value3 with values that uniquely identify a row in the result set, Found is always equal to False.

When the DateTime column is excluded from the statement, Locate returns True:
Found := Locate('col1; col2', VarArrayOf([value1, value2]), []);


Is there a bug in the Locate method?

Thank you in advance.
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Locate always returns False  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 19, 2016 5:36 AM   in response to: Paulo Mariano in response to: Paulo Mariano
Is there a bug in the Locate method?

It depends on how you are assigning col3 value.
1) Are you sure that it does not include fractional part of seconds ?
2) How the col3 is defined ? ftDateTime or ftSQLTimeStamp ? If first,
then there are all chances to always get False because Float=Float
may be affected to precision lost.

--
With best regards,
Dmitry
Paulo Mariano

Posts: 29
Registered: 11/25/12
Re: Locate always returns False  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 19, 2016 11:00 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
2) How the col3 is defined ? ftDateTime or ftSQLTimeStamp ?

Hello, Dmitry.
Thank you for your reply.

Here's how the variables are defined and initialized:

var
  col1: Integer;
  col2: String;
  col3: TDateTime;
.
.
.
 
  col1:= query.Fields[1].AsInteger;
  col2:= query.Fields[2].AsString;
  col3:= query.Fields[3].AsDateTime;


Please, let me know how col3 should be declared and initialized.TSqlTimeStamp doesn't seem to be a valid type.
Thank you again.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02