Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 3 Tools : PARSE_TAM

PARSE_TAM
Breaks up an input string into a table specification, and optionally, the WHERE clause and the ORDERED clause of the corresponding table access statement. (C)
Invocation
CALL PARSE_TAM(string)
 
The string of characters to be analyzed by the parser. Contains the table specification, optionally the WHERE clause, and optionally the ORDERED clause of the corresponding table access statement.
Usage Notes
On successful return, the fields of the table buffer of the TEM table TAM are initialized.
Fields of the TEM Table Called TAM
 
Successive invocations of PARSE_TAM overwrite the values in the TAM table buffer left by previous invocations.

Exceptions
 
There is a syntax error in the table specification, WHERE clause and ORDERED clause passed in the argument string. The field TAM.MSG contains a message specifying the syntax error. The other fields of TAM are NULL.
Example
Rule

 
RULE EDITOR ===> SCROLL: P
QUERY(STRING);
_ LOCAL ROW;
_ ---------------------------------------------------------------------------
_ ------------------------------------------------------------+--------------
_ CALL PARSE_TAM(STRING); | 1
_ CALL FORALLA(TAM.TNAME, TAM.PSTR, TAM.WSTR, TAM.OSTR); | 2
_ UNTIL TABLEEND : | 3
_ ROW = ROW + 1; |
_ CALL MSGLOG(TAM.TNAME || ' ROW# ' || ROW); |
_ CALL MSGLOG(''); |
_ FORALL FIELDS(TAM.TNAME) : |
_ CALL MSGLOG(PAD(FIELDS.NAME, 16, ' ', 'R') || ': ' |
_ ||(TAM.TNAME).(FIELDS.NAME)); |
_ END; |
_ CALL MSGLOG(''); |
_ CALL FORALLB(TAM.TNAME); |
_ END; |
_ CALL FORALLE(TAM.TNAME); | 4
_ CALL ENDMSG(ROW || ' ROWS FOUND IN ' || TAM.TNAME); | 5
_ ---------------------------------------------------------------------------
_ ON PARSER_ERROR :
_ CALL ENDMSG(TAM.MSG);
_ ON TABLEEND :
_ CALL FORALLE(TAM.TNAME);
_ CALL ENDMSG('NO ROWS FOUND IN ' || TAM.TNAME);

 
Explanation
The QUERY rule does the following:
1.
Takes a string containing the table specification, plus optionally the WHERE clause and optionally the ORDERED clause of a table access statement
2.
Dynamically accesses all rows of the specified table instance that match the WHERE clause (if there is a WHERE clause, otherwise all the rows)
3.
For example:
CALL QUERY('TABLES WHERE NAME >= ''Q'' ORDERED DESCENDING NAME');
lists the rows of the TABLES table where the field value of NAME is greater than or equal to the letter Q in reverse alphabetical order of the values of the field NAME.
CALL QUERY('FIELDS(TAM)');
lists the rows of the table instance with a parameter value of TAM of the FIELDS table.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved