Hi Everyone,
You are probably thinking, what the hell is this Noob talking about Dynamic For Each Statement!
Ok, let me explain what I'm trying to achieve.
My current working database has over 100s of tables, for my self and other developers, it' ok, because we have the knowledge of the 'For Each' and 'Find' statements. But for the Business Analysts, when they perform testing, they wouldn't know how to write up a simple for each statement, even if they new the table name, if they wanted to look up on some records.
So I thought, ok, if the BAs knew what tables and fields to look for, I can just write up a simple program, to take the table name and the field queries.
It wasn't so simple, as a matter of fact, I got stuck.
I've got a simple .i file which can be seen as the body, if you wish.
/* Heres my file called dynquery.i */
&IF "{1}" <> "" &THEN
FOR EACH {1} WHERE {1}.{2} = "{3}" NO-LOCK:
DISPLAY {1}.{4}.
END.
&ENDIF
/* End of file called dynquery.i */
And here's the simple .p file:
/* Heres my file called TESTING.i */
DEF VAR tempaaa AS CHAR NO-UNDO.
DEF VAR tname AS CHAR NO-UNDO.
DEF VAR tfield AS CHAR NO-UNDO.
DEF VAR qfield AS CHAR NO-UNDO.
DEF VAR dfield AS CHAR NO-UNDO.
tname = "TABLE-A".
tfield = "FIELD-A".
qfield = "QFIELD-A".
dfield = "FIELD-B".
{DYNQUERY.i tname tfield qfield dfield}.
/* End of file called TESTING.i */
The error I am getting is Unknown or Ambiguous tname table, although I have assigned tname to TABLE-A, but Progress seems to be using "tname" instead of what the variable is.
In the .i file, if I comment out the 'for each' statement and just to display '{1}', I will actually get the name TABLE-A.
Is there a work around?
Or is there some Progress already defined code?
Thanks in advance.
Calv.
You are probably thinking, what the hell is this Noob talking about Dynamic For Each Statement!
Ok, let me explain what I'm trying to achieve.
My current working database has over 100s of tables, for my self and other developers, it' ok, because we have the knowledge of the 'For Each' and 'Find' statements. But for the Business Analysts, when they perform testing, they wouldn't know how to write up a simple for each statement, even if they new the table name, if they wanted to look up on some records.
So I thought, ok, if the BAs knew what tables and fields to look for, I can just write up a simple program, to take the table name and the field queries.
It wasn't so simple, as a matter of fact, I got stuck.
I've got a simple .i file which can be seen as the body, if you wish.
/* Heres my file called dynquery.i */
&IF "{1}" <> "" &THEN
FOR EACH {1} WHERE {1}.{2} = "{3}" NO-LOCK:
DISPLAY {1}.{4}.
END.
&ENDIF
/* End of file called dynquery.i */
And here's the simple .p file:
/* Heres my file called TESTING.i */
DEF VAR tempaaa AS CHAR NO-UNDO.
DEF VAR tname AS CHAR NO-UNDO.
DEF VAR tfield AS CHAR NO-UNDO.
DEF VAR qfield AS CHAR NO-UNDO.
DEF VAR dfield AS CHAR NO-UNDO.
tname = "TABLE-A".
tfield = "FIELD-A".
qfield = "QFIELD-A".
dfield = "FIELD-B".
{DYNQUERY.i tname tfield qfield dfield}.
/* End of file called TESTING.i */
The error I am getting is Unknown or Ambiguous tname table, although I have assigned tname to TABLE-A, but Progress seems to be using "tname" instead of what the variable is.
In the .i file, if I comment out the 'for each' statement and just to display '{1}', I will actually get the name TABLE-A.
Is there a work around?
Or is there some Progress already defined code?
Thanks in advance.
Calv.