From 8dbe44576454acc44b2ef5ee769aa4bdf487cd79 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 3 Oct 2012 16:24:52 -0400 Subject: [PATCH] start work on a function for creating staff users in bulk Signed-off-by: Galen Charlton --- sql/base/base.sql | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/sql/base/base.sql b/sql/base/base.sql index 16e6b3a..b033fe1 100644 --- a/sql/base/base.sql +++ b/sql/base/base.sql @@ -1873,3 +1873,22 @@ The third argument is the indicator position, either 1 or 2. The fourth argument is the character to set the indicator value to. All occurences of the specified field will be changed. The function returns the revised MARCXML string.$$; + +CREATE OR REPLACE FUNCTION migration_tools.create_staff_user( + username TEXT, + password TEXT, + org TEXT, + perm_group TEXT, + first_name TEXT DEFAULT '', + last_name TEXT DEFAULT '' +) RETURNS VOID AS $func$ +BEGIN + RAISE NOTICE '%', org ; + INSERT INTO actor.usr (usrname, passwd, ident_type, first_given_name, family_name, home_ou, profile) + SELECT username, password, 1, first_name, last_name, aou.id, pgt.id + FROM actor.org_unit aou, permission.grp_tree pgt + WHERE aou.shortname = org + AND pgt.name = perm_group; +END +$func$ +LANGUAGE PLPGSQL; -- 1.7.2.5