473,396 Members | 1,775 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,396 software developers and data experts.

DB2 CHECK for names?

Hallo,

does anyone know how to perform a

CREATE TABLE TEST(NAME CHAR(40) NOT NULL, CHECK(NAME ???));

I want that i only can insert lower and upper chars. I tried it with the statement

CHECK(NAME BETWEEN 'a' AND 'z') OR (NAME BETWEEN 'A' AND 'Z')

but this only checks the first char of the inserted NAME. Can anyone help me?

Thanks very much!
Nov 12 '05 #1
3 3956
Try:

TRANSLATE(NAME, '!', ' aAbBcC...xXyYzZ) = ''

(You have to fill in all the letters where I used "...")

This will replace space with ! and all the letters with spaces. (Effectively
leaving a non-space character for evey non-letter. You then compare it to a
blank string.
--
__________________________________________________ ___________________
Doug Doole
DB2 Universal Database Development
IBM Toronto Lab

Visit the DB2 UDB and DB2 Connect Online Support site at:
http://www.ibm.com/software/data/db2...s2unix/support
Nov 12 '05 #2
Thank you! After thinking about it, I think I understood it :-) I only
have one more Problem: The NAME field is a CHAR(30) field and am I
right that if I insert a name of the Length 15 the rest will be filled
with '!'? Then the comparison will fail and the CHECK returns false?
So I did this:

CHECK(TRANSLATE(NNAME, '', '
aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY zZ') = '')

But there is the problem that blanks are allowed in the NAME!
Douglas Doole <do***@ca.ibm.com> wrote in message news:<bp**********@hanover.torolab.ibm.com>...
Try:

TRANSLATE(NAME, '!', ' aAbBcC...xXyYzZ) = ''

(You have to fill in all the letters where I used "...")

This will replace space with ! and all the letters with spaces. (Effectively
leaving a non-space character for evey non-letter. You then compare it to a
blank string.

Nov 12 '05 #3
How about this?
CHECK(TRANSLATE(RTRIM(NAME), '!',
' aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY zZ') = '')

fs*****@hotmail.com (Michael Huber) wrote in message news:<8f**************************@posting.google. com>...
Thank you! After thinking about it, I think I understood it :-) I only
have one more Problem: The NAME field is a CHAR(30) field and am I
right that if I insert a name of the Length 15 the rest will be filled
with '!'? Then the comparison will fail and the CHECK returns false?
So I did this:

CHECK(TRANSLATE(NNAME, '', '
aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY zZ') = '')

But there is the problem that blanks are allowed in the NAME!
Douglas Doole <do***@ca.ibm.com> wrote in message news:<bp**********@hanover.torolab.ibm.com>...
Try:

TRANSLATE(NAME, '!', ' aAbBcC...xXyYzZ) = ''

(You have to fill in all the letters where I used "...")

This will replace space with ! and all the letters with spaces. (Effectively
leaving a non-space character for evey non-letter. You then compare it to a
blank string.

Nov 12 '05 #4

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

Similar topics

13
by: Adrian Parker | last post by:
I have a PHP generated page which displays X many records. Each record has a checkbox preceding it. The user checks several checkboxes, and hits a delete button. All the corresponding records...
7
by: Al Kolff | last post by:
Hi, Has anyone come across a utility to check the case of a filename versus a php page? I develop locally on a windows machine (Know Know) then upload to a Linux and everything works usually works...
2
by: Amir Michail | last post by:
Hi, I was wondering if there is a tool that will perform some heuristic checking of actual and formal parameters to warn about likely errors. Such a tool could check that formal and actual...
37
by: Mike Meng | last post by:
hi all, I'm a newbie Python programmer with a C++ brain inside. I have a lightweight framework in which I design a base class and expect user to extend. In other part of the framework, I heavily...
1
by: Patrick Gunia | last post by:
Hi, i´m trying to build a xml - parser, which should simply list all used tokens an dattributes including their values. So far, so good, this works, but now i try to check for illegal phrases in...
2
by: Ben | last post by:
My current project requires me to create part of a form that is created on the fly. The project consists a list of entries to an event. The name and address and such is easy. The design is detup so...
3
by: Chris | last post by:
Hi, In C# I tried to save a file from a generated file name. Just before launching the dialog I check for a valid file name to be sure. There for I used the method ValidateNames from the save...
8
by: Iona | last post by:
Hi Allan, I'm using a nifty piece of code you put on here some time back to do a duplicate entry check as below. I'm using to check for duplicate names. However I am getting an error message on...
18
by: Joel Hedlund | last post by:
Hi! The question of type checking/enforcing has bothered me for a while, and since this newsgroup has a wealth of competence subscribed to it, I figured this would be a great way of learning...
14
by: Martin Wells | last post by:
When I have errors in a program, whether they be compiler errors, linker errors, or if the program crashes when running, I have a list of things I check for initially. If I get an error for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.