This repository has been archived on 2025-12-25. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tcommon-studio-se/org.talend.librariesmanager/resources/java/sqltemplates/__TEMPLATE__.template
2011-11-25 15:56:59 +00:00

22 lines
846 B
Plaintext

-- This pattern is suitable to make aggregate caculates(group by operations) on a table
--(c) 2008 Talend Inc.
<%
EXTRACT(__GROUPBY__);
EXTRACT(__OPERATION__);
String operation = "";
boolean flag=false;
for(int i=0; i < __OPERATION_INPUT_COLUMN__.length; i++){
if(flag){
operation += ",";
}else{
flag=true;
}
operation += (__OPERATION_FUNCTION__[i] + "(" + __OPERATION_INPUT_COLUMN__[i] + ")");
}
%>
INSERT INTO <%=__TABLE_NAME_TARGET__%> (<%=StringUtils.list(__OPERATION_OUTPUT_COLUMN__, ",")%> , <%= StringUtils.list(__GROUPBY_OUTPUT_COLUMN__, ",") %> )
SELECT <%= operation %>, <%= StringUtils.list(__GROUPBY_INPUT_COLUMN__, ",") %> FROM <%= __TABLE_NAME__ %>
GROUP BY <%=StringUtils.list(__GROUPBY_INPUT_COLUMN__, ",", "", "") %>;