Re: [GENERAL] null values in a view

2011-10-05 Thread Lauri Kajan
This worked. Thank you all! I know the casting is quite basic operation but could this be added to the CREATE VIEW documentation? Now there is only an example: CREATE VIEW vista AS SELECT text 'Hello World' AS hello; The same syntax won't work with other type as Tom wrote. -Lauri On Wed, Oct 5,

Re: [GENERAL] null values in a view

2011-10-05 Thread Tom Lane
Lauri Kajan writes: > This works with other values but not with nulls: > CREATE VIEW view1 AS > SELECT > attribute1 as a1, > text null as a2, > text 'test' as a3 > FROM > table; FYI, the syntax typename 'literal' works *only* with string literals, not anything else. For any other targ

Re: [GENERAL] null values in a view

2011-10-05 Thread hubert depesz lubaczewski
On Wed, Oct 05, 2011 at 05:22:21PM +0300, Lauri Kajan wrote: > Hi all, > > How could I create a view that returns null values among all other values. > Here is a sample that i want to achieve: > > CREATE VIEW view1 AS > SELECT > attribute1 as a1, > null as a2 > FROM > table; > > Now the pr

Re: [GENERAL] null values in a view

2011-10-05 Thread Achilleas Mantzios
try: CREATE OR REPLACE VIEW view1 AS SELECT name as a1, null::text as a2, 'test'::text as a3 FROM some_table; Στις Wednesday 05 October 2011 17:22:21 ο/η Lauri Kajan έγραψε: > Hi all, > > How could I create a view that returns null values among all other values. > Here is a sample that i

[GENERAL] null values in a view

2011-10-05 Thread Lauri Kajan
Hi all, How could I create a view that returns null values among all other values. Here is a sample that i want to achieve: CREATE VIEW view1 AS SELECT attribute1 as a1, null as a2 FROM table; Now the problem is that I got an warning: column "a2" has type "unknown" I know that I should de

Re: [GENERAL] NULL values seem to short-circuit my unique index

2008-11-08 Thread Alban Hertroys
On Sep 29, 2008, at 4:59 AM, Chris wrote: Matthew Wilson wrote: I'm trying to comprehend how NULL values interact with unique indexes. It seems like I can insert two rows with NULL values in a column with a unique constraint just fine. Is there something special about NULL? Can anyone post

Re: [GENERAL] NULL values seem to short-circuit my unique index

2008-09-29 Thread Tom Allison
You can always add a constraint that these columns cannot be NULL themselves. That removes this problem. On Sep 28, 2008, at 11:17 PM, Klint Gore <[EMAIL PROTECTED]> wrote: Matthew Wilson wrote: I'm trying to comprehend how NULL values interact with unique indexes. It seems like I can inser

Re: [GENERAL] NULL values seem to short-circuit my unique index

2008-09-28 Thread Klint Gore
Matthew Wilson wrote: I'm trying to comprehend how NULL values interact with unique indexes. It seems like I can insert two rows with NULL values in a column with a unique constraint just fine. Is there something special about NULL? Can anyone post some links to explain what is going on? h

Re: [GENERAL] NULL values seem to short-circuit my unique index

2008-09-28 Thread Tom Lane
Matthew Wilson <[EMAIL PROTECTED]> writes: > It seems like I can insert two rows with NULL values in a column with a > unique constraint just fine. This is per SQL spec and quite well-documented in our manual ... regards, tom lane -- Sent via pgsql-general mailing list (

Re: [GENERAL] NULL values seem to short-circuit my unique index

2008-09-28 Thread Chris
Matthew Wilson wrote: I'm trying to comprehend how NULL values interact with unique indexes. It seems like I can insert two rows with NULL values in a column with a unique constraint just fine. Is there something special about NULL? Can anyone post some links to explain what is going on? When

[GENERAL] NULL values seem to short-circuit my unique index

2008-09-28 Thread Matthew Wilson
I'm trying to comprehend how NULL values interact with unique indexes. It seems like I can insert two rows with NULL values in a column with a unique constraint just fine. Is there something special about NULL? Can anyone post some links to explain what is going on? Here's the example that stump

Re: [GENERAL] NULL values and string

2006-02-02 Thread Berend Tober
Richard Huxton wrote: Sergey Karin wrote: Are there any abilities to represent NULL values as string? Null isn't a real value. Try not to think of it as a value. That being said, and with due credit elsewhere (http://www.varlena.com/varlena/GeneralBits/84.php), what I do is CREATE OR R

Re: [GENERAL] NULL values and string

2006-02-02 Thread Richard Huxton
Sergey Karin wrote: Hi, List! I'm using PG8.1. Are there any abilities to represent NULL values as string? Null isn't a real value. Try not to think of it as a value. http://archives.postgresql.org/pgsql-sql/2003-01/msg00222.php num_value alias for $1; string_value := \'input val

Re: [GENERAL] NULL values and string

2006-02-02 Thread Tino Wildenhain
Sergey Karin schrieb: Hi, List! I'm using PG8.1. Are there any abilities to represent NULL values as string? I'm doing something like this: create function func(int4) returns varchar as' declare num_value alias for $1; string_value varchar; begin string_value := \'input value =

[GENERAL] NULL values and string

2006-02-02 Thread Sergey Karin
Hi, List! I'm using PG8.1. Are there any abilities to represent NULL values as string? I'm doing something like this: create function func(int4) returns varchar as' declare     num_value alias for $1;     string_value varchar; begin       string_value := \'input value = \' || num_value;    ret

Re: [GENERAL] NULL values

2001-07-17 Thread Chad R. Larson
On Tue, Jul 10, 2001 at 09:40:31AM +0100, Mark Muffett wrote: > Is there a Postgresql equivalent to the Oracle NVL( ) function, > which allows a SELECT statement to fill in default values if a > column is NULL? Yes. Use the DEFAULT keyword while creating the table. That is: CREATE TABLE ac