Question

I'm trying to define a domain which will allow to pass only 6 chars strings. I'm declaring it in a following way:

create domain aircrafts_reg_nos as char(6)
check(length(@value) = 6)

But this doesn't seem to catch strings which are longer than 6 chars. Is there a way to enforce it?

Was it helpful?

Solution

length is not a Sybase SQL function. To find the length of a character field, use *char_length*. So your code should probably look something like this.

create domain aircrafts_reg_nos as char(6)
check(char_length(@value) = 6)

Also, try to do a little more research to make sure you are using the right function names in your code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top