[antlr-interest] String Template Puzzle

Johannes Luber jaluber at gmx.de
Mon Jun 30 14:55:06 PDT 2008


David Beckedorff schrieb:
> 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 
> <http://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

Create a new attribute IsdbColNameJournalEntry.

Johannes


More information about the antlr-interest mailing list