[SQL] Are SQL queries locale dependent?

2005-02-25 Thread Martin Schäfer
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

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [SQL] [GENERAL] Are SQL queries locale dependent?

2005-02-25 Thread Tom Lane
=?iso-8859-1?Q?Martin_Sch=E4fer?= <[EMAIL PROTECTED]> 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

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] Junk queries with variables?

2005-02-25 Thread KÖPFERL Robert
PL/pgSQL is not part of template1 = if you create a new database.
Thus you can use for functions just pure SQL or C. To get pgSQL I did that:

CREATE OR REPLACE FUNCTION plpgsql_call_handler()
  RETURNS language_handler AS
'$libdir/plpgsql', 'plpgsql_call_handler'
  LANGUAGE 'c' VOLATILE;


 CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql'
  HANDLER plpgsql_call_handler;


C:\> -Original Message-
C:\> From: Steve - DND [mailto:[EMAIL PROTECTED]
C:\> Sent: Donnerstag, 24. Februar 2005 18:41
C:\> To: KÖPFERL Robert; pgsql-sql@postgresql.org
C:\> Subject: RE: Junk queries with variables?
C:\> 
C:\> 
C:\> >
C:\> > In pgadmins SQL-window SQL is the 'language' of choice. Or it is
C:\> > rather the
C:\> > only language. Thus if you intend to program plTk or 
C:\> PL/pgSQL, there's no
C:\> > way around defining a function.
C:\> >
C:\> > (At first you have to define a new language in your schema)
C:\> 
C:\> I'm a little confused, is there no way around this, or are 
C:\> you saying I need
C:\> to use CREATE LANGUAGE to define a new language to use? 
C:\> Currently the only
C:\> language I have for the DB is plpgsql.
C:\> 
C:\> Thanks,
C:\> Steve
C:\> 
C:\> 

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly