From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean Louis Subject: Re: exported contacts problem Date: Sun, 4 Aug 2019 00:12:34 +0200 Message-ID: <20190803221234.GD23820@protected.rcdrun.com> References: <20190802160236.GR17561@protected.rcdrun.com> <87mugrb7fi.fsf@ericabrahamsen.net> <20190802213421.GZ17561@protected.rcdrun.com> <875znfaycd.fsf@ericabrahamsen.net> <20190803103340.GN23820@protected.rcdrun.com> <874l2yxnrs.fsf@ericabrahamsen.net> <20190803163219.GZ23820@protected.rcdrun.com> <87pnlmvssp.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:33138) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hu2GY-0003M9-AU for emacs-orgmode@gnu.org; Sat, 03 Aug 2019 18:12:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hu2GX-00070h-74 for emacs-orgmode@gnu.org; Sat, 03 Aug 2019 18:12:42 -0400 Received: from stw1.rcdrun.com ([217.170.207.13]:45925) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hu2GW-00070D-Vi for emacs-orgmode@gnu.org; Sat, 03 Aug 2019 18:12:41 -0400 Content-Disposition: inline In-Reply-To: <87pnlmvssp.fsf@ericabrahamsen.net> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Eric Abrahamsen Cc: emacs-orgmode@gnu.org * Eric Abrahamsen [2019-08-03 23:33]: > time I'm actually starting to feel comfortable with sql. I am using skeleton to quickly create SQL definitions. Now imagine `contacts', `accounts', `countries', etc. It works fast. (define-skeleton cf-sql-table "Prepare the SQL table for Central Files database design" nil " -- ------------------------------------------ -- ------------ Table " (setq table (skeleton-read "Table name: ")) " -- ------------------------------------------ DROP SEQUENCE " table "_id_seq; CREATE TABLE " table " ( " table "_id SERIAL NOT NULL PRIMARY KEY, " table "_datecreated TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, " table "_datemodified TIMESTAMP, " table "_usercreated TEXT NOT NULL DEFAULT current_user, " table "_usermodified TEXT NOT NULL DEFAULT current_user, " table "_name TEXT, " table "_title TEXT, " table "_description TEXT, " table "_ TEXT ); GRANT ALL ON " table " TO PUBLIC; DROP VIEW " table "_combo; CREATE OR REPLACE VIEW " table "_combo AS SELECT " table "_id AS id, " table "_name AS TEXT FROM " table "; GRANT SELECT ON " table "_combo TO PUBLIC; COMMENT ON TABLE " table " IS '" (capitalize table) "'; COMMENT ON COLUMN " table "." table "_id IS 'ID'; COMMENT ON COLUMN " table "." table "_datecreated IS 'Date created'; COMMENT ON COLUMN " table "." table "_datemodified IS 'Date modified'; COMMENT ON COLUMN " table "." table "_usercreated IS 'User created'; COMMENT ON COLUMN " table "." table "_usermodified IS 'User modified'; COMMENT ON COLUMN " table "." table "_hid IS 'HID'; COMMENT ON COLUMN " table "." table "_name IS 'Name'; COMMENT ON COLUMN " table "." table "_title IS 'Title'; COMMENT ON COLUMN " table "." table "_description IS 'Description'; COMMENT ON COLUMN " table "." table "_IS ''; CREATE UNIQUE INDEX " table "_index ON " table " ( " table "_weekend ); INSERT INTO meta_fields VALUES ('" table "','" table "_description','widget','area(rows=10,cols=60)'); INSERT INTO meta_fields VALUES ('" table "','" table "_datecreated','widget','readonly'); INSERT INTO meta_fields VALUES ('" table "','" table "_datemodified','widget','readonly'); INSERT INTO meta_fields VALUES ('" table "','" table "_usercreated','widget','readonly'); INSERT INTO meta_fields VALUES ('" table "','" table "_usermodified','widget','readonly'); INSERT INTO meta_fields VALUES ('" table "','" table "_','hide_list','1'); -- INSERT INTO " table " (" table "_name) VALUES (''); -- INSERT INTO meta_tables VALUES ('" table "', 'hide', '1'); -- Triggers -- For Date Modified CREATE TRIGGER " table "_moddatetime BEFORE UPDATE ON " table " FOR EACH ROW EXECUTE PROCEDURE moddatetime(" table "_datemodified); -- For User Modified CREATE TRIGGER insert_username_" table " BEFORE INSERT OR UPDATE ON " table " FOR EACH ROW EXECUTE PROCEDURE insert_username(" table "_usermodified); -- List view /* DROP VIEW " table "_list; CREATE OR REPLACE VIEW " table "_list AS SELECT " table "_id, " table "_name FROM " table " ORDER BY " table "_id DESC; COMMENT ON VIEW " table "_list IS '" (capitalize table) "'; COMMENT ON COLUMN " table "_list." table "_id IS 'ID'; COMMENT ON COLUMN " table "_list." table "_name IS 'Name'; */ } );")