Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LIKE clause

Status
Not open for further replies.

mlara

Programmer
Oct 22, 2001
32
CO
Hi

I have the next DDL in MS_SQL Server, which is fine:

CREATE TABLE DEMO(
IDCHAR CHAR(2) CONSTRAINT NameConstraint CHECK (IDCHAR LIKE '[0-9][A-Z]')
);

but on InterBase X does not work.

How I can write this so that works on InterBase?

Thanks.
 
The problem is that the constraint CHECK does not work. When I attempt save a new register, InterBase generate an error and not allow save it.

Which is the equivalent syntax on InterBase for:

CHECK (column LIKE '[0-9][A-Z]')

?

En español:

El problema es que la restricción CHECK no funciona. Cuando intento guardar un nuevo registro, InterBase genera un error y no permite guardarlo.

Cuál es la sintaxis equivalente en InterBase para:

CHECK (column LIKE '[0-9][A-Z]')

?
 
Now I have an answer:

If I write the script DDL like the next, then now yes it work:

CREATE TABLE demo(
idcad CHAR(2) CHECK (SUBSTR(idcad, 1, 1) IN ('0', '1') AND SUBSTR(idcad, 2, 2) IN ('1', '2', '3', '4', '5'))
);

But still I have a doubt. I can define on InterBase sets of characters like on Delphi, so I can write something like this:

CREATE TABLE demo(
idcad CHAR(2) CHECK (SUBSTR(idcad, 1, 1) IN set_1 AND SUBSTR(idcad, 2, 2) IN set_2)
);

?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top