Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux