Re: [SQL] Defining Field Types with view

2004-09-01 Thread Tom Lane
"Traci Sumpter" <[EMAIL PROTECTED]> writes: > Cheesy one here Got a cheesy answer for you --- cast the result ... regression=# create view voo as regression-# select f1::varchar(20) from regression-# (select f1 from foo union select f2 from foo) ss; CREATE VIEW regression=# \d voo

[SQL] Defining Field Types with view

2004-09-01 Thread Traci Sumpter
Cheesy one here I created a view similar to Select field1, field2 from table where field3 = 'Fred' UNION Select field1, field2 from table where field3 = 'Wilma'; When the view contains just one sql statement the field definitions e.g. charater varying (20) however when both a

Re: [SQL] Extracting fieldnames from a TABLE

2004-09-01 Thread Thomas F . O'Connell
One way to do this is to use the column_info database handle method. Here's a little perl script that accepts a table name as an argument and returns the column names: #!/usr/bin/perl use DBI; use strict; my( $database, $table ) = @ARGV; my $dbh = DBI->connect( "dbi:Pg:dbname=$database", 'postgre

Re: [SQL] colored PL with emacs

2004-09-01 Thread John DeSoi
On Aug 31, 2004, at 1:23 PM, Manuel Sugawara wrote: I have SQL highlighting, but what I want are colors for the PL/pgSQL key words. It would make PL programming much easier. Since the Pl/PgSQL code is quoted (x)emacs paints the whole thing using the string face. Delete one of the apostrophes delim

Re: [SQL] German "umlaut insensitive" query

2004-09-01 Thread =?ISO-8859-1?Q?Robert_Str=F6tgen?=
select replace( replace( replace( replace( 'Test ä ö ü ß', 'ä','ae'), 'ö','oe' ), 'ü','ue'), 'ß','ss' ); Thanks a lot. A wrote this into a user defined function with lower() around the source string, and it works. :-) CREATE OR REPLACE FUNCTION public.unumlaut(varchar) RETURNS varchar AS 'sele

[SQL] Extracting fieldnames from a TABLE

2004-09-01 Thread Erik Wasser
Hi community, I would like to retrieve all the fieldnames of a given table. In the perl module Tie::DBI[1] i found the following fragment: $dbh->prepare("LISTFIELDS $table"); in the case the DB supports this (Tie::DBI thinks so for Pg) or the alternative is: $dbh->prepare("SELECT * FROM

Re: [SQL] German "umlaut insensitive" query

2004-09-01 Thread Michael Kleiser
One solution: select replace( replace( replace( replace( 'Test ä ö ü ß', 'ä','ae'), 'ö','oe' ), 'ü','ue'), 'ß','ss' ); replace -- Test ae oe ue ss If you also have upcase-characters, you have to extend the statement. Robert Strötgen schrieb: I want to query words with German

Re: [SQL] casting BOOL to somthng

2004-09-01 Thread Stephan Szabo
On Wed, 1 Sep 2004, Tom Lane wrote: > Peter Eisentraut <[EMAIL PROTECTED]> writes: > > The cast to text, however, is part of the data model, and it has to be > > both natural and universal. I think you agree that there is no > > universal, obvious correspondence between character strings and boo

Re: [SQL] casting BOOL to somthng

2004-09-01 Thread Tom Lane
Peter Eisentraut <[EMAIL PROTECTED]> writes: > The cast to text, however, is part of the data model, and it has to be > both natural and universal. I think you agree that there is no > universal, obvious correspondence between character strings and boolean > values, at least not nearly as unive

[SQL] German "umlaut insensitive" query

2004-09-01 Thread =?ISO-8859-1?Q?Robert_Str=F6tgen?=
I want to query words with German "umlauts" (special characters) with and without normalization. I want to find "grün" (green) written "gruen" as well. Using "LIKE" with locale de_DE.iso88591 or .utf-8 does not help (Locale support should affect "LIKE", http://www.postgresql.org/docs/7.3/static/ch

Re: [SQL] casting BOOL to somthng

2004-09-01 Thread Geoffrey
sad wrote: On Wednesday 01 September 2004 10:38, Michael Glaesemann wrote: On Sep 1, 2004, at 2:41 PM, sad wrote: On Wednesday 01 September 2004 09:24, Stephan Szabo wrote: There's a fairly accepted convention for integer representations. There's no such convention for boolean representations. then

[SQL] casting UNKNOWN to REGCLASS

2004-09-01 Thread sad
> select 't'::text::bool; > ERROR: cannot cast type text to boolean > > If you're thinking 't'::bool, that's something different. Ok i have nothing to opppose and by the way (!!!) why TEXT can not be casted to REGCLASS ? ---(end of broadcast)---

Re: [SQL] casting BOOL to somthng

2004-09-01 Thread Stephan Szabo
On Wed, 1 Sep 2004, sad wrote: > > There's a difference between an output function and a cast to text. > > One gives you an external representation of the data for end use. The > > other gives you an internal representation for manipulation. > > And at the same time > > 't'::TEXT can be casted t

Re: [SQL] casting BOOL to somthng

2004-09-01 Thread sad
> There's a difference between an output function and a cast to text. > One gives you an external representation of the data for end use. The > other gives you an internal representation for manipulation. And at the same time 't'::TEXT can be casted to BOOL 't'::BOOL but reverse.

Re: [SQL] casting BOOL to somthng

2004-09-01 Thread Stephan Szabo
On Wed, 1 Sep 2004, sad wrote: > On Wednesday 01 September 2004 09:24, Stephan Szabo wrote: > > On Wed, 1 Sep 2004, sad wrote: > > > On Tuesday 31 August 2004 17:49, Michael Glaesemann wrote: > > > > On Aug 31, 2004, at 8:24 PM, sad wrote: > > > > > and i am still desire to know _WHY_ there are n

Re: [SQL] casting BOOL to somthng

2004-09-01 Thread Michael Glaesemann
On Sep 1, 2004, at 2:55 PM, sad wrote: On Wednesday 01 September 2004 10:38, Michael Glaesemann wrote: On Sep 1, 2004, at 2:41 PM, sad wrote: On Wednesday 01 September 2004 09:24, Stephan Szabo wrote: There's a fairly accepted convention for integer representations. There's no such convention for b