Revision 2606
Added by Aaron Marcuse-Kubitza over 12 years ago
schemas/functions.sql | ||
---|---|---|
34 | 34 |
|
35 | 35 |
|
36 | 36 |
-- |
37 |
-- Name: _label(); Type: FUNCTION; Schema: functions; Owner: - |
|
38 |
-- |
|
39 |
|
|
40 |
CREATE FUNCTION _label() RETURNS trigger |
|
41 |
LANGUAGE plpgsql IMMUTABLE |
|
42 |
AS $$ |
|
43 |
BEGIN |
|
44 |
new.result := (SELECT new.label+': '+new.value); |
|
45 |
RETURN new; |
|
46 |
END; |
|
47 |
$$; |
|
48 |
|
|
49 |
|
|
50 |
-- |
|
37 | 51 |
-- Name: _merge(); Type: FUNCTION; Schema: functions; Owner: - |
38 | 52 |
-- |
39 | 53 |
|
... | ... | |
198 | 212 |
|
199 | 213 |
|
200 | 214 |
-- |
215 |
-- Name: _label; Type: TABLE; Schema: functions; Owner: -; Tablespace: |
|
216 |
-- |
|
217 |
|
|
218 |
CREATE TABLE _label ( |
|
219 |
result text, |
|
220 |
not_null_col boolean DEFAULT true NOT NULL, |
|
221 |
label text, |
|
222 |
value text |
|
223 |
); |
|
224 |
|
|
225 |
|
|
226 |
-- |
|
201 | 227 |
-- Name: _merge; Type: TABLE; Schema: functions; Owner: -; Tablespace: |
202 | 228 |
-- |
203 | 229 |
|
... | ... | |
225 | 251 |
|
226 | 252 |
|
227 | 253 |
-- |
254 |
-- Name: _label_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace: |
|
255 |
-- |
|
256 |
|
|
257 |
CREATE UNIQUE INDEX _label_unique ON _label USING btree (ensure_not_null(label), ensure_not_null(value)); |
|
258 |
|
|
259 |
|
|
260 |
-- |
|
228 | 261 |
-- Name: _merge_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace: |
229 | 262 |
-- |
230 | 263 |
|
... | ... | |
239 | 272 |
|
240 | 273 |
|
241 | 274 |
-- |
275 |
-- Name: _label; Type: TRIGGER; Schema: functions; Owner: - |
|
276 |
-- |
|
277 |
|
|
278 |
CREATE TRIGGER _label BEFORE INSERT OR UPDATE ON _label FOR EACH ROW EXECUTE PROCEDURE _label(); |
|
279 |
|
|
280 |
|
|
281 |
-- |
|
242 | 282 |
-- Name: _merge; Type: TRIGGER; Schema: functions; Owner: - |
243 | 283 |
-- |
244 | 284 |
|
Also available in: Unified diff
schemas/functions.sql: Added _label relational function