...
1# about
2
3<div class="html">HTML</div>
4
5Multiple **bold** on the **same line**.
6
7Multiple _italic_ on the *same_line*.
8
9## user defined function in cql
10
11```javascript
12 column.substring(0,num)
13```
14
15```cql
16CREATE FUNCTION IF NOT EXISTS cycling.left (column TEXT,num int)
17RETURNS NULL ON NULL INPUT
18RETURNS text
19LANGUAGE javascript AS $$
20 column.substring(0,num)
21$$;
22
23CREATE OR REPLACE FUNCTION cycling.fLog (input double)
24CALLED ON NULL INPUT
25RETURNS double LANGUAGE java AS
26'return Double.valueOf(Math.log(input.doubleValue()));';
27```
28
29```postgres
30DROP TABLE IF EXISTS emp CASCADE;
31
32CREATE TABLE emp (
33 empname text,
34 salary integer,
35 last_date timestamp,
36 last_user text
37);
38
39select
40 $my_tag$aoeuaoeu$my_tag$ as blah
41;
42
43CREATE OR REPLACE FUNCTION emp_stamp() RETURNS trigger AS $emp_stamp$
44BEGIN
45 -- Check that empname and salary are given
46 IF NEW.empname IS NULL THEN
47 RAISE EXCEPTION 'empname cannot be null';
48 END IF;
49 IF NEW.salary IS NULL THEN
50 RAISE EXCEPTION '% cannot have null salary', NEW.empname;
51 END IF;
52
53 -- Who works for us when she must pay for it?
54 IF NEW.salary < 0 THEN
55 RAISE EXCEPTION '% cannot have a negative salary', NEW.empname;
56 END IF;
57
58 -- Remember who changed the payroll when
59 NEW.last_date := current_timestamp;
60 NEW.last_user := current_user;
61 RETURN NEW;
62END;
63$emp_stamp$ LANGUAGE plpgsql;
64
65CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp
66 FOR EACH ROW EXECUTE PROCEDURE emp_stamp();
67
68DO language plpgsql $$
69declare r record;
70begin
71 for r in select * from books
72loop
73 execute 'select ''' || r.title || '''';
74end loop;
75end
76$$;
77
78DO $$
79declare r record;
80begin
81 for r in select * from books
82loop
83 execute 'select ''' || r.title || '''';
84end loop;
85end
86$$;
87```
View as plain text