Re: Converting an expression of one data type to another

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: rohtodeveloper <rohtodeveloper(at)outlook(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Converting an expression of one data type to another
Date: 2014-10-30 13:14:21
Message-ID: 545239AD.4020601@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I think you're looking for the pgsql-general mailing list. This list is
for PostgreSQL extensions and core database engine software development.

On 10/30/2014 07:44 PM, rohtodeveloper wrote:
> 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

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2014-10-30 13:24:57 Re: Wait free LW_SHARED acquisition - v0.9
Previous Message Michael Paquier 2014-10-30 13:05:37 Re: Review of Refactoring code for sync node detection