Project

General

Profile

« Previous | Next » 

Revision 2596

schemas/functions.sql: Added _merge relational function

View differences:

schemas/functions.sql
34 34

  
35 35

  
36 36
--
37
-- Name: _merge(); Type: FUNCTION; Schema: functions; Owner: -
38
--
39

  
40
CREATE FUNCTION _merge() RETURNS trigger
41
    LANGUAGE plpgsql IMMUTABLE
42
    AS $$
43
BEGIN
44
    new.result := (
45
        SELECT DISTINCT functions.join_strs('; ', value)
46
        FROM
47
        (VALUES (new."0"), (new."1"), (new."2"), (new."3"), (new."4"),
48
            (new."5"), (new."6"), (new."7"), (new."8"), (new."9"))
49
        AS v (value)
50
    );
51
    RETURN new;
52
END;
53
$$;
54

  
55

  
56
--
37 57
-- Name: boolean(text); Type: FUNCTION; Schema: functions; Owner: -
38 58
--
39 59

  
......
155 175

  
156 176

  
157 177
--
178
-- Name: _merge; Type: TABLE; Schema: functions; Owner: -; Tablespace: 
179
--
180

  
181
CREATE TABLE _merge (
182
    result text,
183
    not_null_col boolean DEFAULT true NOT NULL,
184
    "0" text,
185
    "1" text,
186
    "2" text,
187
    "3" text,
188
    "4" text,
189
    "5" text,
190
    "6" text,
191
    "7" text,
192
    "8" text,
193
    "9" text
194
);
195

  
196

  
197
--
158 198
-- Name: _alt_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
159 199
--
160 200

  
......
162 202

  
163 203

  
164 204
--
205
-- Name: _merge_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
206
--
207

  
208
CREATE UNIQUE INDEX _merge_unique ON _merge USING btree (ensure_not_null("0"), ensure_not_null("1"), ensure_not_null("2"), ensure_not_null("3"), ensure_not_null("4"), ensure_not_null("5"), ensure_not_null("6"), ensure_not_null("7"), ensure_not_null("8"), ensure_not_null("9"));
209

  
210

  
211
--
165 212
-- Name: _alt; Type: TRIGGER; Schema: functions; Owner: -
166 213
--
167 214

  
......
169 216

  
170 217

  
171 218
--
219
-- Name: _merge; Type: TRIGGER; Schema: functions; Owner: -
220
--
221

  
222
CREATE TRIGGER _merge BEFORE INSERT OR UPDATE ON _merge FOR EACH ROW EXECUTE PROCEDURE _merge();
223

  
224

  
225
--
172 226
-- PostgreSQL database dump complete
173 227
--
174 228

  

Also available in: Unified diff