Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Problem with computed insert value
Sat, Mar 3 2007 8:13 AMPermanent Link

"Ole Willy Tuv"
create table test
(
 col1 integer generated by default as identity,
 col2 char varying(20) collate enu not null,
 constraint pk_test primary key (col1)
)

insert into test (col2) values ('col2 rowid '||cast(col1 as char
varying(5)))

Error:
ElevateDB Error #1004 The column col2 cannot be NULL

The problem seems to be that the expression cast(col1 as char varying(5))
returns null. I'd expect the column reference "col1" in the VALUES clause to
represent the actual value for col1 in the row being inserted, hence the
computed insert value for col2 should be:

col2 rowid 1

Ole Willy Tuv

Mon, Mar 5 2007 8:54 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ole,

<< The problem seems to be that the expression cast(col1 as char varying(5))
returns null. I'd expect the column reference "col1" in the VALUES clause to
represent the actual value for col1 in the row being inserted, hence the
computed insert value for col2 should be:  >>

Column expressions of this nature are evaluated prior to the identity column
assignment, which happens during the actual insert operation due to locking
requirements, hence the identity column at the time of the assignment is
NULL.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image