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