From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | rohtodeveloper <rohtodeveloper(at)outlook(dot)com> |
Cc: | Atri Sharma <atri(dot)jiit(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: How to implent CONVERT ( data_type [ ( length ) ] , expression ) function in postgreSQL |
Date: | 2014-11-02 12:47:53 |
Message-ID: | CAFj8pRAxkX9vumNkYvfo9v8NL_FGA6TnNZZ8zMSEuu4YFMXQ=g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2014-11-02 13:22 GMT+01:00 rohtodeveloper <rohtodeveloper(at)outlook(dot)com>:
> I need the convert function because that Our application will be
> switched from SQL Server to PostgreSQL.
>
> >For the options you suggested:
>
> >1) Pass in datatype as string and deparse and process in the function.
> >2) Are you referring to pg_convert here?
>
> 1) is yes. but I want to use the CONVERT ( data_type [ ( length ) ] ,
> expression ) just as same as in the SQLServer, SO, that doesn't work.
>
usually is more simple fix the application than database.
> 2) I mean modifying the 'src\backend\parser\gram.y' file. There will
> be a grammer conflict with the PostgreSQL self's
> convert(data,src_encoding_name,dest_encoding_name) function.
>
>
you can look on http://www.tpostgres.org/se/ .. there maybe is your problem
solved
Regards
Pavel
>
>
> ------------------------------
> Date: Sun, 2 Nov 2014 16:00:14 +05
> Subject: Re: [HACKERS] How to implent CONVERT ( data_type [ ( length ) ] ,
> expression ) function in postgreSQL
> From: atri(dot)jiit(at)gmail(dot)com
> To: rohtodeveloper(at)outlook(dot)com
> CC: pgsql-hackers(at)postgresql(dot)org
>
>
>
>
> On Sun, Nov 2, 2014 at 3:40 PM, rohtodeveloper <rohtodeveloper(at)outlook(dot)com
> > wrote:
>
>
> Dear
>
>
> In SQLServer, there'are two functions to converte an expression of one
> data type to another.
>
> 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.
> Please do not cross post to multiple lists.
>
>
>
> Please do not cross post to various lists.
>
> For the options you suggested:
>
> 1) Pass in datatype as string and deparse and process in the function.
> 2) Are you referring to pg_convert here?
>
> IMO I do not understand why you need the convert function in the first
> place. You may want to refer to
> http://www.postgresql.org/docs/9.3/static/typeconv.html
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2014-11-02 12:54:39 | Re: Let's drop two obsolete features which are bear-traps for novices |
Previous Message | Simon Riggs | 2014-11-02 12:31:53 | Re: group locking: incomplete patch, just for discussion |