Reputation: 27
I'm a beginner to Progress and to programming, would be really greatful for some help.
Trying to write a query connected to a browser. In my window there is also a radioset (that sorts the browser, for example by name or age) and a fillin (if anything is written there and "ok" is pushed then only the posts where the surname begins with whatever is written are to be displayed in the browser.
The radioset has a default-value, on value-chagned the browser is opened again.
I've tried to write my query like the following and the sorting by the radioset works, but not the fillin (Showeing the error message that it doesn't understand the query):
DEFINE INPUT PARAMETER pfiSurname AS CHARACTER NO-UNDO.
DEFINE VARIABLE cQuery AS CHARACTER NO-UNDO.
DEFINE VARIABLE hQueryHandle AS HANDLE NO-UNDO.
&SCOPED-DEFINE BROWSER brMembers
DO WITH FRAME {&FRAME-NAME}:
ASSIGN rsSort.
IF fiSurname = '' THEN
ASSIGN cQuery = 'FOR EACH Member NO-LOCK by member.' + rsSort.
ELSE
ASSIGN cQuery = 'FOR EACH member NO-LOCK WHERE member.surname BEGINS'
+ fiSurname + 'BY member.' + rsSort.
hQueryHandle = {&BROWSER}:QUERY.
hQueryHandle:QUERY-PREPARE(cQuery).
hQueryHandle:QUERY-OPEN().
END.
END PROCEDURE.
Upvotes: 1
Views: 99
Reputation: 1498
You need to space before and after your string bits, enclose the surname in quotes, and use screen-value to the rsSort bit. Just to help you understand for the first part, message the query string. You'll see something like this: For each member no-lock where member.surname beginsEllenby member.chosenfield
When it should be For each member no-lock where member.surname begins "Ellen" by member.chosenfield
And just to make sure, I'd message the value of rsSort So I recommend you change to
ASSIGN cQuery = 'FOR EACH member NO-LOCK WHERE member.surname BEGINS '
+ Quoter(fiSurname) + ' BY member.' + rsSort:screen-value.
And like I said, message the entire thing, copy it and try to write it directly in the Progress window, I find it helps me a lot to debug these dynamic queries this way.
Upvotes: 2
Reputation: 7192
Add QUOTER() around fiSurname and extra SPACE's after the BEGINS and before the BY within the quotes
Upvotes: 1