Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread default for BYTE fields?
Thu, Jan 19 2012 4:53 AMPermanent Link

Lucian

Hi,

How does one set a default value for a BYTE field? I thought this should work

ALTER TABLE "table" ALTER COLUMN "ByteColumn" AS BYTE(1) DEFAULT X'01' NOT NULL

however it gives with Error #700 An error was found in the default column expression at line 1 and column 1 (Expected NULL, Byte, GUID, or VarByte expression but instead found '01')

none of this variations work
...AS BYTE(1) DEFAULT 1 NOT NULL
...AS BYTE DEFAULT 1 NOT NULL

What I actually wabted was to set the default when I created the table but also nothing worked, so then I tried altering and now I'm stuck...

Thanks
Lucian
Thu, Jan 19 2012 6:29 AMPermanent Link

John Hay

Lucian
>
> How does one set a default value for a BYTE field? I thought this should work
>
> ALTER TABLE "table" ALTER COLUMN "ByteColumn" AS BYTE(1) DEFAULT X'01' NOT NULL
>

How about

ALTER TABLE "table" ALTER COLUMN "ByteColumn" AS BYTE(1) DEFAULT cast(X'01' as byte) NOT NULL

John


Thu, Jan 19 2012 6:38 AMPermanent Link

Lucian

Thanks a lot, that works Smile
Lucian
Mon, Jan 23 2012 8:26 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Lucian,

<< How does one set a default value for a BYTE field? I thought this should
work

ALTER TABLE "table" ALTER COLUMN "ByteColumn" AS BYTE(1) DEFAULT X'01' NOT
NULL

however it gives with Error #700 An error was found in the default column
expression at line 1 and column 1 (Expected NULL, Byte, GUID, or VarByte
expression but instead found '01') >>

This is a bug, and is fixed for the new build coming out this week.  John's
workaround is correct.

--
Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jan 25 2012 7:22 AMPermanent Link

Lucian

>This is a bug, and is fixed for the new build coming out this week.

Cool!
Lucian
Image