[SQL] Uppercase and Lowercase

2007-02-19 Thread Shavonne Marietta Wijesinghe
Hello In my PostgreSQL database i have records inserted in Uppercase. For example: VIA SENATO What i want is to change them to Via Senato. Ofcourse i'm looking for a automatico way. I wrote this code update registro1 set pa_indirizzo = upper(substr(pa_indirizzo, 1, 1))

Re: [SQL] Uppercase and Lowercase

2007-02-19 Thread Bart Degryse
Replace by || Shavonne Marietta Wijesinghe [EMAIL PROTECTED] 2007-02-19 16:22 Hello In my PostgreSQL database i have records inserted in Uppercase. For example: VIA SENATO What i want is to change them to Via Senato. Ofcourse i'm looking for a automatico way. I wrote this code update

Re: [SQL] Uppercase and Lowercase

2007-02-19 Thread Andrew Sullivan
On Mon, Feb 19, 2007 at 04:22:06PM +0100, Shavonne Marietta Wijesinghe wrote: Hello In my PostgreSQL database i have records inserted in Uppercase. For example: VIA SENATO What i want is to change them to Via Senato. Have a look at the initcap() function. A -- Andrew Sullivan |

Re: [SQL] Uppercase and Lowercase

2007-02-19 Thread Shavonne Marietta Wijesinghe
Hey thanks Bart. it worked ;) but sadly what it does is changes VIA SENATO in to Via senato but what i need is Via Senato Anyoneee?? Shavonne Wijesinghe - Original Message - From: Bart Degryse To: pgsql-sql@postgresql.org Sent: Monday, February 19, 2007 4:25 PM

Re: [SQL] Uppercase and Lowercase

2007-02-19 Thread Bart Degryse
Of course it does. That's what you ask your query to do. You only used the wrong operator for string concatenation, which is why it didn't seem to work. But your query will not do this for each word in a field. For that you need a function or regular expressions. I suggest you try select

Re: [SQL] Uppercase and Lowercase

2007-02-19 Thread Alvaro Herrera
Shavonne Marietta Wijesinghe wrote: Hey thanks Bart. it worked ;) but sadly what it does is changes VIA SENATO in to Via senato but what i need is Via Senato Anyoneee?? initcap() does what you want. -- Alvaro Herrerahttp://www.CommandPrompt.com/

Re: [SQL] Uppercase and Lowercase

2007-02-19 Thread Bart Degryse
Robert is right of course. You can eg use a trigger to do that... I haven't tested, but I guess something like this would do what you want whenever you insert records in your table CREATE OR REPLACE FUNCTION public.func_change_case () RETURNS trigger AS $body$ BEGIN NEW.pa_indirizzo :=

[SQL] cartesian product

2007-02-19 Thread Salman Tahir
Hi, I have a query regarding an SQL statement I'm trying to execute. I have the following table: sequence -+ AK AKCMK CMKA I execute the following statement (Cartesian product): SELECT p1.sequence as sequence1, p2.sequence as sequence2 FROM potential_pairs p1, potential_pairs p2

Re: [SQL] cartesian product

2007-02-19 Thread Scott Marlowe
On Mon, 2007-02-19 at 10:58, Salman Tahir wrote: Hi, I have a query regarding an SQL statement I'm trying to execute. I have the following table: sequence -+ AK AKCMK CMKA I execute the following statement (Cartesian product): SELECT p1.sequence as sequence1,

Re: [SQL] cartesian product

2007-02-19 Thread Scott Marlowe
On Mon, 2007-02-19 at 10:58, Salman Tahir wrote: Hi, I have a query regarding an SQL statement I'm trying to execute. I have the following table: sequence -+ AK AKCMK CMKA I execute the following statement (Cartesian product): SELECT p1.sequence as sequence1,

Re: [SQL] cartesian product

2007-02-19 Thread Luiz K. Matsumura
Hi, Salman Maybe this isn't so much elegant, but works: SELECT p1.sequence as sequence1, p2.sequence as sequence2 FROM potential_pairs p1, potential_pairs p2 WHERE p1.sequence = p2.sequence Hope this helps Salman Tahir wrote: Hi, I have a query regarding an SQL statement I'm trying to

[SQL] DISTINCT ON not working...?

2007-02-19 Thread Phillip Smith
Hi all, Strange one - I have a nightly export / import routine that exports from one database and imports to another. Has been working fine for several months, but last night it died on a unique constraint. To cut out all the details, the code that is causing the problem: SELECT

Re: [SQL] DISTINCT ON not working...?

2007-02-19 Thread Tom Lane
Phillip Smith [EMAIL PROTECTED] writes: To cut out all the details, the code that is causing the problem: SELECT DISTINCT ON (ean) code, CASE WHEN ean IS NULL OR valid_barcode(ean) = false THEN null ELSE ean END AS ean FROMTMPTABLE

Re: [SQL] DISTINCT ON not working...?

2007-02-19 Thread Phillip Smith
Removing the CASE statement all together: SELECT DISTINCT ON (ean) ean, count(*) FROMTMPTABLE WHERE code NOT IN (SELECT code FROM stock_deleted) ANDean IS NOT NULL GROUP BY ean Still gives me: 3246576919422 2 -Original Message- From: Tom Lane

Re: [SQL] can someone explain confusing array indexing nomenclature

2007-02-19 Thread Achilleas Mantzios
Στις Παρασκευή 16 Φεβρουάριος 2007 20:35, ο/η chrisj έγραψε: I am quite sure the [2] is not discarded, easy enough to test but I don't have access to PG at the moment. Well it should, since dynacom=# SELECT (CAST( '{{meeting,lunch},{training,presentation}}' as text[][]))[1:1]; text