Re: Validating Data

From: Mladen Gogala <>
Date: Sun, 26 Feb 2012 00:17:10 +0000 (UTC)
Message-ID: <>

On Sun, 26 Feb 2012 00:39:11 +0100, Robert Klemme wrote:
>> With all due respect, why would you use a database for such thing?

> The most prominent reason is that general rule to check inputs when they
> enter a system.

This looks like a web application as the original poster has mentioned PHP. Web server looks like the most logical place to prevent an undesired data format from being entered into the system. Of course, there is an advantage of doing it in the database, because the input checking is centralized and you don't have to worry about that in the applications. Oracle also support POSIX character classes in its regular expressions implementation:

SQL> select regexp_count('HAL 9000','[[:digit:]]',1) from dual;



Elapsed: 00:00:00.00
SQL> select regexp_count('HAL 9000','[[:print:]]',1) from dual;



Elapsed: 00:00:00.01
SQL> select regexp_count('HAL 9000','[^[:print:]]',1) from dual;



Elapsed: 00:00:00.01
SQL> select regexp_count('HAL 9000','[^[:digit:]]',1) from dual;



Elapsed: 00:00:00.00

However, having in mind how lightweight things are, when done through PHP I would probably do it in PHP. Maintaining a simple filter on the data, to prevent non-printable characters in the certain fields should not be a problem, either way.

Received on Sat Feb 25 2012 - 18:17:10 CST

Original text of this message