Difference between revisions of "Sandbox2"
Jump to navigation
Jump to search
(Created page with "## Test Test line ### Sub Test Sub test line") |
|||
Line 6: | Line 6: | ||
Sub test line | Sub test line | ||
+ | |||
+ | |||
+ | # Update modified_date column on update | ||
+ | <syntaxhighlight lang="sql"> | ||
+ | CREATE OR REPLACE FUNCTION update_modified_date_column() | ||
+ | RETURNS TRIGGER AS $$ | ||
+ | BEGIN | ||
+ | NEW.modified_date = now(); | ||
+ | RETURN NEW; | ||
+ | END; | ||
+ | $$ language 'plpgsql'; | ||
+ | |||
+ | --or even better but more costly compute if only if content has changed | ||
+ | |||
+ | CREATE OR REPLACE FUNCTION update_modified_date_column() | ||
+ | RETURNS TRIGGER AS $$ | ||
+ | BEGIN | ||
+ | IF row(NEW.*) IS DISTINCT FROM row(OLD.*) THEN | ||
+ | NEW.modified_date = now(); | ||
+ | RETURN NEW; | ||
+ | ELSE | ||
+ | RETURN OLD; | ||
+ | END IF; | ||
+ | END; | ||
+ | $$ language 'plpgsql'; | ||
+ | |||
+ | BEFORE UPDATE ON my_table FOR EACH ROW EXECUTE PROCEDURE update_modified_date_column(); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | <syntaxhighlight lang="Python"> | ||
+ | def test(): | ||
+ | print('test') | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | <source> | ||
+ | def testcodetag(): | ||
+ | print('test' | ||
+ | </source> | ||
+ | |||
+ | <code> | ||
+ | def testcodetag(): | ||
+ | print('test' | ||
+ | </code> | ||
+ | |||
+ | To manually overwrite a file while {{ic|noclobber}} is set: | ||
+ | |||
+ | <pre style="color: silver; background: black;"> | ||
+ | $ echo "output" >| file.txt | ||
+ | </pre> |
Latest revision as of 01:10, 27 July 2019
Test
Test line
Sub Test
Sub test line
Update modified_date column on update
NEW.modified_date = now(); RETURN NEW;
END; $$ language 'plpgsql';
--or even better but more costly compute if only if content has changed
CREATE OR REPLACE FUNCTION update_modified_date_column() RETURNS TRIGGER AS $$ BEGIN
IF row(NEW.) IS DISTINCT FROM row(OLD.) THEN NEW.modified_date = now(); RETURN NEW; ELSE RETURN OLD; END IF;
END; $$ language 'plpgsql';
BEFORE UPDATE ON my_table FOR EACH ROW EXECUTE PROCEDURE update_modified_date_column();
print('test')
def testcodetag():
print('test'
def testcodetag():
print('test'
To manually overwrite a file while Template:Ic is set:
$ echo "output" >| file.txt