/[eiffelstudio]/branches/eth/eve/Src/library/abel/libraries/ethz/src/abel/backends/generic_database_layout/ps_sqlite_strings.e
ViewVC logotype

Contents of /branches/eth/eve/Src/library/abel/libraries/ethz/src/abel/backends/generic_database_layout/ps_sqlite_strings.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 88969 - (show annotations)
Fri Jun 22 11:53:00 2012 UTC (7 years, 3 months ago) by romanschmocker
File size: 2259 byte(s)
Changed structure in the ABEL library repository - e.g. pre-built backends are now collected in their own cluster
1 note
2 description: "The SQLite specific SQL statements for the generic layout mapping strategy."
3 author: "Roman Schmocker"
4 date: "$Date$"
5 revision: "$Revision$"
6
7 class
8 PS_SQLITE_STRINGS
9
10 inherit
11 PS_GENERIC_LAYOUT_SQL_STRINGS
12
13 feature {PS_GENERIC_LAYOUT_KEY_MANAGER} -- Table creation
14
15
16 Create_value_table: STRING
17 do
18 Result:= "[
19 CREATE TABLE ps_value (
20 objectid INTEGER,
21 attributeid INTEGER,
22 runtimetype INTEGER,
23 value VARCHAR(128),
24
25 PRIMARY KEY (objectid ASC, attributeid),
26 FOREIGN KEY (attributeid) REFERENCES ps_attribute (attributeid) ON DELETE CASCADE,
27 FOREIGN KEY (runtimetype) REFERENCES ps_class (classid) ON DELETE CASCADE
28 )
29 ]"
30 end
31
32
33 Create_class_table: STRING
34 do
35 Result:= "[
36
37 CREATE TABLE ps_class (
38 classid INTEGER PRIMARY KEY AUTOINCREMENT,
39 classname VARCHAR(64)
40 )
41 ]"
42 end
43
44 Create_attribute_table: STRING
45 do
46 Result:= "[
47 CREATE TABLE ps_attribute (
48 attributeid INTEGER PRIMARY KEY AUTOINCREMENT,
49 name VARCHAR(128),
50 class INTEGER,
51
52 FOREIGN KEY (class) REFERENCES ps_class (classid) ON DELETE CASCADE
53 )
54 ]"
55 end
56
57 feature {PS_GENERIC_LAYOUT_KEY_MANAGER} -- Data querying - Key manager
58
59
60 Show_tables: STRING = "SELECT name FROM sqlite_master WHERE type = 'table'"
61
62
63 feature {PS_GENERIC_LAYOUT_KEY_MANAGER} -- Data modification - Key manager
64
65 Insert_class_use_autoincrement (class_name:STRING):STRING
66 do
67 Result:="INSERT INTO ps_class ( classname) VALUES ( '" + class_name + "')"
68 end
69
70 Insert_attribute_use_autoincrement (attribute_name:STRING; class_key:INTEGER):STRING
71 do
72 Result:= "INSERT INTO ps_attribute (attributeid, name, class) VALUES (NULL, '" + attribute_name + "', " + class_key.out + ")"
73 end
74
75
76 feature {PS_GENERIC_LAYOUT_SQL_BACKEND} -- Data modification - Backend
77
78 Insert_value_use_autoincrement (attribute_id, runtimetype:INTEGER; value: STRING): STRING
79 do
80 Result:= "INSERT INTO ps_value (objectid, attributeid, runtimetype, value) VALUES ( (SELECT CASE WHEN MAX(objectid) IS NULL THEN 1 ELSE (MAX(objectid) + 1) END FROM ps_value) ," + attribute_id.out + ", " + runtimetype.out + ", '" + value + "')"
81 end
82
83 feature {PS_GENERIC_LAYOUT_SQL_BACKEND}
84
85 For_update_appendix: STRING = ""
86
87
88 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23