Re: [SQL] casting character varying to integer - order by numeric sort

2005-10-19 Thread Tom Lane
Bryce W Nesbitt <[EMAIL PROTECTED]> writes: > SELECT username,last_name > FROM eg_member ORDER BY username::integer; > But postgres 7 rejects this with "ERROR: cannot cast type character > varying to integer". As a general rule, you need to be more specific than that about which version you

Re: [SQL] casting character varying to integer - order by numeric

2005-10-19 Thread Terry Fielder
Check out the function to_number() In particular here's an example... If a field named section is text containing numbers: ORDER BY to_number(t.section, text()) If the field can also contain non-numerals such as 3a, 3b, and you want 3a to show first then do this: ORDER BY to_number(t.s

[SQL] casting character varying to integer - order by numeric sort

2005-10-19 Thread Bryce W Nesbitt
How can I force a character field to sort as a numeric field? I've got something like this: Postgres=> SELECT username,last_name FROM eg_member ORDER BY username; --+--- 0120 | Foley 1| Sullivan 10 | Guest 11 | User (5 rows) (I can't chang

Re: [SQL] NULL in IN clause

2005-10-19 Thread Stephan Szabo
On Wed, 19 Oct 2005, [iso-8859-2] Havasv?lgyi Ott? wrote: > Hi, > > I have just run this command on 8.0.4 : > > SELECT 'foo' WHERE 0 NOT IN (NULL, 1); > > And it resulted is zero rows. > Without NULL it is OK. > Is this a bug, or the standard has such a rule? This is standard behavior. Seeing if

Re: [SQL] NULL in IN clause

2005-10-19 Thread Tom Lane
=?iso-8859-2?Q?Havasv=F6lgyi_Ott=F3?= <[EMAIL PROTECTED]> writes: > I have just run this command on 8.0.4 : > SELECT 'foo' WHERE 0 NOT IN (NULL, 1); > And it resulted is zero rows. > Without NULL it is OK. > Is this a bug, or the standard has such a rule? This is per spec. The computation is ef

Re: [SQL] NULL in IN clause

2005-10-19 Thread David Dick
As i understand it, the use of NULL in SQL means the value of the column is unknown. Therefore that result would seem fair. Havasvölgyi Ottó wrote: Hi, I have just run this command on 8.0.4 : SELECT 'foo' WHERE 0 NOT IN (NULL, 1); And it resulted is zero rows. Without NULL it is OK. Is this

Re: [SQL] NULL in IN clause

2005-10-19 Thread Terry Fielder
Havasvölgyi Ottó wrote: Hi, I have just run this command on 8.0.4 : SELECT 'foo' WHERE 0 NOT IN (NULL, 1); 0 <> NULL (Indeed nothing equals NULL, other then sometimes NULL itself) 0 <> 1 Therefore, the statement: 0 NOT IN (NULL, 1) Should always equate to false. Therefore No rows retur

[SQL] NULL in IN clause

2005-10-19 Thread Havasvölgyi Ottó
Hi, I have just run this command on 8.0.4 : SELECT 'foo' WHERE 0 NOT IN (NULL, 1); And it resulted is zero rows. Without NULL it is OK. Is this a bug, or the standard has such a rule? Best Regards, Otto ---(end of broadcast)--- TIP 4: Have you

Re: [SQL] Problem -Postgre sql

2005-10-19 Thread Muralidharan Ramakrishnan
COALESCE( , )   Vikas J <[EMAIL PROTECTED]> wrote: Hi I want to know substitute function for sql server ISNULL() function in postgre   Regards,Vikas Jadhav Codec Communication Pvt. Ltd.Swargate, Pune.Ph: 020-2422 1460/70 (Ext 37)Email: [EMAIL PROTECTED] Yahoo! India Matrimony: Find your pa

[SQL] Character set error

2005-10-19 Thread Mauricio Fernandez A.
Good Day. I´m working with postgres 7.4. on Win XP and when I do a query like select* from table it returns me this error message: Invalid character data was found. This is most likely caused by stored data containing characters that are invalid for the character set the database was created in

[SQL] Sql - Error en ejecución de función Post gres desde cliente VFoxPro

2005-10-19 Thread Adriana Marcela Aguirre
Hola a todos!!   Muchas gracias a Mario Splivalo por responder mi mail anterior!!! Tengo otro problema. Yo ejecuto una función en Postgresql desde una aplicación realizada en VFoxPro. La función crea una tabla temporal con la sintaxis CREATE TEMPORAY TABLE tmp_datos (...) ON COMMIT DROP;  Si ejecu

Re: [SQL] Field Separator not working?

2005-10-19 Thread Mario Splivalo
On Wed, 2005-10-19 at 11:43 +0100, Richard Huxton wrote: > Mario Splivalo wrote: > > pulitzer2=# \t > > Showing only tuples. > > pulitzer2=# \f# > > Field separator is "#". > > pulitzer2=# select * from pg_user; > > mario |1 | t | t| t | | > > > psql

Re: [SQL] Field Separator not working?

2005-10-19 Thread Richard Huxton
Mario Splivalo wrote: pulitzer2=# \t Showing only tuples. pulitzer2=# \f# Field separator is "#". pulitzer2=# select * from pg_user; mario |1 | t | t| t | | psql does tell me that I changed the field separator to "#", but it still uses "|" as sep

Re: [SQL] SEVEN cross joins?!?!?

2005-10-19 Thread Frank Bax
At 09:04 AM 10/13/05, Daryl Richter wrote: Frank Bax wrote: [snip] Richard, you've summed it up nicely. Splitting locations into subsets (like 2,2,3) doesn't work because it is possible that low values in one location can be offset by high values in another location, and still result in an

[SQL] Field Separator not working?

2005-10-19 Thread Mario Splivalo
I'm having troubles setting the field separator. I tried this on pg7.4, 8.0 and 8.1beta, and I always get the same results. So, from within psql i do: pulitzer2=# select * from pg_user; usename | usesysid | usecreatedb | usesuper | usecatupd | passwd | valuntil | useconfig ---+---

Re: [SQL] Problem while using start transaction ans commit;

2005-10-19 Thread Oliver Elphick
On Mon, 2005-10-17 at 12:53 +0530, Sri wrote: > Hi All, > > I have a small problem in using nested transactions while working on > Postgres 8.0. > > Ex: I have a function A() which in turn calls functions b() and c() , > if i want commit something in b or c. i have to use You cannot start or

Re: [SQL] Query information needed

2005-10-19 Thread Oliver Elphick
On Thu, 2005-10-13 at 05:50 -0700, [EMAIL PROTECTED] wrote: > Dear all, > > I have a table created with this specifications: > > CREATE TABLE cdr ( > calldate timestamp with time zone NOT NULL default now(), > clid varchar(80) NOT NULL default '', > src varchar(80) NOT NULL default '', >

Re: [SQL] Double query (limit and offset)

2005-10-19 Thread Richard Huxton
Michael Landin Hostbaek wrote: List, I'm using the OFFSET / LIMIT combo in order to split up my query, so it only parses 20 rows at a time (for my php-scripted webpage). The best way to do it is to have a layer between your application and the database that can cache the results of your quer

Re: [SQL] Double query (limit and offset)

2005-10-19 Thread Janning Vygen
Am Dienstag, 11. Oktober 2005 17:11 schrieb Michael Landin Hostbaek: > List, > > I'm using the OFFSET / LIMIT combo in order to split up my query, so it > only parses 20 rows at a time (for my php-scripted webpage). > > I'm using two queries; the first basically doing a select count(*) from > [bla