Skip to content
Permalink
Browse files

0003884: Oracle LONG error when creating trigger

  • Loading branch information...
elong
elong committed Mar 5, 2019
1 parent da503d4 commit 76afa7b2ab9246b65fe5a1cbe7ebaf88e821489e
@@ -371,15 +371,25 @@ public String massageForLob(String sql, boolean isContainsBigLob) {

@Override
public boolean isInitialLoadTwoPassLob(Table table) {
return parameterService.is(ParameterConstants.INITIAL_LOAD_EXTRACT_USE_TWO_PASS_LOB)
&& !TableConstants.getTables(parameterService.getTablePrefix()).contains(table.getNameLowerCase())
&& table.containsLobColumns(this.platform);
boolean initialLoadTwoPassLob = false;
if (parameterService.is(ParameterConstants.INITIAL_LOAD_EXTRACT_USE_TWO_PASS_LOB)
&& !TableConstants.getTables(parameterService.getTablePrefix()).contains(table.getNameLowerCase())) {
for (Column column : table.getLobColumns(this.platform)) {
if (!column.getJdbcTypeName().equalsIgnoreCase("LONG")) {
initialLoadTwoPassLob = true;
break;
}
}
}
return initialLoadTwoPassLob;
}

@Override
public String getInitialLoadTwoPassLobLengthSql(Column column, boolean isFirstPass) {
String quote = this.platform.getDdlBuilder().getDatabaseInfo().getDelimiterToken();
if (isFirstPass) {
if (column.getJdbcTypeName().equalsIgnoreCase("LONG")) {
return isFirstPass ? "1=1" : "1=0";
} else if (isFirstPass) {
return "dbms_lob.getlength(t." + quote + column.getName() + quote + ") <= 4000";
}
return "dbms_lob.getlength(t." + quote + column.getName() + quote + ") > 4000";
@@ -44,6 +44,7 @@ public OracleTriggerTemplate(ISymmetricDialect symmetricDialect) {
dateColumnTemplate = "decode($(tableAlias).\"$(columnName)\", null, '', concat(concat('\"',to_char($(tableAlias).\"$(columnName)\", 'YYYY-MM-DD HH24:MI:SS','NLS_CALENDAR=''GREGORIAN''')),'\"'))" ;
clobColumnTemplate = "decode(dbms_lob.getlength(to_clob($(tableAlias).\"$(columnName)\")), null, to_clob(''), '\"'||replace(replace($(tableAlias).\"$(columnName)\",'\\','\\\\'),'\"','\\\"')||'\"')" ;
blobColumnTemplate = "decode(dbms_lob.getlength($(tableAlias).\"$(columnName)\"), null, to_clob(''), '\"'||$(prefixName)_blob2clob($(tableAlias).\"$(columnName)\")||'\"')" ;
longColumnTemplate = "$(oracleToClob)'\"\\b\"'";
booleanColumnTemplate = "decode($(tableAlias).\"$(columnName)\", null, '', '\"'||cast($(tableAlias).\"$(columnName)\" as number("+symmetricDialect.getTemplateNumberPrecisionSpec()+"))||'\"')" ;
xmlColumnTemplate = "decode(dbms_lob.getlength(extract($(tableAlias).\"$(columnName)\", '/').getclobval()), null, to_clob(''), '\"'||replace(replace(extract($(tableAlias).\"$(columnName)\", '/').getclobval(),'\\','\\\\'),'\"','\\\"')||'\"')" ;
triggerConcatCharacter = "||" ;
@@ -101,6 +101,8 @@

protected String blobColumnTemplate;

protected String longColumnTemplate;

protected String binaryColumnTemplate;

protected String imageColumnTemplate;
@@ -874,7 +876,11 @@ else if (column.getJdbcTypeName() != null
break;
case Types.LONGVARCHAR:
case ColumnTypes.LONGNVARCHAR:
if (!isLob) {
if (column.getJdbcTypeName().equalsIgnoreCase("LONG") && isNotBlank(longColumnTemplate)) {
templateToUse = longColumnTemplate;
isLob = false;
break;
} else if (!isLob) {
templateToUse = stringColumnTemplate;
break;
}
@@ -2873,7 +2873,7 @@ protected void startNewCursor(final TriggerHistory triggerHistory,
log.info("Querying level {} for table {}: {}", selfRefLevel, sourceTable.getName(), selectSql);
}

Channel channel = configurationService.getChannel(triggerRouter.getTrigger().getChannelId());
Channel channel = configurationService.getChannel(triggerRouter.getTrigger().getReloadChannelId());

if (channel.isReloadFlag() && symmetricDialect.isInitialLoadTwoPassLob(this.sourceTable)) {
channel = new Channel();

0 comments on commit 76afa7b

Please sign in to comment.
You can’t perform that action at this time.