Re: Error: Operator does not exist: "char"=integer

Поиск
Список
Период
Сортировка
От Julius Tuskenis
Тема Re: Error: Operator does not exist: "char"=integer
Дата
Msg-id 494A46D9.8050505@gmail.com
обсуждение исходный текст
Ответ на Re: Error: Operator does not exist: "char"=integer  (Raymond O'Donnell <rod@iol.ie>)
Ответы Re: Error: Operator does not exist: "char"=integer  (novnov <novnovice@gmail.com>)
Список pgsql-general
Raymond O'Donnell rašė:
> A lot of previously automatic casts were removed in the 8.3 series -
> this is possibly one of them.
>
> You now need to cast explicitly in such cases, e.g.
>
>   select '5'::integer;
>
> Ray.
>
That is a good advice and a good practice. But the solution usually
takes time. For a quick (temporary) solution you could write your own
operator for handling "char" = integer cases.

I had to do it once for an "integer ILIKE text" operator:

CREATE OR REPLACE FUNCTION of_integer_ilike_text(prm_integer integer,
prm_text text)
  RETURNS boolean AS
$BODY$BEGIN
RETURN prm_integer::text ~~* prm_text ;
END;$BODY$
  LANGUAGE 'plpgsql' VOLATILE
  COST 100;
ALTER FUNCTION of_integer_ilike_text(integer, text) OWNER TO useris;

CREATE OPERATOR ~~(
  PROCEDURE = of_integer_ilike_text,
  LEFTARG = int4,
  RIGHTARG = text);

I'm sure you'll manage to do this for "text = integer";

Julius Tuskenis



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

Предыдущее
От: Julius Tuskenis
Дата:
Сообщение: Re: SQL plan in functions
Следующее
От: gerhard
Дата:
Сообщение: DELETE running at snail-speed