error with "select from tg_relname" - Mailing list pgsql-general

From Sebastien Caille
Subject error with "select from tg_relname"
Date
Msg-id 3BE94898.4F06BA85@epfl.ch
Whole thread Raw
List pgsql-general
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();

pgsql-general by date:

Previous
From: "Richard Teviotdale"
Date:
Subject: Re: OID's as Primary Keys
Next
From: Tom Lane
Date:
Subject: Re: pg_dump usage - problems with restore due to the use of tab delimiters