Re: || operator
От | Vinayak |
---|---|
Тема | Re: || operator |
Дата | |
Msg-id | 1409821984720-5817712.post@n5.nabble.com обсуждение исходный текст |
Ответ на | Re: || operator (Pavel Stehule <pavel.stehule@gmail.com>) |
Ответы |
Re: || operator
|
Список | pgsql-general |
Hi, The || operator with arguments (character,character) works fine and even || operator(character,varchar) also works fine. but || operator is not working as expected with arguments character data type and any other data type like integer,smallint,date,text. Example: postgres=# select 'ab'::char(10) || 4::int; ?column? ---------- ab4 (1 row) postgres=# select 'ab'::char(10) || 'a'::text; ?column? ------------- aba (1 row) so I have created || operator with argument character and anyelement. Example: create or replace function concat_character(character, anyelement) returns text as $$ select concat($1,$2)$$ language sql; create operator || (procedure = concat_character, leftarg = character, rightarg = anyelement); it works fine with argument of type int,smallint,bigint,date etc. but its not working with text and varchar data type. Example: postgres=# select 'ab'::char(10) || 4::int; ?column? ------------- ab 4 (1 row) postgres=# select 'ab'::char(10) || 'b'::text; ?column? ---------- abb (1 row) postgres=# select 'ab'::char(10) || 'b'::varchar(5); ERROR: operator is not unique: character || character varying LINE 1: select 'ab'::char(10) || 'b'::varchar(5); ^ HINT: Could not choose a best candidate operator. You might need to add explicit type casts. Thought? ----- Regards, Vinayak, -- View this message in context: http://postgresql.1045698.n5.nabble.com/operator-tp5817541p5817712.html Sent from the PostgreSQL - general mailing list archive at Nabble.com.
В списке pgsql-general по дате отправления: