Kbase P19044: QUERY-PREPARE with USE-INDEX fails with index created by the
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  13/02/2003 |
|
Status: Unverified
FACT(s) (Environment):
Progress 9.1D
SYMPTOM(s):
PREPARE-QUERY method fails when USE-INDEX option refers to an index created with ADD-LIKE-INDEX method by a name different from the original source index name.
** Could not find Index <index-name> in table <table>. (229)
QUERY-OPEN for query <name> requires a previous QUERY-PREPARE. (7312)
Cannot run GET methods on query <name> until it is opened. (7313)
The following code generates the errors if run against the sports2000 database:
/**********************************************************/
DEFINE VARIABLE httHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE hqHandle AS WIDGET-HANDLE.
DEFINE VARIABLE hbttHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE httCustNum AS HANDLE NO-UNDO.
DEFINE VARIABLE hName AS HANDLE NO-UNDO.
DEFINE VARIABLE lLogical AS LOGICAL NO-UNDO.
/*Create the temp table, its fields and index */
CREATE TEMP-TABLE httHandle.
ASSIGN
lLogical = httHandle:ADD-LIKE-FIELD("ttCustNum","Customer.CustNum")
lLogical = httHandle:ADD-LIKE-FIELD("Name","Customer.Name")
lLogical = httHandle:ADD-LIKE-INDEX("ttIndex","name","customer").
ASSIGN
lLogical = httHandle:TEMP-TABLE-PREPARE("myTempTable").
ASSIGN
hbttHandle = httHandle:DEFAULT-BUFFER-HANDLE
httCustNum = hbttHandle:BUFFER-FIELD("ttCustNum")
hName = hbttHandle:BUFFER-FIELD("Name").
/* populate the temp table from the customer table */
FOR EACH Customer NO-LOCK:
hbttHandle:BUFFER-CREATE.
ASSIGN
httCustNum = hbttHandle:BUFFER-FIELD("ttCustNum")
hName = hbttHandle:BUFFER-FIELD("Name")
httCustNum:BUFFER-VALUE = Customer.CustNum
hName:BUFFER-VALUE = Customer.Name.
END.
/* create a query and query it using the USE-INDEX */
CREATE QUERY hqHandle.
hqHandle:SET-BUFFERS(hbttHandle).
hqHandle:QUERY-PREPARE("FOR EACH myTempTable USE-INDEX ttIndex").
hqHandle:QUERY-OPEN.
REPEAT WITH FRAME y:
hqHandle:GET-NEXT().
IF hqHandle:QUERY-OFF-END THEN LEAVE.
DISPLAY hName:BUFFER-VALUE FORMAT "X(35)"
httCustNum:BUFFER-VALUE FORMAT "9999999".
END.
hqHandle:QUERY-CLOSE().
DELETE OBJECT hqHandle.
DELETE OBJECT httHandle.
/**********************************************************/
CAUSE:
Bug number 20030213-009 has been logged for this issue.
FIX:
There are two possible workarounds:
1. Modify the ADD-LIKE-INDEX and the QUERY-PREPARE statements to use the same name as the original source LIKE index, "name":
lLogical = httHandle:ADD-LIKE-INDEX("name","name","customer").
hqHandle:QUERY-PREPARE("FOR EACH myTempTable USE-INDEX Name").
2. Use the ADD-NEW-INDEX method instead of the ADD-LIKE-INDEX method to create the new index leaving the QUERY-PREPARE statement unchanged:
ASSIGN
lLogical = httHandle:ADD-NEW-INDEX("ttIndex",FALSE,true).
lLogical = httHandle:ADD-INDEX-FIELD("ttIndex","ttName").
hqHandle:QUERY-PREPARE("FOR EACH myTempTable USE-INDEX ttIndex").