Buffer-Handle Method FIND-FIRST, FIND-LAST

Posted by Lars Neumeier on 16-Aug-2017 08:11

Hello,

Is it a wanted behavior, that in case that the where condition of FIND-FIRST or FIND-LAST equals to ? is the same like ""?

DEFINE VARIABLE cWhere AS CHARACTER NO-UNDO.
cWhere = ?.

BUFFER Customer:FIND-FIRST(cWhere, NO-LOCK).

All Replies

Posted by Lieven De Foor on 24-Aug-2017 02:51

I don't know if it's wanted, but it indeed appears to be the case.

The following are equivalent and do a FIND using the primary index:

- "WHERE TRUE",

- ""

- ?

Posted by Rick Terrell on 24-Aug-2017 05:58

Without any specified criteria, which index would you like if to use?

This is expected behavior.

Rick Terrell 
Principle Consultant, Professional Services 
Progress

Sent from my iPhone

Posted by cverbiest on 28-Aug-2017 06:41

I would not allow a developer to rely on that, even if it appears to work.

I'll take the risk of maybe misinterpreting the question.

I think some developers would expext unkown where to throw an error.

It's probably easier to find bugs if  where = ? would throw an error.

In our code a lot of find statements are with no-error so throwing an "unknown where clause" error would go undetected .

I've think we could use a "allow-unavailable" option on find to replace the no-error option.

This option would preserve errors such as 7254 (*) without throwing an error when there is no record.

(*) community.progress.com/.../eliminate_error_7254_and_allow_all_methodproperty_implementations_in_where_clauses

Posted by Lars Neumeier on 28-Aug-2017 09:33

I would expect, that no record is found.

We had a case (find and delete record) where we create a WHERE-Condition dynamically based on the primary unique index of a table, unfortunately, we did not handle the case with ? values in the query string algorithm, which results in WHERE-Condition = ?.

But okay, then I will log an idea request.

Kind regards,

Lars Neumeier

Posted by Rick Terrell on 28-Aug-2017 09:44

Ok, but that was not the original question. The OP's question was about index *selection*, not whether a record would be found. 

I would think that "where true" would act like a find first. Where = ? wouldn't find a record. 

Rick Terrell 
Principle Consultant, Professional Services 
Progress

Sent from my iPhone

Posted by Rick Terrell on 28-Aug-2017 09:48

Actually I would suspect that "where true" would be ambiguous if that were the only criteria. 

Rick Terrell 
Principle Consultant, Professional Services 
Progress

Sent from my iPhone

Posted by Lieven De Foor on 31-Aug-2017 02:27

"where true" is not ambigous in a FIND-FIRST, only in a FIND-UNIQUE.

I would also like WHERE ? to return no result or even throw an error...

You'll have my vote if you create a feature request for this one ;-)

Posted by cverbiest on 05-Sep-2017 04:57

@lars I voted for the idea.

I also added a slightly related idea asking for an extra option on find to distinguish between records no being available and other errors.

community.progress.com/.../unavailable-no-error_option_on_find__dynamic-find

Posted by Lars Neumeier on 05-Sep-2017 06:14

Thank you and you got my vote too.

This thread is closed