Validate whether the dates are ANSI compliant or not
with dates as (
select '2015-01-01' as dt from dual union all /* Valid date 1 Jan 2015 */
select '2015-99-99' as dt from dual union all /* Invalid day and month 99 */
select '01-01-2015' as dt from dual union all /* In DD-MM-YYYY format */
select '2015-12-31' as dt from dual union all /* Valid date 31 Dec 2015 */
select '2015-12-39' as dt from dual union all /* Invalid date 39 Dec 2015 */
select '2015-31-12' as dt from dual /* Day and month in a wrong way */
)
select * from dates
where regexp_like (dt, '[0-9]{4}-[0-9]{2}-[0-9]{2}')
DT | 2015-01-01 | 2015-99-99 | 2015-12-31 | 2015-12-39 | 2015-31-12 |
---|
Validate whether the dates are ANSI compliant or not
with dates as (
select '2015-01-01' as dt from dual union all /* Valid date 1 Jan 2015 */
select '2015-99-99' as dt from dual union all /* Invalid day and month 99 */
select '01-01-2015' as dt from dual union all /* In DD-MM-YYYY format */
select '2015-12-31' as dt from dual union all /* Valid date 31 Dec 2015 */
select '2015-12-39' as dt from dual union all /* Invalid date 39 Dec 2015 */
select '2015-31-12' as dt from dual /* Day and month in a wrong way */
)
select * from dates
where regexp_like (dt, '[0-9]{4}-[0-1][0-9]-[0-3][0-9]')
DT | 2015-01-01 | 2015-12-31 | 2015-12-39 |
---|
Validate whether the dates are ANSI compliant or not
with dates as (
select '2015-01-01' as dt from dual union all /* Valid date 1 Jan 2015 */
select '2015-99-99' as dt from dual union all /* Invalid day and month 99 */
select '01-01-2015' as dt from dual union all /* In DD-MM-YYYY format */
select '2015-12-31' as dt from dual union all /* Valid date 31 Dec 2015 */
select '2015-02-30' as dt from dual union all /* Invalid date 39 Dec 2015 */
select '2015-31-12' as dt from dual /* Day and month in a wrong way */
)
select * from dates
where regexp_like (dt, '[0-9]{4}-(0[0-9]|1[0-2])-([0-2][0-9]|3[0-1])')
DT | 2015-01-01 | 2015-12-31 |
---|
XML validator for checking a closing tag of an element
with xml as (
select '<element>test<element>' as x from dual union all /* Incorrect closing tag '/' missing */
select '<element>test</different_element>' as x from dual union all /* Different opening and closing tags */
select '<element>test</element>' as x from dual /* Valid open and close tags*/
)
select * from xml
where regexp_like (x, '<.*>.*</.*>')
X | <element>test</different_element> | <element>test</element> |
---|
XML validator for checking the opening and closing tags match
with xml as (
select '<element>test<element>' as x from dual union all /* Incorrect closing tag '/' missing */
select '<element>test</different_element>' as x from dual union all /* Different opening and closing tags */
select '<element>test</element>' as x from dual /* Valid open and close tags*/
)
select * from xml
where regexp_like (x, '<(.*)>.*</(\1)>')
X | <element>test</element> |
---|