source: trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/GS3SQLInsert.java@ 7305

Last change on this file since 7305 was 6739, checked in by cs025, 20 years ago

Added date support.

  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 KB
Line 
1package org.greenstone.gsdl3.gs3build.database;
2
3public class GS3SQLInsert extends GS3SQLAction
4 { public GS3SQLInsert(String table)
5 { super(table);
6 }
7
8 public String toString()
9 {
10 StringBuffer reply = new StringBuffer();
11 reply.append("INSERT INTO ");
12 reply.append(this.table);
13 reply.append(" ");
14 if (this.values.size() >= 1)
15 reply.append("(");
16 for (int i = 0; i < this.values.size(); i ++)
17 { GS3SQLValue value = (GS3SQLValue) this.values.get(i);
18 if (i > 0)
19 reply.append(", ");
20 reply.append(value.field);
21 }
22 if (this.values.size() >= 1)
23 reply.append(")");
24 reply.append(" VALUES ");
25 if (this.values.size() >= 1)
26 reply.append("(");
27 for (int i = 0; i < this.values.size(); i ++)
28 { GS3SQLValue value = (GS3SQLValue) this.values.get(i);
29 if (i > 0)
30 reply.append(", ");
31 if (value.getType() == null ||
32 value.getType().equals(GS3SQLField.DATETIME_TYPE) ||
33 value.getType().equals(GS3SQLField.VARCHAR_TYPE))
34 {
35 reply.append("\"");
36 }
37 reply.append(value.value);
38 if (value.getType() == null ||
39 value.getType().equals(GS3SQLField.DATETIME_TYPE) ||
40 value.getType().equals(GS3SQLField.VARCHAR_TYPE))
41 {
42 reply.append("\"");
43 }
44 }
45 if (this.values.size() >= 1)
46 reply.append(")");
47 reply.append(";");
48 return reply.toString();
49 }
50 }
51
52
53
54
Note: See TracBrowser for help on using the repository browser.