Urgent Please Help

Reynold

Member
Problem is we are storeing the database table(pt_mstr) field name in a local variable l (ex pt_prod_line) and that database field value in another local variable k(the value of pt_prod_line as 9955) ... now there is an item whose item code(pt_part) is "xx01" ... now we have to check for that pt_part whether the product line value is 9955 or not .. by using l and k only ... so help me in this regard ...

define var l as char.
def var k as char.
l = "pt_prod_line".
k = "9955".
for first pt_mstr
where pt_part = "xx01" and l = k:
message "work".
end.

But this code is not working ... bcoz it is not considering l as database field though it contains the database field name .. but progress consider it as a text value ...
so how can we consider that as databse field....
 

DevTeam

Member
Hi Reynold,

If I did understand well your problem, here's a sample code why could help :

Code:
DEF VAR myBh AS WIDGET-HANDLE NO-UNDO.
DEF VAR myQh AS WIDGET-HANDLE NO-UNDO.
DEF VAR l AS CHARACTER INIT "pt_prod_line" NO-UNDO.
DEF VAR k AS CHARACTER INIT "9955" NO-UNDO.

CREATE BUFFER myBh FOR TABLE "pt_mstr".
CREATE QUERY myQh.
myQh:SET-BUFFERS(myBh).
myQh:QUERY-PREPARE("FOR EACH pt_mstr WHERE pt_part = 'xx01' NO-LOCK").
myQh:QUERY-OPEN.
myQh:GET-FIRST.

IF NOT myQh:QUERY-OFF-END
THEN DO :
    DEF VAR tmp AS CHAR NO-UNDO.
    tmp = STRING(myBh:BUFFER-FIELD(l):BUFFER-VALUE).
  
    IF tmp = k
    THEN DISP "ok".
END.

IF VALID-HANDLE(myQh)
THEN DO :
    myQh:QUERY-CLOSE().
    DELETE WIDGET myQh.
END.

IF VALID-HANDLE(myBh)
THEN DO :
    myBh:BUFFER-RELEASE().
    DELETE WIDGET myBh.
END.
I think it works...
But it implies that you are running Progress 9 or 10.
 

FrancoisL

Member
To get the result he wants the query should be:


myQH:QUERY-PREPARE("FOR EACH pt_mstr WHERE pt_part = 'xx01' AND " + l + " = '" + k + "' NO-LOCK").
 
Top