File: insert_username.example

package info (click to toggle)
postgresql 6.3.2-8
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 19,388 kB
  • ctags: 15,077
  • sloc: ansic: 158,988; sh: 5,379; java: 5,143; yacc: 4,891; tcl: 4,170; sql: 4,120; makefile: 2,615; lex: 906; cpp: 839; python: 836; perl: 678; asm: 70; csh: 5; sed: 2
file content (21 lines) | stat: -rw-r--r-- 562 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
DROP TABLE username_test;

CREATE TABLE username_test (
	name		text,
	username	text not null
);

CREATE TRIGGER insert_usernames
	BEFORE INSERT OR UPDATE ON username_test
	FOR EACH ROW 
	EXECUTE PROCEDURE insert_username (username);

INSERT INTO username_test VALUES ('nothing');
INSERT INTO username_test VALUES ('null', null);
INSERT INTO username_test VALUES ('empty string', '');
INSERT INTO username_test VALUES ('space', ' ');
INSERT INTO username_test VALUES ('tab', '	');
INSERT INTO username_test VALUES ('name', 'name');

SELECT * FROM username_test;