I am writing a query that performs various checks on database tables and returns a summary of the result (in one result set)
IF ( select COUNT(*) from member_table WHERE password IS NULL ) > 0
SELECT 'password check' as name, 'ERROR' as result ,'there is user(s) with blank password' as description
ELSE
SELECT 'password check' as name, 'COMPLETED' as result, 'OK' as description
UNION
IF ( select COUNT(*) from server_context_properties ) = 0
SELECT 'context properties check' as name, 'ERROR' as result ,'no context property has been entered' as description
ELSE
SELECT 'context properties check' as name, 'COMPLETED' as result, 'OK' as description
the result table should look like this:
name result description
password check COMPLETED OK
contex properties check ERROR no context property has been entered
I know that the syntax is incorrect, but I cannot think of any way to achieve this.
source
share