src/main/java/de/cimt/talendcomp/exasol/EXASCDHelper.java
String createTableStatement(String schemaTable, boolean isTarget) {
		if (listSourceFields.isEmpty()) {
			throw new IllegalStateException("Source column list is empty!");
		}
		StringBuilder sb = new StringBuilder();
		sb.append("create table " + schemaTable + " (\n");

		if (isTarget && buildTargetTableWithSk) {
			sb.append(INDENT); // 4
			sb.append(sKeyColumn + " DECIMAL(36,0) IDENTITY" + ",\n");
		}

		if (enabledSCD2Versioning) {
			// create valid time period columns
			sb.append(INDENT); // 4
			sb.append(validTimePeriodStartColumn + " TIMESTAMP");
			if (!isTarget) {
				sb.append(" DEFAULT " + validFromDefaultValue);
			}
			sb.append(",\n" + INDENT); // 4
			sb.append(validTimePeriodEndColumn + " TIMESTAMP");
			sb.append(",\n" + INDENT); // 4
			// create version column
			if (useVersion) {
				sb.append(versionColumn + " DECIMAL(10,0) DEFAULT " + versionStartsWith + ",\n");
			}
			// create currentFlagColumn column
			if (useCurrentFlag) {
				sb.append(currentFlagColumn + " BOOLEAN" + ",\n");
			}
		} else { // SCD 2 disabled
			if (containsSCDType("scd3")) {
				sb.append(timeOfLastSCD3Change + " TIMESTAMP");
				if (!isTarget) {
					sb.append(" DEFAULT " + validFromDefaultValue);
				}
				sb.append(",\n");
			}
		}

		// source columns
		boolean firstLoop = true;
		for (Column col : listSourceFields) {
			if (!col.isNotInSource()) {
				if (firstLoop) {
					firstLoop = false;
				} else {
					sb.append(",\n");
				}
				sb.append(INDENT); // 4
				if (isTarget) {
					sb.append(createColumnCode(col));
				} else {
					sb.append(createColumnCode(col, false));
				}
			} else {
				if (isTarget) {
					if (firstLoop) {
						firstLoop = false;
					} else {
						sb.append(",\n");
					}
					sb.append(INDENT); // 4
					sb.append(createColumnCode(col));
				}
			}
		}
		// add status column for temp-table
		if (!isTarget) {
			while (isColumnInTargetSchema(statusInTempTableColumn)) {
				statusInTempTableColumn = "scd_status_" + ("" + Math.random()).substring(2, 7);
			}
			sb.append(",\n" + statusInTempTableColumn + " VARCHAR(10)" + " DEFAULT ' '");
		}
		// add pk (for scd 2 validTimePeriodStartColumn is included)
		if (isTarget && buildTargetTableWithPk) {
			sb.append(",\nprimary key(" + getCslSourceString(true, false, false, false, false));
			if (enabledSCD2Versioning) {
				sb.append(" ," + validTimePeriodStartColumn);
			}
			sb.append(")");
		}

		// close the field and constraint list
		sb.append("\n)");
		String sql = sb.toString();
		if (debug) {
			if (isTarget) {
				System.out.println("-- create target table");
			} else {
				System.out.println("-- create temp table");
			}
			System.out.println(sql + ";");
		}
		return sql;
	}
/*
	 * parameter isTarget = true if create target table and false for temp table
	 */
parameter isTarget = true if create target table and false for temp table
parameter isTarget = true if create target table and false for temp table
String createTableStatement(String schemaTable, boolean isTarget) {
		if (listSourceFields.isEmpty()) {
			throw new IllegalStateException("Source column list is empty!");
		}
		StringBuilder sb = new StringBuilder();
		sb.append("create table " + schemaTable + " (\n");
		if (isTarget && buildTargetTableWithSk) {
			sb.append(INDENT); 
			sb.append(sKeyColumn + " DECIMAL(36,0) IDENTITY" + ",\n");
		}
		if (enabledSCD2Versioning) {
			sb.append(INDENT); 
			sb.append(validTimePeriodStartColumn + " TIMESTAMP");
			if (!isTarget) {
				sb.append(" DEFAULT " + validFromDefaultValue);
			}
			sb.append(",\n" + INDENT); 
			sb.append(validTimePeriodEndColumn + " TIMESTAMP");
			sb.append(",\n" + INDENT); 
			if (useVersion) {
				sb.append(versionColumn + " DECIMAL(10,0) DEFAULT " + versionStartsWith + ",\n");
			}
			if (useCurrentFlag) {
				sb.append(currentFlagColumn + " BOOLEAN" + ",\n");
			}
		} else { 
			if (containsSCDType("scd3")) {
				sb.append(timeOfLastSCD3Change + " TIMESTAMP");
				if (!isTarget) {
					sb.append(" DEFAULT " + validFromDefaultValue);
				}
				sb.append(",\n");
			}
		}
		boolean firstLoop = true;
		for (Column col : listSourceFields) {
			if (!col.isNotInSource()) {
				if (firstLoop) {
					firstLoop = false;
				} else {
					sb.append(",\n");
				}
				sb.append(INDENT); 
				if (isTarget) {
					sb.append(createColumnCode(col));
				} else {
					sb.append(createColumnCode(col, false));
				}
			} else {
				if (isTarget) {
					if (firstLoop) {
						firstLoop = false;
					} else {
						sb.append(",\n");
					}
					sb.append(INDENT); 
					sb.append(createColumnCode(col));
				}
			}
		}
		if (!isTarget) {
			while (isColumnInTargetSchema(statusInTempTableColumn)) {
				statusInTempTableColumn = "scd_status_" + ("" + Math.random()).substring(2, 7);
			}
			sb.append(",\n" + statusInTempTableColumn + " VARCHAR(10)" + " DEFAULT ' '");
		}
		if (isTarget && buildTargetTableWithPk) {
			sb.append(",\nprimary key(" + getCslSourceString(true, false, false, false, false));
			if (enabledSCD2Versioning) {
				sb.append(" ," + validTimePeriodStartColumn);
			}
			sb.append(")");
		}
		sb.append("\n)");
		String sql = sb.toString();
		if (debug) {
			if (isTarget) {
				System.out.println("-- create target table");
			} else {
				System.out.println("-- create temp table");
			}
			System.out.println(sql + ";");
		}
		return sql;
	}
String createTableStatement ( String schemaTable , boolean isTarget ) { if ( listSourceFields . isEmpty ( ) ) { throw new IllegalStateException ( "Source column list is empty!" ) ; } StringBuilder sb = new StringBuilder ( ) ; sb . append ( "create table " + schemaTable + " (\n" ) ; if ( isTarget && buildTargetTableWithSk ) { sb . append ( INDENT ) ; sb . append ( sKeyColumn + " DECIMAL(36,0) IDENTITY" + ",\n" ) ; } if ( enabledSCD2Versioning ) { sb . append ( INDENT ) ; sb . append ( validTimePeriodStartColumn + " TIMESTAMP" ) ; if ( ! isTarget ) { sb . append ( " DEFAULT " + validFromDefaultValue ) ; } sb . append ( ",\n" + INDENT ) ; sb . append ( validTimePeriodEndColumn + " TIMESTAMP" ) ; sb . append ( ",\n" + INDENT ) ; if ( useVersion ) { sb . append ( versionColumn + " DECIMAL(10,0) DEFAULT " + versionStartsWith + ",\n" ) ; } if ( useCurrentFlag ) { sb . append ( currentFlagColumn + " BOOLEAN" + ",\n" ) ; } } else { if ( containsSCDType ( "scd3" ) ) { sb . append ( timeOfLastSCD3Change + " TIMESTAMP" ) ; if ( ! isTarget ) { sb . append ( " DEFAULT " + validFromDefaultValue ) ; } sb . append ( ",\n" ) ; } } boolean firstLoop = true ; for ( Column col : listSourceFields ) { if ( ! col . isNotInSource ( ) ) { if ( firstLoop ) { firstLoop = false ; } else { sb . append ( ",\n" ) ; } sb . append ( INDENT ) ; if ( isTarget ) { sb . append ( createColumnCode ( col ) ) ; } else { sb . append ( createColumnCode ( col , false ) ) ; } } else { if ( isTarget ) { if ( firstLoop ) { firstLoop = false ; } else { sb . append ( ",\n" ) ; } sb . append ( INDENT ) ; sb . append ( createColumnCode ( col ) ) ; } } } if ( ! isTarget ) { while ( isColumnInTargetSchema ( statusInTempTableColumn ) ) { statusInTempTableColumn = "scd_status_" + ( "" + Math . random ( ) ) . substring ( 2 , 7 ) ; } sb . append ( ",\n" + statusInTempTableColumn + " VARCHAR(10)" + " DEFAULT ' '" ) ; } if ( isTarget && buildTargetTableWithPk ) { sb . append ( ",\nprimary key(" + getCslSourceString ( true , false , false , false , false ) ) ; if ( enabledSCD2Versioning ) { sb . append ( " ," + validTimePeriodStartColumn ) ; } sb . append ( ")" ) ; } sb . append ( "\n)" ) ; String sql = sb . toString ( ) ; if ( debug ) { if ( isTarget ) { System . out . println ( "-- create target table" ) ; } else { System . out . println ( "-- create temp table" ) ; } System . out . println ( sql + ";" ) ; } return sql ; }
parameter isTarget = true if create target table and false for temp table
parameter isTarget = true if create target table and false for temp table
// 4 // create valid time period columns // 4 // 4 // 4 // create version column // create currentFlagColumn column // SCD 2 disabled // source columns // 4 // 4 // add status column for temp-table // add pk (for scd 2 validTimePeriodStartColumn is included) // close the field and constraint list