/** INTERNAL: Return the create table statement. */
 public Writer buildCreationWriter(AbstractSession session, Writer writer)
     throws ValidationException {
   try {
     DatabasePlatform platform = session.getPlatform();
     writer.write("CREATE PACKAGE " + getFullName());
     writer.write(" AS");
     writer.write("\n");
     for (Enumeration statementsEnum = getStatements().elements();
         statementsEnum.hasMoreElements(); ) {
       writer.write((String) statementsEnum.nextElement());
       writer.write(platform.getBatchDelimiterString());
       writer.write("\n");
     }
     for (Enumeration proceduresEnum = getProcedures().elements();
         proceduresEnum.hasMoreElements(); ) {
       writer.write("\n");
       String procedureString =
           ((StoredProcedureDefinition) proceduresEnum.nextElement())
               .buildCreationWriter(session, writer)
               .toString();
       writer.write(procedureString.substring(7, procedureString.length()));
       writer.write("\n");
     }
     writer.write(platform.getBatchEndString());
     writer.write("\n" + session.getPlatform().getStoredProcedureTerminationToken());
   } catch (IOException ioException) {
     throw ValidationException.fileError(ioException);
   }
   return writer;
 }
Exemplo n.º 2
0
 /**
  * If using native SQL then print a byte[] literally as a hex string otherwise use ODBC format as
  * provided in DatabasePlatform.
  */
 protected void appendByteArray(byte[] bytes, Writer writer) throws IOException {
   if (usesNativeSQL()) {
     writer.write("Ox");
     Helper.writeHexString(bytes, writer);
   } else {
     super.appendByteArray(bytes, writer);
   }
 }
Exemplo n.º 3
0
 /**
  * Appends an MySQL specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format.
  * Native Format: 'YYYY-MM-DD HH:MM:SS'
  */
 protected void appendCalendar(Calendar calendar, Writer writer) throws IOException {
   if (usesNativeSQL()) {
     writer.write("TIMESTAMP '");
     writer.write(Helper.printCalendarWithoutNanos(calendar));
     writer.write("'");
   } else {
     super.appendCalendar(calendar, writer);
   }
 }
Exemplo n.º 4
0
 /**
  * Appends an MySQL specific Timestamp, if usesNativeSQL is true otherwise use the ODBC format.
  * Native Format: 'YYYY-MM-DD HH:MM:SS'
  */
 protected void appendTimestamp(java.sql.Timestamp timestamp, Writer writer) throws IOException {
   if (usesNativeSQL()) {
     writer.write("TIMESTAMP '");
     writer.write(Helper.printTimestampWithoutNanos(timestamp));
     writer.write("'");
   } else {
     super.appendTimestamp(timestamp, writer);
   }
 }
Exemplo n.º 5
0
 /**
  * Appends an MySQL specific time if usesNativeSQL is true otherwise use the ODBC format. Native
  * FORMAT: 'HH:MM:SS'.
  */
 protected void appendTime(java.sql.Time time, Writer writer) throws IOException {
   if (usesNativeSQL()) {
     writer.write("TIME '");
     writer.write(Helper.printTime(time));
     writer.write("'");
   } else {
     super.appendTime(time, writer);
   }
 }
Exemplo n.º 6
0
 /**
  * Appends an MySQL specific date if usesNativeSQL is true otherwise use the ODBC format. Native
  * FORMAT: 'YYYY-MM-DD'
  */
 protected void appendDate(java.sql.Date date, Writer writer) throws IOException {
   if (usesNativeSQL()) {
     writer.write("DATE '");
     writer.write(Helper.printDate(date));
     writer.write("'");
   } else {
     super.appendDate(date, writer);
   }
 }
Exemplo n.º 7
0
 /** Initialize any platform-specific operators */
 protected void initializePlatformOperators() {
   super.initializePlatformOperators();
   addOperator(ExpressionOperator.simpleTwoArgumentFunction(ExpressionOperator.Concat, "CONCAT"));
   addOperator(operatorOuterJoin());
   addOperator(ExpressionOperator.ifNull());
 }