1 /*
2 * $Id: MicrosoftSqlWriter.java,v 1.3 2005/03/21 18:45:55 mch Exp $
3 *
4 * (C) Copyright Astrogrid...
5 */
6
7 package org.astrogrid.tableserver.jdbc.sqlserver;
8
9 import org.astrogrid.query.QueryException;
10 import org.astrogrid.tableserver.jdbc.StdSqlWriter;
11
12
13 /***
14 * For writing out Querys as Microsoft SQL-server statment strings
15 */
16
17 public class MicrosoftSqlWriter extends StdSqlWriter
18 {
19
20 /*** Adds 'top' if appropriate, just after SELECT and before anything else */
21 public void visitLimit(long limit) {
22 if (limit>0) {
23 // String newSql = select.toString();
24 // int selectIdx = newSql.indexOf("SELECT ");
25 // if (selectIdx == -1) {
26 // throw new QueryException("No SELECT found while adding TOP");
27 // }
28 // newSql = newSql.substring(0,selectIdx+7)+" TOP "+limit+" "+newSql.substring(selectIdx+7);
29 //
30 // select = new StringBuffer(newSql);
31 select.insert(0, " TOP "+limit+" ");
32 }
33 }
34
35 }
36
37 /*
38 $Log: MicrosoftSqlWriter.java,v $
39 Revision 1.3 2005/03/21 18:45:55 mch
40 Naughty big lump of changes
41
42 Revision 1.2 2005/03/10 22:39:17 mch
43 Fixed tests more metadata fixes
44
45 Revision 1.1 2005/03/10 16:42:55 mch
46 Split fits, sql and xdb
47
48 Revision 1.1.1.1 2005/02/17 18:37:35 mch
49 Initial checkin
50
51 Revision 1.1 2005/02/17 18:17:46 mch
52 Moved SqlWriters back into server as they need metadata information
53
54 Revision 1.1.1.1 2005/02/16 17:11:23 mch
55 Initial checkin
56
57 Revision 1.1.2.1 2004/12/08 23:23:37 mch
58 Made SqlWriter and AdqlWriter implement QueryVisitor
59
60 Revision 1.1.2.1 2004/12/08 18:36:40 mch
61 Added Vizier, rationalised SqlWriters etc, separated out TableResults from QueryResults
62
63
64 */
65
66
67
68
69