Newbie question about escaping in a function

Поиск
Список
Период
Сортировка
От Naeem Bari
Тема Newbie question about escaping in a function
Дата
Msg-id 53F35087CC531844AD19CCAE6FA66929368C@util.agilissystems.com
обсуждение исходный текст
Ответы Re: Newbie question about escaping in a function  (Oliver Elphick <olly@lfix.co.uk>)
Re: Newbie question about escaping in a function  (Thomas F.O'Connell <tfo@sitening.com>)
Список pgsql-general

I have a simple function defined thusly:

 

CREATE OR REPLACE FUNCTION datemath(timestamp with time zone, int4, varchar)

  RETURNS timestamp AS

'

DECLARE

  tdat timestamp;

  rdat timestamp;

BEGIN

  IF ($1 IS NULL) THEN

    TDAT := NOW();

  ELSE

    TDAT := $1;

  END IF;

 

  select tdat + interval ''$2 $3'' into rdat;

  return rdat;

END;

'

  LANGUAGE 'plpgsql' VOLATILE;

 

The problem is the interval part. How do I tell the bugger to use the second and third params as input to interval? I have tried different ways of escaping, from \’$2 $3\’ to ‘’$2 $3’’ and everything else in between, it just doesn’t like it.

 

Help! J

 

Thanks,

naeem

В списке pgsql-general по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: primary key and existing unique fields
Следующее
От: Devrim GUNDUZ
Дата:
Сообщение: [SECURITY] New set of PostgreSQL RPMS are available for download