Re: [SQL] ARRAY() returning NULL instead of ARRAY[] resp. {}

2005-05-24 Thread Markus Bertheau
Dnia 24-05-2005, wto o godzinie 00:06 -0400, Tom Lane napisa(a): Joe Conway [EMAIL PROTECTED] writes: Markus Bertheau wrote: why does SELECT ARRAY(SELECT 1 WHERE FALSE) return NULL instead of ARRAY[] resp. '{}'? Why would you expect an empty array instead of a NULL? I think he's got

Re: [SQL] ARRAY() returning NULL instead of ARRAY[] resp. {}

2005-05-24 Thread Achilleus Mantzios
O Joe Conway May 23, 2005 : Markus Bertheau wrote: why does SELECT ARRAY(SELECT 1 WHERE FALSE) return NULL instead of ARRAY[] resp. '{}'? Why would you expect an empty array instead of a NULL? NULL is what you'd get for other data types -- for example: One could ask in the same

Re: [SQL] datatype conversion on postgresql 7.4.1

2005-05-24 Thread Richard Huxton
Timo Roessner wrote: and if i try something like: alter table fragment alter column x type numeric(15,2) i get an syntax error, so this seems to be no feature in 7.4.1 (didnt find anything like that in the docs too) what can i do to solve this? there must be some way in postgresql

Re: [SQL] Transaction in plpgslq

2005-05-24 Thread Rafa Couto
2005/5/20, Andrew Hammond [EMAIL PROTECTED]: The solution to your problem is locking (or concurrency control if you prefer). While we're at it, we might as well optimize your statement a little too using ORDER BY with LIMIT instead of min(). SELECT id INTO _contacto_id FROM contactos

Re: [SQL] could not devise a query plan

2005-05-24 Thread Szűcs Gábor
Dear Gurus, Sorry for upping a 13-month-old thread; please tell if I should've opened another one. Here I come again, with another silly join. Please forgive me, but our queries are built from blocks :) VERSION: 7.4.6, 7.4.8, 8.0.0rc4 (sorry, no newer installed right now) ABSTRACT: The

Re: [SQL] Transaction in plpgslq

2005-05-24 Thread Jan B.
Rafa Couto wrote: 2005/5/20, Andrew Hammond [EMAIL PROTECTED]: The solution to your problem is locking (or concurrency control if you prefer). While we're at it, we might as well optimize your statement a little too using ORDER BY with LIMIT instead of min(). SELECT id INTO _contacto_id FROM

Re: [SQL] Transaction in plpgslq

2005-05-24 Thread Richard Huxton
Rafa Couto wrote: I have got a plpgsql function: -- BEGIN; SELECT min(id) INTO _contacto_id FROM contactos WHERE contactos.operadora_id IS NULL AND contactos.actividad_id = _actividad_id; UPDATE contactos SET operadora_id = _operadora_id WHERE id = _contacto_id; --

Re: [SQL] Transaction in plpgslq

2005-05-24 Thread Andrew Hammond
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Rafa Couto wrote: I understand FOR UPDATE clause is locking while is selecting rows only. It does not secure atomic execution from 'SELECT' to 'UPDATE' in next statement. Is not it? Locks adhere until the transaction ends. I included links to

[SQL] DROP IF ...

2005-05-24 Thread CG
PostgreSQL 7.4 ... I'm trying to find a way to drop a table via SQL if it contains 0 rows. Here was my thought: CREATE OR REPLACE FUNCTION dropif(text, bool) RETURNS bool AS 'DECLARE tblname ALIAS FOR $1; condition ALIAS FOR $2; BEGIN IF (condition) THEN EXECUTE(\'DROP TABLE \' ||

Re: [SQL] Help: Function for splitting VARCHAR column and migrating its data to 2 new tables

2005-05-24 Thread Tony Wasson
On 5/23/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I am restructuring my DB schema and need help migrating data from 1 column of an existing table to two new tables. I have some Java code that can do this for me, but it's very slow, and I am now hoping I can migrate this data with some

[SQL] Tip ?

2005-05-24 Thread Alain
This tip was at the end of a message (from Szcs Gbor). TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match it looks very important, but I cannot understand it. Sound as a small and easy mistake that can make things go

Re: [SQL] Tip ?

2005-05-24 Thread Scott Marlowe
On Tue, 2005-05-24 at 13:26, Alain wrote: This tip was at the end of a message (from Szcs Gbor). TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match it looks very important, but I cannot understand it. Sound as a small

Re: [SQL] could not devise a query plan

2005-05-24 Thread Tom Lane
=?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= [EMAIL PROTECTED] writes: ABSTRACT: The following query fails. SELECT * FROM (SELECT a,b FROM cdqp WHERE a=1 AND b=2) AS aa NATURAL FULL JOIN (SELECT a,b FROM cdqp WHERE a=1 and b=2) AS bb WHERE a+b = 3; Thanks for the

[SQL] Duplicated records

2005-05-24 Thread lucas
Hi. How can I delete the duplicated records with DELETE FROM TABLE WHERE... clause?? The problem is becouse I have imported data from Dbase (dbf) file, and this function have not built the Constraint (unique, primary key, ...), and this function is usually executed. select * from table1; --id

Re: [SQL] Duplicated records

2005-05-24 Thread PFC
How can I delete the duplicated records with DELETE FROM TABLE WHERE... clause?? The problem is becouse I have imported data from Dbase (dbf) file, and this function have not built the Constraint (unique, primary key, ...), and this function is usually executed. If you have no primary

Re: [despammed] [SQL] Duplicated records

2005-05-24 Thread Andreas Kretschmer
am 24.05.2005, um 17:59:31 -0300 mailte [EMAIL PROTECTED] folgendes: Hi. How can I delete the duplicated records with DELETE FROM TABLE WHERE... clause?? Please read http://www.gtsm.com/oscon2003/deletetid.html Its a very good article about this problem. Regards, Andreas -- Andreas