Обсуждение: error with "select from tg_relname"

Поиск
Список
Период
Сортировка

error with "select from tg_relname"

От
Sebastien Caille
Дата:
Hello,

I'm trying to write a generic function for some triggers (full code @
end of mail)
It works fine with

    "select uid into same_login
    from USR
    where login = new.login;"

but when I try to do something like

    "select uid into same_login
    from TG_RELNAME
    where login = new.login;",

the function die with " ERROR:  parser: parse error at or near "$1" "

Did I miss something ?
(egh... I hope so... :) )

tia
(please CC me since I'm not on the list)

--

drop function uniq_login();
drop trigger check_uniq_login on usr;


create function uniq_login ()
returns opaque as '
declare
    same_login integer;
    tab varchar;
begin

    select uid into same_login
    from tg_relname
    where login = new.login;

    if same_login notnull then
        raise exception ''Login already used'';
    end if;

    return new;
end;
' language 'plpgsql';


create trigger check_uniq_login
before insert or update
on usr for each row
execute procedure uniq_login();