X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=sql%2Fbase%2Fbase.sql;h=b033fe11d9c93b04ad68830db2bc969aa38c1519;hp=16e6b3abfb72e45c767b733ede9776b00a30fdaa;hb=8dbe44576454acc44b2ef5ee769aa4bdf487cd79;hpb=a220c56b038fc03e95ba7e5242931cb621cc6ee3 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;