pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ron <ronljohnsonjr@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: function to_char(unknown) is not unique at character 8
Date: Thu, 06 Jul 2023 10:07:23 -0400
Message-ID: <1204404.1688652443@sss.pgh.pa.us> (raw)
In-Reply-To: <937cdcff-5ecd-afdf-8b86-64c0c6c982fa@gmail.com>
References: <2f8f581c.67f1.1892a7fba60.Coremail.gzhcoder@126.com>
	<937cdcff-5ecd-afdf-8b86-64c0c6c982fa@gmail.com>

Ron <ronljohnsonjr@gmail.com> writes:
> On 7/6/23 04:19, gzh wrote:
>> when I execute the sql below , the to_char function caused the following 
>> error.
>> select TO_CHAR('1000000');

> Isn't '1000000' already a character string?

Nope; in the mind of the Postgres parser, it's a literal of unknown type,
with the actual type to be inferred from context.  There is a small
preference for resolving such a thing as being of text type, but only a
small one.  The rules are exactly the same as for an undecorated NULL
constant.

			regards, tom lane





view thread (12+ messages)  latest in thread

Message-ID: <1204404.1688652443@sss.pgh.pa.us>
Permalink:  ../1204404.1688652443@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1204404.1688652443@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ronljohnsonjr@gmail.com
  Subject: Re: function to_char(unknown) is not unique at character 8
  In-Reply-To: <1204404.1688652443@sss.pgh.pa.us>
  References: <2f8f581c.67f1.1892a7fba60.Coremail.gzhcoder@126.com> <937cdcff-5ecd-afdf-8b86-64c0c6c982fa@gmail.com> <1204404.1688652443@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox