From: Jean Louis <bugs@gnu.support>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: exported contacts problem
Date: Sun, 4 Aug 2019 00:12:34 +0200 [thread overview]
Message-ID: <20190803221234.GD23820@protected.rcdrun.com> (raw)
In-Reply-To: <87pnlmvssp.fsf@ericabrahamsen.net>
* Eric Abrahamsen <eric@ericabrahamsen.net> [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';
*/
}
);")
next prev parent reply other threads:[~2019-08-03 22:12 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-02 15:47 exported contacts problem Jude DaShiell
2019-08-02 16:00 ` Jean Louis
2019-08-02 16:02 ` Jean Louis
2019-08-02 16:06 ` Jude DaShiell
2019-08-02 21:09 ` Eric Abrahamsen
2019-08-02 21:34 ` Jean Louis
2019-08-03 0:26 ` Eric Abrahamsen
2019-08-03 10:33 ` Jean Louis
2019-08-03 15:38 ` Eric Abrahamsen
2019-08-03 16:32 ` Jean Louis
2019-08-03 17:48 ` Neil Jerram
2019-08-03 18:25 ` Jean Louis
2019-08-03 21:32 ` Eric Abrahamsen
2019-08-03 22:12 ` Jean Louis [this message]
2019-08-04 1:28 ` Tim Cross
2019-08-13 22:24 ` David Masterson
2019-08-14 20:38 ` Eric Abrahamsen
2019-08-16 0:07 ` David Masterson
2019-08-03 10:48 ` Jean Louis
2019-08-02 22:19 ` John Kitchin
2019-08-02 20:33 ` Tim Cross
2019-08-02 20:57 ` Jude DaShiell
2019-08-02 21:25 ` Tim Cross
2019-08-02 21:39 ` Jean Louis
2019-08-02 22:07 ` Tim Cross
2019-08-03 8:25 ` Jean Louis
2019-08-02 21:00 ` Jean Louis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190803221234.GD23820@protected.rcdrun.com \
--to=bugs@gnu.support \
--cc=emacs-orgmode@gnu.org \
--cc=eric@ericabrahamsen.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).