473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

SQL0401N on Check constraint on UDT column.

Why should this be incompatible data types when CD is really VARCHAR??

D:\DBA\LDS>db2 "CREATE DISTINCT TYPE CD AS VARCHAR( 5 ) WITH
COMPARISONS"
DB20000I The SQL command completed successfully.

D:\DBA\LDS>db2 "CREATE TABLE X1 (COL1 CD NOT NULL DEFAULT 'I' CHECK
(COL1 IN ('A', 'I')) )"
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0401N The data types of the operands for the operation "IN" are
not
compatible. SQLSTATE=42818
Nov 12 '05 #1
2 3483
That's what makes distinct types distict.
You need to cast col1 to the base type (or the inlist arguments to CD).
Essentially SQL makes you assure that you really want to comaper 'T' with CD
rather than just did so by accident.

Cheers
Serge
Nov 12 '05 #2
Serge Rielau <sr*****@ca.eyebeem.com> wrote:
That's what makes distinct types distict.
You need to cast col1 to the base type (or the inlist arguments to CD).


Or the other way around:

CREATE TABLE x1(col1 cd NOT NULL DEFAILT 'I' CHECK (col1 IN (cd('A'),
cd('I'))) )

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Agoston Bejo | last post by:
I want to enforce such a constraint on a column that would ensure that the values be all unique, but this wouldn't apply to NULL values. (I.e. there may be more than one NULL value in the column.)...
5
by: Doug Baroter | last post by:
Hi, DDL: -- create table #task (taskID int identity(1,1) primary key, taskName varchar(25) unique, taskCompleteDate dateTime, taskComplete bit default(0)); /* Business Rules: a) if...
2
by: Doug Baroter | last post by:
Hi, DDLs and DMLs: create table #job (jobID int identity(1,1) primary key, jobName varchar(25) unique not null, jobEndDate dateTime, jobComplete bit default(0), check (( is null and = 0) OR (...
1
by: Bob Stearns | last post by:
When the "new" data IS NOT NULL or whenever the row is stored? In particular is the first clause needed in: ALTER TABLE IS3.FLUSHES ADD CONSTRAINT PALP_LEFT_OV CHECK (PALP_LEFT_OV IS NULL OR...
9
by: Edmund Dengler | last post by:
Greetings! Just trying some tests out, and wanted to know about some optimizations. If I do a CHECK constraint on a table, is this used to optimize a SELECT or does Postgresql rely mostly on...
3
by: ferg | last post by:
I have a Customer table. The table has two different CHECK constraints. Then there is the Customer details dialog, which provides the user with an UI for changing users. I have some UPDATE sql,...
5
by: new | last post by:
Sorry to bug you with what is a simple question but if you could point me in the right direction I can follow up. I have a sql table field we can call XXX it is the least significant of a four...
1
by: Spectre1337 | last post by:
Hello, it seems like the check constraint validation of MS SQL Server Management Studio express is horribly, horribly broken. Either that or I'm using it wrong. I hope it's the latter. I'm...
2
by: Normann | last post by:
I am working on designing a database for a project at work and am in the process of adding constraints to the various tables. I have run into a bit of trouble with one of them and hope someone here...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.