pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Are SQL queries locale dependent?
2+ messages / 2 participants
[nested] [flat]

* Are SQL queries locale dependent?
@ 2005-02-25 09:41  Martin Schäfer <Martin.Schaefer@cadcorp.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Martin Schäfer @ 2005-02-25 09:41 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; pgsql-sql

Hi,

I recently found out that my app doesn't work in Spain because it creates localized queries like this:

create table t (c1 float8, c2 float8);
insert into t (c1, c2) values (3,14159, 1,4142);

I understand that PostgreSQL obviously can't parse this query. But I'm not sure how to fix this query so that it works under all circumstances.

If the database uses the "C" (or e.g. English or US) locale, then I know that I always have to use the decimal dot ('.') instead of a decimal comma (','), regardless of the locale of the client machine.

But what if the database itself uses a locale which mandates a decimal comma, like Spanish, German, etc.? How do I have to construct the SQL query then?

Martin



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Are SQL queries locale dependent?
@ 2005-02-25 15:51  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Martin Schäfer <Martin.Schaefer@cadcorp.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2005-02-25 15:51 UTC (permalink / raw)
  To: Martin Schäfer <Martin.Schaefer@cadcorp.com>; +Cc: pgsql-general@postgresql.org; pgsql-sql

=?iso-8859-1?Q?Martin_Sch=E4fer?= <Martin.Schaefer@cadcorp.com> writes:
> I recently found out that my app doesn't work in Spain because it creates localized queries like this:

> create table t (c1 float8, c2 float8);
> insert into t (c1, c2) values (3,14159, 1,4142);

> I understand that PostgreSQL obviously can't parse this query. But I'm not sure how to fix this query so that it works under all circumstances.

Use dots.  The SQL syntax for a number is not locale-dependent.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-02-25 15:51 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-25 09:41 Are SQL queries locale dependent? Martin Schäfer <Martin.Schaefer@cadcorp.com>
2005-02-25 15:51 ` Tom Lane <tgl@sss.pgh.pa.us>

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