How to implent the CONVERT ( data_type [ ( length ) ] , expression ) function in PostgreSQL

Поиск
Список
Период
Сортировка
От rohtodeveloper
Тема How to implent the CONVERT ( data_type [ ( length ) ] , expression ) function in PostgreSQL
Дата
Msg-id BAY178-W2247CBC96FD5382C609130C4980@phx.gbl
обсуждение исходный текст
Ответы Re: How to implent the CONVERT ( data_type [ ( length ) ] , expression ) function in PostgreSQL  (Emanuel Calvo <emanuel.calvo@2ndquadrant.com>)
Список pgsql-general
Dear

I'm doing a job about converting an expression of one data type to another.
In SQLServer, there'are two functions to do this job.

1. CAST ( expression AS data_type [ ( length ) ] )
2. CONVERT ( data_type [ ( length ) ] , expression )

However, In PostgreSQL, there's only the CAST ( expression AS data_type [ ( length ) ] ) function. I have tried the following two ways to implenting the CONVERT ( data_type [ ( length ) ] , expression ) function, but both are failed.

1. CREATE FUNCTION ..... 
The function's arguments can only be expressions but not data_type . 
2. Modifying the gram.y .....
The CONVERT ( data_type [ ( length ) ] , expression ) is in grammer conflict with the PostgreSQL self's convert(data,src_encoding_name,dest_encoding_name) function. And the PostgreSQL self's convert(data,src_encoding_name,dest_encoding_name) function cannot be used.

I wonder whether there's a better way to solve this problem. 
Any help will be appreciated.

Best Regards
Rohtodeveloper

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

Предыдущее
От: Jonathan Rogers
Дата:
Сообщение: Re: PL/Python prepare example's use of setdefault
Следующее
От: Emanuel Calvo
Дата:
Сообщение: Re: How to implent the CONVERT ( data_type [ ( length ) ] , expression ) function in PostgreSQL