/*ALIAS>prop_db*/

/*SQLStart>2755*/
CREATE OR ALTER procedure ADD_USER (
    U_ID smallint,
    U_RNM varchar(72))
as
declare variable RES smallint;
BEGIN
  select User_id from Users
  where User_id = :U_id
  into :res;
  
  if (:res is Null) then
    begin
      insert into Users (User_id, User_str, user_active)
      values (:U_Id,:U_RNM, 1);
    end
  else
    begin
      update Users set  User_STR = :U_RNM, user_active = 1
      where User_id = :U_ID ;
    end
END
/*SQLStop*/

/*SQLStart>2756*/
CREATE OR ALTER procedure AEUM_USER_UPDATE (
    ID integer,
    APPNAME varchar(100),
    USERNAME varchar(300),
    TITLE varchar(300),
    FIRST_NAME varchar(300),
    MIDDLE_NAME varchar(300),
    LAST_NAME varchar(300),
    PID varchar(300),
    POSITION_TEXT varchar(300))
as
declare variable RES integer;
begin
  select u1.user_id from users u1
  where u1.user_id = :id
  into :res;
  
  if (:res is Null) then
    begin
      insert into users (user_id, user_str, user_name, user_active)
      values (:id,atrimex(:first_name || " " || :middle_name || " " || :last_name), :username, 1);
    end
  else
    begin
      update users u2 set
        u2.user_str=atrimex(:first_name || " " || :middle_name || " " || :last_name),
        u2.user_name=:username,
        u2.user_active=1
      where u2.user_id = :id;
    end
end
/*SQLStop*/

/*SQLStart>2757*/
update system_strings set sys_str = '6.7.229.1' where sys_id = 1401;  /*BackOffice*/
/*SQLStop*/
