Re: Migration from DB2 to PostgreSQL

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: "sachin kotwal *EXTERN*" <kotsachin(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Migration from DB2 to PostgreSQL
Date: 2013-06-20 01:10:05
Message-ID: CA+HiwqFu7S51n1=pUhr3eGgZHvOrQ0orjxE5trzWm9mOcCmANg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jun 19, 2013 at 6:00 PM, Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> wrote:
> sachin kotwal wrote:
>> While migrating my application from DB2 to PostgreSQL.
>>
>> I want to migrate following functions in PostgreSQL.
>>
>> TO_CHAR() in DB2 which can take three arguments as follows:
>>
>> SELECT TO_CHAR(CURRENT_DATE,'YYYY-MM-DD',112.50) FROM SYSIBM.SYSDUMMY1
>>
>> I am not sure what is the purpose of third argument in TO_CHAR() function of
>> DB2.
>>
>> I think we can create one user define function with name TO_CHAR which can
>> take three argument like DB2.
>>
>> I want to know that if we want to create user define function TO_CHAR().
>> What should be the data type of third argument?
>>
>> which can handle maximum data types and more suitable for real time
>> scenarios.
>
> Look at IBM's documentation at
> http://pic.dhe.ibm.com/infocenter/db2luw/v10r1/index.jsp?topic=%2Fcom.ibm.db2.luw.sql.ref.doc%2Fdoc%2Fr0007110.html
>
> TO_CHAR is a synonym for VARCHAR_FORMAT.
> The third argument is an optional locale name, like 'en_US',
> which will be used to generate the text parts of the
> format you chose.
>
> For a format like 'YYYY-MM-DD' this has no effect at all
> and can be omitted.
>
> PostgreSQL has no such capability. Unless you need that and
> want to code it yourself, the best solution would be to
> write a function that just ignores the third argument.
>

Just wondering:

If this particular function is to be used repeatedly in a single
query, would the cost of having a wrapper function around the original
function be too large? For example, if this function appears in a
WHERE clause against a table containing millions of rows.

--
Amit Langote

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Angelico 2013-06-20 01:27:08 Re: Migration from DB2 to PostgreSQL
Previous Message David Johnston 2013-06-20 00:03:57 Re: Carry forward last observation