1 22 23 24 25 package org.xquark.extractor.microsoft.sql; 26 27 28 import org.xquark.extractor.sql.Context; 29 import org.xquark.extractor.sql.SqlExpression; 30 31 public class SfSubString extends org.xquark.extractor.sql.SfSubString 32 { 33 34 private static final String RCSRevision = "$Revision: 1.4 $"; 35 private static final String RCSName = "$Name: $"; 36 37 38 public SfSubString() 39 { 40 super(); 41 } 42 43 public SfSubString(SqlExpression arg0, SqlExpression arg1) 44 { 45 super(arg0, arg1); 46 } 47 48 public SfSubString(SqlExpression arg0, SqlExpression arg1, SqlExpression arg2) 49 { 50 super(arg0, arg1, arg2); 51 } 52 53 public String toSql (Context context) 54 { 55 57 58 StringBuffer retVal = new StringBuffer (); 59 String arg0 = null; 60 String arg1 = null; 61 String arg2 = null; 62 63 retVal.append("SUBSTRING("); 64 arg0 = getArgument(0).toSql(context); 65 retVal.append(arg0); 66 int num = getArgumentNumber(); 67 68 arg1 = getArgument(1).toSql(context); 69 retVal.append(","); 70 retVal.append(arg1); 71 72 if ( 2 < num){ 73 retVal.append(","); 74 arg2 = getArgument(2).toSql(context); 75 retVal.append(arg2); 76 } 77 else { 78 retVal.append(","); 79 retVal.append("LEN("); 80 retVal.append(arg0); 81 retVal.append(")"); 82 87 } 88 retVal.append(")"); 89 90 return retVal.toString(); 92 } 93 } 94 | Popular Tags |