Re: Escaping text / hstore - Mailing list pgsql-general

From pinker
Subject Re: Escaping text / hstore
Date
Msg-id 1445354323182-5870762.post@n5.nabble.com
Whole thread Raw
In response to Re: Escaping text / hstore  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
Adrian Klaver-4 wrote
> Here is my very similar function:
>
> CREATE OR REPLACE FUNCTION utility.archive_del_record() RETURNS trigger AS
> $BODY$
> DECLARE
>      tbl_name text := TG_TABLE_NAME || '_delete' ;
>      archive_row hstore := hstore(OLD.*);
>      user_name text := session_user;
> BEGIN
>      EXECUTE 'INSERT INTO ' ||quote_ident(tbl_name) ||
>          '(record_fld, del_ts, del_user)'
>          || ' VALUES('||quote_literal(archive_row)||', now(),' ||
>          quote_literal(user_name)||')';
> RETURN OLD;
> END;
> $BODY$
> LANGUAGE plpgsql SECURITY DEFINER;

Thank you Adrian you made my day!

I compared our functions and came out that the problem was only in quotes...
I have used 3 of them and with hstore one is enough.




--
View this message in context: http://postgresql.nabble.com/Escaping-text-hstore-tp5870728p5870762.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: RAID and SSD configuration question
Next
From: Pavel Stehule
Date:
Subject: Re: My first PL/pgSQL function