Consultor Eletrônico



Kbase P17456: Error 7328 when using variable in SDO WHERE clause
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   15/10/2008
Status: Unverified

FACT(s) (Environment):

Progress 9.x

SYMPTOM(s):

Error 7328 when using variable in SDO WHERE clause

<database name> <buffer name> <field name> must be a quoted constant or an unabbreviated, unambiguous buffer/field reference for buffers known to query <name>. (7328)

CAUSE:

Using a variable, like viCustNum, it's not possible to change the WHERE clause of the SDO query to read: Customer.CustNum = viCustNum,

because the final string that gets passed to the QUERY-PREPARE is generated to look like this:

'OPEN QUERY Query-Main FOR EACH Customer NO-LOCK WHERE Customer.CustNum =
viCustNum INDEXED-REPOSITION'

This will not compile because the QUERY-PREPARE sees viCustNum as a field on the table. Instead, the WHERE section in the query builder or the OPEN_QUERY trigger of a freeform query has to read:

Customer.CustNum = ' + STRING(viCustNum) + ', because the final string that gets passed to the QUERY-PREPARE then looks like this:

'OPEN QUERY Query-Main FOR EACH Customer WHERE NO-LOCK Customer.CustNum = ' + STRING(viCustNum) + ' INDEXED-REPOSITION'.

FIX:

Call the setQueryWhere SDO Function to dynamically change the WHERE clause of the SDO query. These are the steps to do the same thing that was done with the code above using the setQueryWhere SDO Function instead:

1. Define a character variable in the SDO definitions section. IE:
DEFINE VARIABLE vcWhereClause AS CHARACTER NO-UNDO.

2. Create an override version of the initializeObject procedure in the SDO and place the following code into it:

PROCEDURE initializeObject :

/* Code placed here will execute PRIOR to standard behavior. */
ASSIGN vcWhereClause = "Customer.CustNum = '" + STRING(viCustNum) + "'".
DYNAMIC-FUNCTION('setQueryWhere':U IN THIS-PROCEDURE, vcWhereClause).

RUN SUPER.

END PROCEDURE.

3. Save changes and run the SDO code.