001 /*
002 * Copyright (c) 2009 The openGion Project.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013 * either express or implied. See the License for the specific language
014 * governing permissions and limitations under the License.
015 */
016 package org.opengion.plugin.table;
017
018 /**
019 * TableFilter_SEQUENCE_SQLSERVER は、TableUpda インターフェースを継承した、DBTableModel 処?の
020 * 実?ラスです?
021 *
022 * ここでは、シーケンス?の検索結果より、GF09 のシーケンス定義??ブルから
023 * ?な??を取得し、シーケンス作?スクリプトを作?します?
024 *
025 * こ?処?実行するには、DBTableModelのカラ?して?
026 * SEQNAME,INCREBY,STARTVAL,MINVAL,MAXVAL,FGCYCLE,SUCACHE
027 * が?です?
028 *
029 * ※SQLServerに対して生?されるスクリプトでは、INCREBY,MINVAL,MAXVAL,FGCYCLE,SUCACHEは無視されます?
030 * なお?SQLServerではシーケンスはサポ?トされて??め?シーケンス名と同じ名前のシーケンス採番??ブルを生成し?
031 * これ?ずつ?してア????トすることで、シーケンスをエミュレートします?(こ?実??未?トで?
032 *
033 * @og.rev 5.1.9.0 (2010/08/01) DB定義DB・シーケンス定義追?
034 * @version 0.9.0 2010/08/01
035 * @author Hiroki Nakamura
036 * @since JDK1.1,
037 */
038 public class TableFilter_SEQUENCE_SQLSERVER extends TableFilter_SEQUENCE {
039 //* こ?プログラ??VERSION??を設定します? {@value} */
040 private static final String VERSION = "5.1.9.0 (2010/08/01)" ;
041
042 /**
043 * シーケンス作?の処?実行します?
044 *
045 * @param clmNo カラ?号配?
046 * @param data ?行?の??タ配?
047 *
048 * @return シーケンス作?
049 */
050 @Override
051 protected String makeLineList( final int[] clmNo,final String[] data ) {
052 StringBuilder buf = new StringBuilder();
053
054 if( isXml ) { buf.append( EXEC_START_TAG ).append( CR ); }
055 buf.append( "CREATE TABLE " ).append( data[clmNo[SEQNAME]] ).append( CR );
056 buf.append( " (SEQID INT NOT NULL)" );
057 // buf.append( "(SEQID INT NOT NULL)" ).append( CR );
058 if( isXml ) { buf.append( CR ).append( EXEC_END_TAG ); }
059 else { buf.append( " ;" ); }
060
061 buf.append( CR ).append( CR );
062
063 if( isXml ) { buf.append( EXEC_START_TAG ).append( CR ); }
064 // buf.append( "INSERT INTO " ).append( data[clmNo[SEQNAME]] ).append( CR );
065 int startVal = Integer.valueOf( data[clmNo[STARTVAL]] );
066 if( startVal < 0 ) { startVal = 0; }
067 buf.append( "INSERT INTO " ).append( data[clmNo[SEQNAME]] );
068 buf.append( " VALUES (" ).append( startVal ).append( ")" );
069 if( isXml ) { buf.append( CR ).append( EXEC_END_TAG ); }
070 else { buf.append( " ;" ); }
071
072 // buf.append( CR );
073
074 return buf.toString();
075 }
076 }