[antlr-interest] String Template Puzzle

David Beckedorff david.beckedorff at gmail.com
Mon Jun 30 14:28:51 PDT 2008


Dear String Templaters,

I have a ST template that generates a SQL update statement::

dtoSqlMap(service,dto) ::= <<
...
update $dto.tableName$
set $dto.fields : { f |
  $f.dbColName$ = #$f.name;format="ilc"$:$f.dbColType$#};
separator=","$           <== "ilc" means to format the initial letter
lowercase
where current of c1;
...
>>

which in a specific case generates the following code:

update DP_JRNL_ENTRY
set
  DP_JRNL_ENTRY_ID = #id:NUMERIC,
  OWNR_PERS_NTL_ID = #ownerId:VARCHAR,
  OWNR_DP_TYPE_CD = #ownerDpType:VARCHAR,
  ATHR_PERS_NTL_ID = #authorId:VARCHAR,
  ATHR_PERS_SRC_ID = #authorSourceId:NUMERIC,
  SBJ_AREA_ID = #subjectAreaId:NUMERIC,
  DP_GOAL_TYPE_CD = #goalTypeCode:VARCHAR,
  DP_JRNL_TITLE_TX = #title:VARCHAR,
  DP_JRNL_ENTRY_TX = #entry:CLOB,
  DP_JRNL_CRTN_DT = #createDate:DATE,
  DP_JRNL_UPDT_DT = #modifiedDate:DATE,
  DP_JRNL_STRT_DT = #startDate:DATE,
  DP_JRNL_END_DT = #endDate:DATE,
  DP_JRNL_ACHV_DT = #achievementDate:DATE,
  VER_NBR = #version:NUMERIC
where current of c1;


However, I want to suppress the DP_JRNL_ENTRY_ID and VER_NBR fields. The
former is implied by "where current of c1" and the latter is updated by a
trigger, so should be omitted from the update statement. But they are valid
fields of the Data Transfer Object (DTO).

It appears that the $if(...)$ construct allows to test for the presence of
an attribute or the value of a boolean. But I don't think it allows to test
for:  if  ( $f.dbColName$ == "DP_JRNL_ENTRY_ID" ).

Is there some other way to accomplish this?

Thanks,
David




-- 
----------------------------------

David Beckedorff
57 Emerson Rd.
Wellesley, MA  02481

Home:  (781) 235-0061
Cell:  (781) 820-0567
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080630/ee8ec431/attachment.html 


More information about the antlr-interest mailing list